Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions bitbucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,14 @@ type RepositoryBranchCreationOptions struct {
Target RepositoryBranchTarget `json:"target"`
}

type RepositoryBranchDeleteOptions struct {
Owner string `json:"owner"`
RepoSlug string `json:"repo_slug"`
RepoUUID string `json:"uuid"`
RefName string `json:"name"`
RefUUID string `json:uuid`
}

type RepositoryBranchTarget struct {
Hash string `json:"hash"`
}
Expand Down
15 changes: 15 additions & 0 deletions repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,21 @@ func (r *Repository) GetBranch(rbo *RepositoryBranchOptions) (*RepositoryBranch,
return decodeRepositoryBranch(bodyString)
}

// DeleteBranch https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/refs/branches/%7Bname%7D#delete
func (r *Repository) DeleteBranch(rbo *RepositoryBranchDeleteOptions) error {
repo := rbo.RepoSlug
if rbo.RepoUUID != "" {
repo = rbo.RepoUUID
}
ref := rbo.RefName
if rbo.RefUUID != "" {
ref = rbo.RefUUID
}
urlStr := r.c.requestUrl("/repositories/%s/%s/refs/branches/%s", rbo.Owner, repo, ref)
_, err := r.c.execute("DELETE", urlStr, "")
return err
}

func (r *Repository) CreateBranch(rbo *RepositoryBranchCreationOptions) (*RepositoryBranch, error) {
urlStr := r.c.requestUrl("/repositories/%s/%s/refs/branches", rbo.Owner, rbo.RepoSlug)
data := r.buildBranchBody(rbo)
Expand Down