-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Remote delete #982
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
Remote delete #982
Changes from all commits
a303dab
904c541
80bdd1e
ae70a81
479707d
a8fa9a2
368aacb
858cd70
e643765
ff97fc1
9113092
9c88cd6
9c48e2d
9a290d7
9c075ab
b27df34
909e177
6c5c7cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -209,6 +209,12 @@ func DeleteLocalBranch(branch string) error { | |
return err | ||
} | ||
|
||
func HasLocalBranch(branch string) bool { | ||
configCmd := GitCommand("rev-parse", "--verify", "refs/heads/"+branch) | ||
_, err := run.PrepareCmd(configCmd).Output() | ||
return err == nil | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I made the assumption here that any error means the branch doesn't exist. I figured that will be more stable in the future than doing a string match on the error message. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a fair assumption! |
||
} | ||
|
||
func CheckoutBranch(branch string) error { | ||
configCmd := GitCommand("checkout", branch) | ||
err := run.PrepareCmd(configCmd).Run() | ||
|
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.
Tip: to run a command without being interested in its output, you can use
Run()
instead ofOutput()
.