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

Commit

Permalink
Fixing an edge case in lockdiff where all the projects may be removed…
Browse files Browse the repository at this point in the history
… from the lock file.
  • Loading branch information
tariq1890 committed Aug 2, 2018
1 parent 224a564 commit 327682c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
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

0 comments on commit 327682c

Please sign in to comment.