Skip to content
This repository was archived by the owner on Oct 25, 2023. It is now read-only.

Commit a34343d

Browse files
committed
fix: properly update git packages specified by branch
closes #84
1 parent 8f50916 commit a34343d

File tree

6 files changed

+59
-7
lines changed

6 files changed

+59
-7
lines changed

Diff for: Lake/Config/Resolve.lean

+11-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,17 @@ namespace Lake
1919
def updateGitPkg (name : String)
2020
(repo : GitRepo) (rev? : Option String) : LogIO PUnit := do
2121
if let some rev := rev? then
22-
if (← repo.headRevision) == rev then return
23-
logInfo s!"{name}: updating {repo} to revision {rev}"
24-
unless ← repo.revisionExists rev do repo.fetch
25-
repo.checkoutDetach rev
22+
if (← repo.branchExists rev) then
23+
repo.fetch
24+
let rev ← repo.parseOriginRevision rev
25+
if (← repo.headRevision) == rev then return
26+
logInfo s!"{name}: updating {repo} to revision {rev}"
27+
repo.checkoutDetach rev
28+
else
29+
if (← repo.headRevision) == rev then return
30+
logInfo s!"{name}: updating {repo} to revision {rev}"
31+
unless ← repo.revisionExists rev do repo.fetch
32+
repo.checkoutDetach rev
2633
else
2734
logInfo s!"{name}: updating {repo}"
2835
repo.pull

Diff for: Lake/Util/Git.lean

+4-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ def exec (args : Array String) (wd : Option FilePath := none) : LogIO PUnit := d
3333

3434
def test (args : Array String) (wd : Option FilePath := none) : LogT BaseIO Bool :=
3535
let act : IO _ := do
36-
let child ← IO.Process.spawn {cmd := "git", args, cwd := wd}
36+
let child ← IO.Process.spawn {
37+
cmd := "git", args, cwd := wd,
38+
stdout := IO.Process.Stdio.null, stderr := IO.Process.Stdio.null
39+
}
3740
return (← child.wait) == 0
3841
act.catchExceptions fun _ => pure false
3942

Diff for: Makefile

+8-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ test: check-lake test-ci test-bootstrap test-bootstrapped
1212

1313
test-ci: test-tests test-examples
1414

15-
test-tests: test-49 test-50 test-62 test-75
15+
test-tests: test-49 test-50 test-62 test-75 test-84
1616

1717
test-examples: test-init test-hello test-io test-deps\
1818
test-git test-ffi test-targets test-precompile test-scripts
@@ -21,7 +21,7 @@ test-bootstrapped: test-boostrapped-hello
2121

2222
clean: clean-build clean-tests clean-examples
2323

24-
clean-tests: clean-62
24+
clean-tests: clean-62 clean-84
2525

2626
clean-examples: clean-init clean-hello clean-io clean-deps\
2727
clean-git clean-ffi clean-targets clean-precompile clean-bootstrap
@@ -137,3 +137,9 @@ clean-62:
137137

138138
test-75:
139139
cd test/75 && ./test.sh
140+
141+
clean-84:
142+
cd test/84 && ./clean.sh
143+
144+
test-84:
145+
cd test/84 && ./test.sh

Diff for: test/84/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/a
2+
/b

Diff for: test/84/clean.sh

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
rm -rf a
2+
rm -rf b

Diff for: test/84/test.sh

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
set -exo pipefail
3+
4+
LAKE=${LAKE:-../../build/bin/lake}
5+
6+
./clean.sh
7+
8+
$LAKE new a
9+
pushd a
10+
git add .
11+
git commit -am 'first commit in a'
12+
popd
13+
14+
$LAKE new b
15+
pushd b
16+
cat >>lakefile.lean <<EOF
17+
require a from git "../a" @ "master"
18+
EOF
19+
../$LAKE update
20+
git add .
21+
git commit -am 'first commit in b'
22+
popd
23+
24+
pushd a
25+
echo def hello2 := 42 >>A.lean
26+
git commit -am 'second commit in a'
27+
popd
28+
29+
pushd b
30+
../$LAKE update
31+
git diff | grep -m1 manifest
32+
popd

0 commit comments

Comments
 (0)