Skip to content

Commit d444f2e

Browse files
committed
fix(version): use file-existence check for duplicate branch detection in CreateBranch
1 parent 2b42bf6 commit d444f2e

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

internal/version/branch.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,12 @@ func CreateBranch(dir, name, fromHash string) error {
7878
}
7979

8080
refPath := refsDirName + "/" + headsDirName + "/" + name
81-
existing, err := readRef(dir, refPath)
82-
if err != nil {
83-
return err
84-
}
85-
if existing != "" {
81+
refFile := filepath.Join(dir, RepoDirName, refPath)
82+
if _, err := os.Stat(refFile); err == nil {
8683
return fmt.Errorf("branch %q already exists", name)
8784
}
8885

86+
var err error
8987
if fromHash == "" {
9088
fromHash, err = ReadHEAD(dir)
9189
if err != nil {

0 commit comments

Comments
 (0)