-
Notifications
You must be signed in to change notification settings - Fork 896
feat: add --branch option to clone or checkout different dotfiles branch #8331
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
Conversation
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.
Nice feature! Might've misunderstood some parts but left a few questions.
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.
Once the stdout thing is fixed, I see no blockers. LGTM and thanks for answering my questions! 👍🏻
if err != nil { | ||
// Do not block on this error, just log it and continue | ||
_, _ = fmt.Fprintln(inv.Stdout, | ||
cliui.DefaultStyles.Error.Render(fmt.Sprintf("Failed to use branch %q (%s), continuing...", err.Error(), gitbranch))) |
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.
Would it make sense to use a non-zero exit code if this happens? Otherwise the user might expect one thing but receive another due to the silent failure. (Not saying we can't continue from here, but set a branchFailed = true
and then exit 1 at the end.
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.
That is an idea. I am not sure, I was copying the existing behavior.
See this:
Line 142 in e1d7dc3
if !dotfilesExists { |
If the git pull --ff-only
fails then we continue, even though we are now operating in a stale dotfiles. I was maintaining that behavior of continuing.
If we decide to exit code 1, we should go back and also change the previous behavior.
If
--branch
is specified, theclone
will clone that branch.The code will always do a
git branch --show-current
and checkout the specified branch if the flag is provided.Fixes: #8282
How it works
--branch
is specified, git clone usesgit clone --branch <xxx> ...
git pull
(git checkout
might fail before a pull.--branch
existsgit checkout <branch>
git pull --ff-only
(The earlier pull was on the wrong branch)