Skip to content
This repository has been archived by the owner on Feb 26, 2019. It is now read-only.

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

Closed
wants to merge 2 commits into from

Conversation

andrewstuart
Copy link

@andrewstuart andrewstuart commented Jul 22, 2016

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. 😄

@freeformz
Copy link

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
Copy link
Author

andrewstuart commented Jul 22, 2016

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.


for _, dep := range g.Deps {
c := exec.Command(args[0], args[1:]...)
c.Dir = getRoot(dep.root, dep.ImportPath)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be run for each dep or each repo?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants