mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-10-04 01:12:12 +00:00
always specify a branch when rebuilding
This commit is contained in:
parent
fbdb330d5c
commit
ff98d74731
2 changed files with 8 additions and 4 deletions
|
@ -121,9 +121,13 @@ func (h *CommitRebuildHandler) CommitRebuild(w http.ResponseWriter, r *http.Requ
|
||||||
hash := r.FormValue(":commit")
|
hash := r.FormValue(":commit")
|
||||||
labl := r.FormValue(":label")
|
labl := r.FormValue(":label")
|
||||||
host := r.FormValue(":host")
|
host := r.FormValue(":host")
|
||||||
|
branch := r.FormValue("branch")
|
||||||
|
if branch == "" {
|
||||||
|
branch = "master"
|
||||||
|
}
|
||||||
|
|
||||||
// get the commit from the database
|
// get the commit from the database
|
||||||
commit, err := database.GetCommitHash(hash, repo.ID)
|
commit, err := database.GetCommitBranchHash(branch, hash, repo.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -157,9 +161,9 @@ func (h *CommitRebuildHandler) CommitRebuild(w http.ResponseWriter, r *http.Requ
|
||||||
h.queue.Add(&queue.BuildTask{Repo: repo, Commit: commit, Build: build})
|
h.queue.Add(&queue.BuildTask{Repo: repo, Commit: commit, Build: build})
|
||||||
|
|
||||||
if labl != "" {
|
if labl != "" {
|
||||||
http.Redirect(w, r, fmt.Sprintf("/%s/%s/%s/commit/%s/build/%s", host, repo.Owner, repo.Name, hash, labl), http.StatusSeeOther)
|
http.Redirect(w, r, fmt.Sprintf("/%s/%s/%s/commit/%s/build/%s?branch=%s", host, repo.Owner, repo.Name, hash, labl, branch), http.StatusSeeOther)
|
||||||
} else {
|
} else {
|
||||||
http.Redirect(w, r, fmt.Sprintf("/%s/%s/%s/commit/%s", host, repo.Owner, repo.Name, hash), http.StatusSeeOther)
|
http.Redirect(w, r, fmt.Sprintf("/%s/%s/%s/commit/%s?branch=%s", host, repo.Owner, repo.Name, hash, branch), http.StatusSeeOther)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
{{ if .IsAdmin }}
|
{{ if .IsAdmin }}
|
||||||
{{ if not .Build.IsRunning }}
|
{{ if not .Build.IsRunning }}
|
||||||
<form action="/{{.Repo.Slug}}/commit/{{.Commit.Hash}}/rebuild"
|
<form action="/{{.Repo.Slug}}/commit/{{.Commit.Hash}}/rebuild?branch={{ .Commit.Branch }}"
|
||||||
method="POST">
|
method="POST">
|
||||||
<input class="btn btn-default" type="submit" value="Rebuild"/>
|
<input class="btn btn-default" type="submit" value="Rebuild"/>
|
||||||
</form>
|
</form>
|
||||||
|
|
Loading…
Reference in a new issue