Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mr checkout: specify the tracking remote #774

Closed
claytonrcarter opened this issue Jan 3, 2022 · 5 comments
Closed

mr checkout: specify the tracking remote #774

claytonrcarter opened this issue Jan 3, 2022 · 5 comments
Assignees

Comments

@claytonrcarter
Copy link
Collaborator

I don't use the "1 remote/author" workflow at work; instead we all push branches to a single, shared origin where only some of us have permission to merge to main. As written, mr checkout -t <id> will create/update a remote named after the MR author. In my case, this ends up w/ 2 remotes both pointing to the same URL, which doesn't feel helpful to me. I have hacked around this locally, but before I go making it pretty I'd like to know if anyone else wants this. 😛

My existing hack is just an add'l flag --track-default-remote that tells mr checkout use targetRemote instead of creating a new remote based on mr.Author.Username.

Any interest?

BTW I looked into some way to support something like this:

  • --tracking-remote not specified on command line: use mr.Author.Username (current behavior)
  • --tracking-remote specified but w/ no value: use default remote
  • --tracking-remote=<remoteName>: use remote named remoteName

I got stuck on this b/c I couldn't (quickly) figure out how to coax pflags into working w/ some sort of flag that has different values if it's not specified, vs if it's passed but w/o a value vs w/ a value. (Or even if such a thing is possible.) I eventually just settled for the default remote being fine for me. 😄

@krobelus
Copy link
Contributor

krobelus commented Jan 3, 2022 via email

@bmeneg
Copy link
Collaborator

bmeneg commented Jan 5, 2022

It seems indeed useful and I would like to test it myself actually :)
Even though I don't use this workflow I already saw other places/friends using it.

  • --tracking-remote not specified on command line: use mr.Author.Username (current behavior)

  • --tracking-remote specified but w/ no value: use default remote

  • --tracking-remote=<remoteName>: use remote named remoteName

Yeah, it would require to specify two flags with the same name, being one a bool and the other string, otherwise the second bullet will eat the following string in the CLI as the flag value (even if the next string starts with --, which would indicate another flag). But it's not possible with pflag/Cobra 😢 .

I didn't look into the UI, but maybe we can use the remote specified in git config remote.pushDefault.

Using the git options here is indeed a valid option, maybe "use remote.pushDefault if set, targetRemote otherwise"?

@fmuellner
Copy link
Contributor

As written, mr checkout -t <id> will create/update a remote named after the MR author. In my case, this ends up w/ 2 remotes both pointing to the same URL

Wouldn't it be better to detect that the MR remote matches the default remote and pick that automatically? The proposed CLI flag sounds like a workaround for something that shouldn't be done in the first place.

@bmeneg
Copy link
Collaborator

bmeneg commented Feb 4, 2022

@fmuellner That's actually a pretty good point.
The checkout should track the remote from where that mr is coming from and we have this information available.

@bmeneg
Copy link
Collaborator

bmeneg commented Feb 4, 2022

@claytonrcarter @fmuellner please take a look at the PR #786 .
@claytonrcarter if possible, could you test it in your local env and workflow?

@bmeneg bmeneg self-assigned this Feb 8, 2022
@bmeneg bmeneg closed this as completed Feb 8, 2022
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

No branches or pull requests

4 participants