Skip to content

Commit

Permalink
feat: improve cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Mar 8, 2024
1 parent 64985b9 commit 3737668
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 0 additions & 2 deletions fixtures_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ go 1.15
// test
require (
// test
github.com/google/go-github v17.0.0+incompatible
github.com/google/go-querystring v1.0.0 // indirect
github.com/google/go-github/v20 v20.0.0
)
Expand Down
1 change: 1 addition & 0 deletions motoko_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func Test_updateCmd(t *testing.T) {
}

if string(mod) != test.expected.mod {
t.Log(string(mod))
t.Errorf("got diffs:\n%s", quickDiff(string(mod), test.expected.mod))
}
})
Expand Down
13 changes: 13 additions & 0 deletions upgrader.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,24 @@ func updateModFile(dir, lib, full, major string) error {
return err
}

for _, require := range file.Require {
if !strings.HasPrefix(require.Mod.Path, lib) || require.Indirect {
continue
}

err = file.DropRequire(require.Mod.Path)
if err != nil {
return err
}
}

err = file.AddRequire(path.Join(lib, major), full)
if err != nil {
return err
}

file.Cleanup()

data, err := file.Format()
if err != nil {
return err
Expand Down

0 comments on commit 3737668

Please sign in to comment.