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

Add support for refs to BuildLast #59

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 5 additions & 1 deletion drone/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,11 @@ func (c *client) BuildLast(owner, name, branch string) (*Build, error) {
out := new(Build)
uri := fmt.Sprintf(pathBuild, c.addr, owner, name, "latest")
if branch != "" {
uri += "?branch=" + branch
if strings.HasPrefix(branch, "refs/") {
uri += "?ref=" + branch
Copy link
Contributor

@eoinmcafee00 eoinmcafee00 Feb 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be cleaner to create a new function BuildLastRef and call the parameter ref. This change still uses "branch" which isn't as clear to read.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also with this change the comment is no longer correct.

} else {
uri += "?branch=" + branch
}
}
err := c.get(uri, out)
return out, err
Expand Down