The last-commit walk counts every commit it visits, so a rarely changed directory can no longer walk a huge history
Browse files at this commit28e31436ed86500092a942764d6197d108731db2Parent: c25199eSome checks failed
Show checks
ci/buildFailedDetails
- fix
- the last-commit walk counts every commit it visits, so a rarely changed directory can no longer walk a huge history
- the cap is 10 000 commits
3 changed files +3 -3
- crates/forge-git/src/history.rs +1 -1
- crates/forge-git/tests/integration/history.rs +1 -1
- crates/forge-web-pages/src/pages/tree.rs +1 -1
crates/forge-git/src/history.rsmodified+1 -1
| @@ -912,6 +912,7 @@ fn last_commits_blocking( | |||
| 912 | if walked == max_walk || found.len() == wanted.len() { | 912 | if walked == max_walk || found.len() == wanted.len() { |
| 913 | break; | 913 | break; |
| 914 | } | 914 | } |
| 915 | + walked += 1; | ||
| 915 | let id = info.map_err(browse::gerr)?.id; | 916 | let id = info.map_err(browse::gerr)?.id; |
| 916 | let object = repo.find_commit(id).map_err(browse::gerr)?; | 917 | let object = repo.find_commit(id).map_err(browse::gerr)?; |
| 917 | let parents: Vec<gix::ObjectId> = object.parent_ids().map(|p| p.detach()).collect(); | 918 | let parents: Vec<gix::ObjectId> = object.parent_ids().map(|p| p.detach()).collect(); |
| @@ -933,7 +934,6 @@ fn last_commits_blocking( | |||
| 933 | if cur.as_ref().map(|t| t.id().detach()) == prev.as_ref().map(|t| t.id().detach()) { | 934 | if cur.as_ref().map(|t| t.id().detach()) == prev.as_ref().map(|t| t.id().detach()) { |
| 934 | continue; | 935 | continue; |
| 935 | } | 936 | } |
| 936 | - walked += 1; | ||
| 937 | let cur = dir_entries(cur, wanted)?; | 937 | let cur = dir_entries(cur, wanted)?; |
| 938 | let prev = dir_entries(prev, wanted)?; | 938 | let prev = dir_entries(prev, wanted)?; |
| 939 | let changed: Vec<String> = wanted | 939 | let changed: Vec<String> = wanted |
crates/forge-git/tests/integration/history.rsmodified+1 -1
| @@ -235,7 +235,7 @@ async fn last_commits_finds_newest_touch_per_child() { | |||
| 235 | assert_eq!(root["d"].oid, c5); | 235 | assert_eq!(root["d"].oid, c5); |
| 236 | assert_eq!(root["other.txt"].oid, c6); | 236 | assert_eq!(root["other.txt"].oid, c6); |
| 237 | 237 | ||
| 238 | - let short = last_commits(&f.git_dir, &c6, "d", &names, 1).await.unwrap(); | 238 | + let short = last_commits(&f.git_dir, &c6, "d", &names, 2).await.unwrap(); |
| 239 | assert_eq!(short.len(), 1); | 239 | assert_eq!(short.len(), 1); |
| 240 | assert_eq!(short["sub"].oid, c5); | 240 | assert_eq!(short["sub"].oid, c5); |
| 241 | } | 241 | } |
crates/forge-web-pages/src/pages/tree.rsmodified+1 -1
| @@ -40,7 +40,7 @@ pub const README_NAMES: [&str; 5] = [ | |||
| 40 | ]; | 40 | ]; |
| 41 | 41 | ||
| 42 | pub const MAX_BLOB_BYTES: usize = 1 << 20; | 42 | pub const MAX_BLOB_BYTES: usize = 1 << 20; |
| 43 | -const LAST_COMMIT_WALK: usize = 2000; | 43 | +const LAST_COMMIT_WALK: usize = 10_000; |
| 44 | const LAST_COMMIT_TIMEOUT: Duration = Duration::from_secs(3); | 44 | const LAST_COMMIT_TIMEOUT: Duration = Duration::from_secs(3); |
| 45 | 45 | ||
| 46 | path_param!(owner); | 46 | path_param!(owner); |