Skip to content

Fetch upstream remote after adding it#752

Merged
mislav merged 1 commit intocli:masterfrom
lumaxis:feature/fetch-upstream-after-adding
Apr 6, 2020
Merged

Fetch upstream remote after adding it#752
mislav merged 1 commit intocli:masterfrom
lumaxis:feature/fetch-upstream-after-adding

Conversation

@lumaxis
Copy link
Copy Markdown
Contributor

@lumaxis lumaxis commented Apr 5, 2020

This is a naive proposal for fixing #731

cloneDir := path.Base(strings.TrimSuffix(cloneURL, ".git"))

cloneCmd := git.GitCommand("-C", cloneDir, "remote", "add", "upstream", upstreamURL)
cloneCmd := git.GitCommand("-C", cloneDir, "remote", "add", "-f", "upstream", upstreamURL)
Copy link
Copy Markdown
Contributor Author

@lumaxis lumaxis Apr 5, 2020

Choose a reason for hiding this comment

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

I was wondering if it might be possible – and preferred – to instead repurpose and use an adjusted version of AddRemote:

cli/git/remote.go

Lines 74 to 76 in e10ccef

// AddRemote adds a new git remote and auto-fetches objects from it
func AddRemote(name, u string) (*Remote, error) {
addCmd := exec.Command("git", "remote", "add", "-f", name, u)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That is generally a good idea, but in this instance it would require us to change the signature of AddRemote to accept an additional (optional) directory parameter.

Since making that change isn't a marked improvement over your current approach, in my book, I would just say— this looks good, and leave it as is! Thank you so much for taking a stab at a fix 🎉

@lumaxis lumaxis marked this pull request as ready for review April 5, 2020 18:59
cloneDir := path.Base(strings.TrimSuffix(cloneURL, ".git"))

cloneCmd := git.GitCommand("-C", cloneDir, "remote", "add", "upstream", upstreamURL)
cloneCmd := git.GitCommand("-C", cloneDir, "remote", "add", "-f", "upstream", upstreamURL)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That is generally a good idea, but in this instance it would require us to change the signature of AddRemote to accept an additional (optional) directory parameter.

Since making that change isn't a marked improvement over your current approach, in my book, I would just say— this looks good, and leave it as is! Thank you so much for taking a stab at a fix 🎉

@mislav mislav merged commit e878cdf into cli:master Apr 6, 2020
@lumaxis lumaxis deleted the feature/fetch-upstream-after-adding branch April 6, 2020 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants