tools / godep

dependency tool for go
http://godoc.org/github.com/tools/godep
BSD 3-Clause "New" or "Revised" License
5.54k stars 455 forks source link

Add foreach command to run a shell command in each dependency's directory #499

Closed andrewstuart closed 7 years ago

andrewstuart commented 8 years ago

I think this gives a very simple solution to #453 of simply running godep foreach git checkout master to fix any inconsistencies caused by godep restore. I'm sure it could be useful in other ways as well, and matches up well with the git submodule foreach paradigm.

I'm sure there are other enhancements that could be made to this, so I'd be glad to go through the work to get it up to the necessary quality for inclusion. Let me know what I can do. :smile:

freeformz commented 8 years ago

Blinly checking out master isn't a good thing, but probably works in the 90% case. I'd argue that the appropriate place to fix this is to have go get determine the remote head and check that out when not already on that branch when doing a go get -u. godep already has logic to do that because it needs to check out the correct default head when updating to ensure the correct sha is present.

Also my goal, although I don't know if I'll ever get to it, is to remove the need to ever godep restore.

Thoughts?

andrewstuart commented 8 years ago

Yeah, it'd definitely be nice to not need to run godep restore, but I still think a generic foreach command has the potential to be useful for one-offs and scripts, much as it is with git submodule foreach.

I think it's just a nice side-effect that for now it does help the process of upgrading old Godeps/_workspace environments using godep restore; godep save; godep foreach git checkout master.