From 4b4d078377029b18b9a965f4a8546645531f5b18 Mon Sep 17 00:00:00 2001 From: qwerty287 <80460567+qwerty287@users.noreply.github.com> Date: Fri, 7 Apr 2023 18:09:17 +0200 Subject: [PATCH] Fix Bitbucket Server branches (#1698) Closes #1695 --- server/forge/bitbucketserver/internal/client.go | 6 ++---- server/forge/bitbucketserver/internal/types.go | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/server/forge/bitbucketserver/internal/client.go b/server/forge/bitbucketserver/internal/client.go index 256ac4bb9..51af542b3 100644 --- a/server/forge/bitbucketserver/internal/client.go +++ b/server/forge/bitbucketserver/internal/client.go @@ -43,7 +43,7 @@ const ( pathHookEnabled = "%s/rest/api/1.0/projects/%s/repos/%s/settings/hooks/%s/enabled" pathHookSettings = "%s/rest/api/1.0/projects/%s/repos/%s/settings/hooks/%s/settings" pathStatus = "%s/rest/build-status/1.0/commits/%s" - pathBranches = "%s/2.0/repositories/%s/%s/refs/branches" + pathBranches = "%s/rest/api/1.0/projects/%s/repos/%s/branches" ) type Client struct { @@ -326,12 +326,10 @@ func (c *Client) paginatedRepos(start int) ([]*Repo, error) { func (c *Client) ListBranches(owner, name string) ([]*Branch, error) { uri := fmt.Sprintf(pathBranches, c.base, owner, name) response, err := c.doGet(uri) - if response != nil { - defer response.Body.Close() - } if err != nil { return nil, err } + defer response.Body.Close() out := new(BranchResp) err = json.NewDecoder(response.Body).Decode(&out) return out.Values, err diff --git a/server/forge/bitbucketserver/internal/types.go b/server/forge/bitbucketserver/internal/types.go index d516c1065..d320e41ae 100644 --- a/server/forge/bitbucketserver/internal/types.go +++ b/server/forge/bitbucketserver/internal/types.go @@ -211,5 +211,5 @@ type BranchResp struct { } type Branch struct { - Name string `json:"name"` + Name string `json:"displayId"` }