Signed by hanna SSH key fingerprint: SHA256:4g9cWhkAAw8gwqhJUcVbSnGEvdGwklW+1Aa/fMUu59k
crates/git/src/repo.rs +48 −0 crates/web/src/activity.rs +4 −5 crates/git/src/repo.rs +48 −0 323 } 323 } 324 } 324 } 325 325 326 327 328 329 330 331 332 333 334 pub fn commits_all_branches ( 335 & self , 336 per_branch : usize , 337 ) -> Result < Vec < ( CommitSummary , String ) > , GitError > { 338 let branches = self . branch_names ( ) ?; 339 let mut seen: std:: collections:: HashSet < String > = std:: collections:: HashSet :: new ( ) ; 340 let mut out: Vec < ( CommitSummary , String ) > = Vec :: new ( ) ; 341 for branch in & branches { 342 let Ok ( rev) = self . resolve_ref ( branch) else { 343 continue ; 344 } ; 345 let start = git2:: Oid :: from_str ( rev. oid. as_str ( ) ) ?; 346 let mut walk = self . inner. revwalk ( ) ?; 347 walk. set_sorting ( Sort :: TIME ) ?; 348 walk. push ( start) ?; 349 for oid in walk. take ( per_branch) { 350 let oid = oid?; 351 if !seen. insert ( oid. to_string ( ) ) { 352 continue ; 353 } 354 let commit = self . inner. find_commit ( oid) ?; 355 out. push ( ( commit_summary ( & commit) , branch. clone ( ) ) ) ; 356 } 357 } 358 Ok ( out) 359 } 360 326 361 327 362 328 363 1126 } 1161 } 1127 1162 1128 # [ test ] 1163 # [ test ] 1164 fn commits_all_branches_dedupes_and_covers_feature ( ) { 1165 let fx = fixture ( ) ; 1166 let repo = open ( & fx) ; 1167 let all = repo. commits_all_branches ( 50 ) . unwrap ( ) ; 1168 1169 1170 assert_eq ! ( all. len ( ) , 3 , "deduplicated across branches" ) ; 1171 1172 let feat = all. iter ( ) . find ( |( c, _) | c. summary == "add extra module" ) ; 1173 assert_eq ! ( feat. map ( |( _, b) | b. as_str ( ) ) , Some ( "feature" ) ) ; 1174 } 1175 1176 # [ test ] 1129 fn commit_returns_full_detail ( ) { 1177 fn commit_returns_full_detail ( ) { 1130 let fx = fixture ( ) ; 1178 let fx = fixture ( ) ; 1131 let repo = open ( & fx) ; 1179 let repo = open ( & fx) ;
crates/web/src/activity.rs +4 −5 74 let mut feed: Vec < FeedItem > = Vec :: new ( ) ; 74 let mut feed: Vec < FeedItem > = Vec :: new ( ) ; 75 75 76 for repo in & repos { 76 for repo in & repos { 77 let rev_name = repo. default_branch. clone ( ) ; 77 78 let commits = git_read ( state, & repo. id, move |r| { 78 let commits = git_read ( state, & repo. id, move |r| { 79 let rev = r. resolve_ref ( & rev_name) ?; 79 r. commits_all_branches ( SCAN_PER_REPO ) 80 r. commits ( & rev, None , git:: Page :: first ( SCAN_PER_REPO ) ) 81 } ) 80 } ) 82 . await ; 81 . await ; 83 let Ok ( commits) = commits else { continue } ; 82 let Ok ( commits) = commits else { continue } ; 84 83 85 for c in commits { 84 for ( c, branch) in commits { 86 if !c. author. email. eq_ignore_ascii_case ( & email) { 85 if !c. author. email. eq_ignore_ascii_case ( & email) { 87 continue ; 86 continue ; 88 } 87 } 99 feed. push ( FeedItem { 98 feed. push ( FeedItem { 100 owner: user. username. clone ( ) , 99 owner: user. username. clone ( ) , 101 repo: repo. path. clone ( ) , 100 repo: repo. path. clone ( ) , 102 branch: repo. default_branch. clone ( ) , 101 branch, 103 short: c. oid. short ( ) . to_string ( ) , 102 short: c. oid. short ( ) . to_string ( ) , 104 oid: c. oid. to_string ( ) , 103 oid: c. oid. to_string ( ) , 105 summary: c. summary. clone ( ) , 104 summary: c. summary. clone ( ) ,