Skip to content

Commit

Permalink
disallow branch names that start with -
Browse files Browse the repository at this point in the history
  • Loading branch information
James Cor committed Jun 21, 2024
1 parent 27cd0ef commit a7f6d53
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions go/libraries/doltcore/ref/branchname.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
// InvalidBranchNameRegex is a list of patterns forbidden in a branch name.
// For additional constraints on ref names, see datas.ValidateDatasetId
var InvalidBranchNameRegex = regexp.MustCompile(strings.Join([]string{
// An exact name of "", "HEAD" or "-"
`\A\z`, `\AHEAD\z`, `\A-\z`,
// An exact name of "", "HEAD" or starts with "-"
`\A\z`, `\AHEAD\z`, `^-.{0,}`,
// A name that looks exactly like a commit id
`\A[0-9a-v]{32}\z`,
// Any empty component; that is, starting or ending with "/" or any appearance of "//"
Expand Down
1 change: 1 addition & 0 deletions go/libraries/doltcore/ref/branchname_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,5 @@ func TestBranchName(t *testing.T) {
assert.False(t, IsValidBranchName("user.lock/working/mybranch"))
assert.False(t, IsValidBranchName("HEAD"))
assert.False(t, IsValidBranchName("-"))
assert.False(t, IsValidBranchName("-test"))
}

0 comments on commit a7f6d53

Please sign in to comment.