Skip to content

Commit 100c408

Browse files
[Prefix] Make get_addable_spec start search from HEAD of upstream repo (#219)
* [Prefix] Make `get_addable_spec` start search from HEAD of upstream repo Co-authored-by: Elliot Saba <staticfloat@gmail.com> * Update src/Prefix.jl Co-authored-by: Elliot Saba <staticfloat@gmail.com> Co-authored-by: Elliot Saba <staticfloat@gmail.com>
1 parent c1e2680 commit 100c408

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Prefix.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,14 @@ function get_addable_spec(name::AbstractString, version::VersionNumber;
477477

478478
LibGit2.with(LibGit2.GitRepo(dir)) do repo
479479
LibGit2.with(LibGit2.GitRevWalker(repo)) do walker
480-
LibGit2.push_head!(walker)
480+
# The repo is cached, so locally it may be checking out an outdated commit.
481+
# Start the search from HEAD of the tracking upstream repo.
482+
try
483+
LibGit2.push!(walker, LibGit2.GitHash(LibGit2.peel(LibGit2.GitCommit, LibGit2.upstream(LibGit2.head(repo)))))
484+
catch
485+
@warn("Could not walk from origin branch!")
486+
LibGit2.push_head!(walker)
487+
end
481488
# For each commit in the git repo, check to see if its treehash
482489
# matches the one we're looking for.
483490
for oid in walker

0 commit comments

Comments
 (0)