Skip to content

Commit fd48ae5

Browse files
authored
1 parent c342cba commit fd48ae5

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

bitbucket.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,14 @@ type RepositoryBranchCreationOptions struct {
232232
Target RepositoryBranchTarget `json:"target"`
233233
}
234234

235+
type RepositoryBranchDeleteOptions struct {
236+
Owner string `json:"owner"`
237+
RepoSlug string `json:"repo_slug"`
238+
RepoUUID string `json:"uuid"`
239+
RefName string `json:"name"`
240+
RefUUID string `json:uuid`
241+
}
242+
235243
type RepositoryBranchTarget struct {
236244
Hash string `json:"hash"`
237245
}

repository.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,21 @@ func (r *Repository) GetBranch(rbo *RepositoryBranchOptions) (*RepositoryBranch,
378378
return decodeRepositoryBranch(bodyString)
379379
}
380380

381+
// DeleteBranch https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/refs/branches/%7Bname%7D#delete
382+
func (r *Repository) DeleteBranch(rbo *RepositoryBranchDeleteOptions) error {
383+
repo := rbo.RepoSlug
384+
if rbo.RepoUUID != "" {
385+
repo = rbo.RepoUUID
386+
}
387+
ref := rbo.RefName
388+
if rbo.RefUUID != "" {
389+
ref = rbo.RefUUID
390+
}
391+
urlStr := r.c.requestUrl("/repositories/%s/%s/refs/branches/%s", rbo.Owner, repo, ref)
392+
_, err := r.c.execute("DELETE", urlStr, "")
393+
return err
394+
}
395+
381396
func (r *Repository) CreateBranch(rbo *RepositoryBranchCreationOptions) (*RepositoryBranch, error) {
382397
urlStr := r.c.requestUrl("/repositories/%s/%s/refs/branches", rbo.Owner, rbo.RepoSlug)
383398
data := r.buildBranchBody(rbo)

0 commit comments

Comments
 (0)