Skip to content

Commit cddcfbf

Browse files
author
Tobias Meinhardt
committed
Fix prevention of creating branch from wrong source branch
1 parent 432aa70 commit cddcfbf

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

git/native_adapter.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,17 @@ func (a nativeGitAdapter) Push(setUpstream bool) error {
112112

113113
// Create a new branch
114114
func (a nativeGitAdapter) Create(b glow.Branch) error {
115-
if !b.CreationIsAllowedFrom(b.BranchName()) {
115+
sourceBranch, err := a.CurrentBranch()
116+
if err != nil {
117+
return err
118+
}
119+
if !b.CreationIsAllowedFrom(sourceBranch.BranchName()) {
116120
return errors.New("creation not allowed from this branch")
117121
}
118122
cmd := a.exec.Command(fmt.Sprintf("git branch %s", b.ShortBranchName()))
119123
var stderr bytes.Buffer
120124
cmd.Stderr = &stderr
121-
err := cmd.Run()
125+
err = cmd.Run()
122126
return errors.Wrap(err, stderr.String())
123127
}
124128

0 commit comments

Comments
 (0)