Skip to content

Commit

Permalink
Document tag/branch lookup in branch/tag creation (#8196)
Browse files Browse the repository at this point in the history
* Add comment to describe tag lookup

* Add comment to describe branch lookup
  • Loading branch information
itaiad200 authored Sep 19, 2024
1 parent 7d52a45 commit b75038e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/catalog/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,7 @@ func (c *Catalog) CreateBranch(ctx context.Context, repositoryID string, branch
return nil, err
}

// look for a tag with the same name to avoid reference conflict
if _, err := c.Store.GetTag(ctx, repository, graveler.TagID(branchID)); err == nil {
return nil, fmt.Errorf("tag ID %s: %w", branchID, graveler.ErrConflictFound)
} else if !errors.Is(err, graveler.ErrNotFound) {
Expand Down Expand Up @@ -859,6 +860,8 @@ func (c *Catalog) CreateTag(ctx context.Context, repositoryID string, tagID stri
if err != nil {
return "", err
}

// look for a branch with the same name to avoid reference conflict
if _, err := c.Store.GetBranch(ctx, repository, graveler.BranchID(tagID)); err == nil {
return "", fmt.Errorf("branch name %s: %w", tagID, graveler.ErrConflictFound)
} else if !errors.Is(err, graveler.ErrNotFound) {
Expand Down

0 comments on commit b75038e

Please sign in to comment.