Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Fixing an edge case in lockdiff where all the projects may be removed… #1972

Merged
merged 1 commit into from
Aug 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions gps/verify/lockdiff.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ func DiffLocks(l1, l2 gps.Lock) LockDelta {
Name: pr1,
}

// Edge case: If there are no lockedProjects on the RHS, they have most probably been removed from the lock file.
if len(p2) == 0 {
lpd.ProjectRemoved = true
diff.ProjectDeltas[pr1] = lpd
continue
}

for i2 := i2next; i2 < len(p2); i2++ {
lp2 := p2[i2]
pr2 := lp2.Ident().ProjectRoot
Expand Down
4 changes: 4 additions & 0 deletions gps/verify/lockdiff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ func TestLockDelta(t *testing.T) {
lt: dup.addII("other.org").rmII("baz.com/qux").addDumbProject("zebrafun.org").rmProject("foo.com/bar"),
delta: InputImportsChanged | ProjectRemoved | ProjectAdded,
},
"remove all projects and imports": {
lt: dup.rmII("baz.com/qux").rmII("foo.com/bar").rmProject("baz.com/qux").rmProject("foo.com/bar").rmProject("transitive.com/dependency"),
delta: InputImportsChanged | ProjectRemoved,
},
}

for name, fix := range tt {
Expand Down