Skip to content

Commit

Permalink
Only replace with a go_mod_download if the path is different in the r…
Browse files Browse the repository at this point in the history
…eplace directive (please-build#97)

* Only replace with a go_mod_download if the path is different in the
replace directive

---------

Co-authored-by: rgodden <rgodden@thoughtmachine.net>
  • Loading branch information
goddenrich and goddenrich authored Feb 1, 2024
1 parent d732d1d commit d0117a7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
8 changes: 7 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Version 1.5.1
------------
* Sync: if we encounter a replace directive where the old path and new
path are the same don't delete the target as we can just update the
version.

Version 1.5.0
------------
* Migrate: Avoid duplicating `go_repo()` targets when migrating a module where
Expand Down Expand Up @@ -78,4 +84,4 @@ Version 0.2.0

Version 0.1.0
------------
* Initial release
* Initial release
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.0
1.5.1
5 changes: 4 additions & 1 deletion sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,11 @@ func (s *Sync) syncModFile(conf *config.Config, file *build.File, exitingRules m
var replace *modfile.Replace
for _, r := range f.Replace {
if r.Old.Path == req.Mod.Path {
reqVersion = r.New.Version
if r.New.Path == req.Mod.Path { // we are just replacing version so don't need a replace
continue
}
replace = r
reqVersion = replace.New.Version
}
}

Expand Down

0 comments on commit d0117a7

Please sign in to comment.