summaryrefslogtreecommitdiffstats
path: root/pkg/integration/components/shell.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2024-03-09 13:36:44 +1100
committerJesse Duffield <jessedduffield@gmail.com>2024-03-09 13:53:14 +1100
commit4a07e037016d90a62b3a99765a1f687909f0c748 (patch)
tree3e1ab3e14bcdf5e03e6d579dc98c60ea9c92e437 /pkg/integration/components/shell.go
parent44f553b6093c69d09718f617e0a7659c64f51015 (diff)
Local-ise remote branches when checking out by namecheckout-by-name
The idea here is that in the git CLI you will often want to checkout a remote branch like origin/blah by doing `git checkout blah`. That will automatically create a local branch named blah that tracks origin/blah. Previously in the suggestions view when checking out a branch by name, we would only show local branches and remote branches like origin/blah but wouldn't show blah as an option (assuming no local branch existed with that name). This meant users would checkout origin/blah and git would check out that branch as a detached head which is rarely what you actually want. Now we give them both options. The alternative approach we could have taken is to still show the branch as origin/blah but then ask if the user wants to check out the branch as detached or as a local branch tracking the remote branch. That approach is certainly more versatile, but it's also something you can do already by going to the remote branch directly via the remotes view. Admittedly, my approach involves less work.
Diffstat (limited to 'pkg/integration/components/shell.go')
-rw-r--r--pkg/integration/components/shell.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/pkg/integration/components/shell.go b/pkg/integration/components/shell.go
index 60c627918..60652b2ad 100644
--- a/pkg/integration/components/shell.go
+++ b/pkg/integration/components/shell.go
@@ -148,6 +148,10 @@ func (self *Shell) Checkout(name string) *Shell {
return self.RunCommand([]string{"git", "checkout", name})
}
+func (self *Shell) DeleteBranch(name string) *Shell {
+ return self.RunCommand([]string{"git", "branch", "-D", name})
+}
+
func (self *Shell) Merge(name string) *Shell {
return self.RunCommand([]string{"git", "merge", "--commit", "--no-ff", name})
}