-
Notifications
You must be signed in to change notification settings - Fork 31
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
Adds the ability to clone only and not fork #62
Conversation
With this commit, the `clone` command is defaulting to cloning and forking only when the user has not push rights onto the repository. If the `--fork` flag is specified, it will fork and clone systematically.
Just noticed there'll be a bug here: In the case of a gh fork the fork will be called After testing, I believe this line can be removed. |
We have a problem... the gh client is quite smart (too smart) with its own logic. https://github.com/cli/cli/blob/trunk/pkg/cmd/pr/create/create.go#L532-L590 Basically the logic is:
Unfortunately that TUI is not programmable so bad luck. At this stage, and having looked at this for a little while now, Option A is prob the easiest one. One downside of using the TUI and the current gh behaviour is that the result forked repo created is named "forked", and the main one is still called "origin". So then it's on the user to basically handle this and push to origin or fork when needed. |
Bottom line of this is that it's a lot more complicated than previously anticipated. After discussing with Richard (@rnorth) a while back, the best course of action for now is to:
It adds some value, as most users will either have full access to the target repos or no access. We can spend some more time refining the logic behind when using clone and forking. For now the gh client logic is not enough as we don't know ahead of time which one will be needed, and programmatically create the fork. |
Adding a `--no-fork` flag and leave the default behaviour as "always fork". Changing the clone unit test to better represent the two scenarii.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Adds the ability to unilaterally choose to not fork. Implementation for a conditional 'fork only if needed' turned out to be much more complicated than originally thought, so this provides a solution for the subset of cases where a user has full access to all repos they wish to change, which is valuable.
This is a follow up of #49.
With this commit, the
clone
command is defaulting to cloning andforking only when the user has not push rights onto the repository.
If the
--fork
flag is specified, it will fork and clonesystematically.