Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed PUT /api/project/123/branch endpoint #49

Merged
merged 2 commits into from
May 10, 2022
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ This project tries to follow [SemVer 2.0.0](https://semver.org/).
field of `wharfapi.Client`. Now defaults to `80` for `HTTP` URLs, and `443`
for `HTTPS`. (#48)

- Fixed `UpdateProjectBranchList` using the wrong HTTP request & response
bodies. (#49)

## v2.2.0 (2022-05-02)

- Added methods for execution engine: (#45)
Expand Down
17 changes: 14 additions & 3 deletions pkg/wharfapi/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,21 @@ func (c *Client) UpdateProjectBranchList(projectID uint, branches []request.Bran
if err := c.validateEndpointVersion(5, 0, 0); err != nil {
return nil, err
}
var newBranches []response.Branch
body := request.BranchListUpdate{
Branches: make([]request.BranchUpdate, 0, len(branches)),
}
for _, b := range branches {
body.Branches = append(body.Branches, request.BranchUpdate{
Name: b.Name,
})
if b.Default {
body.DefaultBranch = b.Name
}
}
var response response.BranchList
path := fmt.Sprintf("/api/project/%d/branch", projectID)
err := c.putJSONUnmarshal(path, nil, branches, &newBranches)
return newBranches, err
err := c.putJSONUnmarshal(path, nil, body, &response)
return response.Branches, err
}

// GetProjectBranchList gets the branches for a project by invoking the HTTP
Expand Down