Use branch form value as fallback for last build
The current version of the Drone CLI is still using the branch form value to filter the latest build information while the server is listening only for the ref form value. With this fix we are falling back to branch form value if it gets defined, formats it as a ref and hands it to the further functions.
This commit is contained in:
parent
b7737a4a89
commit
c34efc152a
2 changed files with 11 additions and 3 deletions
|
@ -11,7 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- endpoint to trigger new build for branch, by [@bradrydzewski](https://github.com/bradrydzewski). [#2679](https://github.com/drone/drone/issues/2679).
|
- endpoint to trigger new build for branch, by [@bradrydzewski](https://github.com/bradrydzewski). [#2679](https://github.com/drone/drone/issues/2679).
|
||||||
- endpoint to trigger new build for branch and sha, by [@bradrydzewski](https://github.com/bradrydzewski). [#2679](https://github.com/drone/drone/issues/2679).
|
- endpoint to trigger new build for branch and sha, by [@bradrydzewski](https://github.com/bradrydzewski). [#2679](https://github.com/drone/drone/issues/2679).
|
||||||
- DRONE_PROMETHEUS_ANONYMOUS_ACCESS configuration option, by [@janberktold](https://github.com/janberktold)
|
- DRONE_PROMETHEUS_ANONYMOUS_ACCESS configuration option, by [@janberktold](https://github.com/janberktold)
|
||||||
-
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- allow to filter last builds by branch, by [@tboerger](https://github.com/tboerger).
|
||||||
|
|
||||||
## [1.1.0] - 2019-04-23
|
## [1.1.0] - 2019-04-23
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@ func HandleLast(
|
||||||
namespace = chi.URLParam(r, "owner")
|
namespace = chi.URLParam(r, "owner")
|
||||||
name = chi.URLParam(r, "name")
|
name = chi.URLParam(r, "name")
|
||||||
ref = r.FormValue("ref")
|
ref = r.FormValue("ref")
|
||||||
|
branch = r.FormValue("branch")
|
||||||
)
|
)
|
||||||
repo, err := repos.FindName(r.Context(), namespace, name)
|
repo, err := repos.FindName(r.Context(), namespace, name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -45,6 +46,9 @@ func HandleLast(
|
||||||
if ref == "" {
|
if ref == "" {
|
||||||
ref = fmt.Sprintf("refs/heads/%s", repo.Branch)
|
ref = fmt.Sprintf("refs/heads/%s", repo.Branch)
|
||||||
}
|
}
|
||||||
|
if branch != "" {
|
||||||
|
ref = fmt.Sprintf("refs/heads/%s", branch)
|
||||||
|
}
|
||||||
build, err := builds.FindRef(r.Context(), repo.ID, ref)
|
build, err := builds.FindRef(r.Context(), repo.ID, ref)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
render.NotFound(w, err)
|
render.NotFound(w, err)
|
||||||
|
|
Loading…
Reference in a new issue