mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2026-03-18 07:56:09 +01:00
removed builds table since not being used in the near term
This commit is contained in:
@@ -79,6 +79,41 @@ func (h *CommitHandler) GetCommit(w http.ResponseWriter, r *http.Request) error
|
||||
return json.NewEncoder(w).Encode(commit)
|
||||
}
|
||||
|
||||
// GetCommitOutput gets the commit's stdout.
|
||||
// GET /v1/repos/{host}/{owner}/{name}/branches/{branch}/commits/{commit}/console
|
||||
func (h *CommitHandler) GetCommitOutput(w http.ResponseWriter, r *http.Request) error {
|
||||
var host, owner, name = parseRepo(r)
|
||||
var branch = r.FormValue(":branch")
|
||||
var sha = r.FormValue(":commit")
|
||||
|
||||
// get the user form the session.
|
||||
user := h.sess.User(r)
|
||||
|
||||
// get the repository from the database.
|
||||
repo, err := h.repos.FindName(host, owner, name)
|
||||
if err != nil {
|
||||
return notFound{err}
|
||||
}
|
||||
|
||||
// user must have read access to the repository.
|
||||
if ok, _ := h.perms.Read(user, repo); !ok {
|
||||
return notFound{err}
|
||||
}
|
||||
|
||||
commit, err := h.commits.FindSha(repo.ID, branch, sha)
|
||||
if err != nil {
|
||||
return notFound{err}
|
||||
}
|
||||
|
||||
output, err := h.commits.FindOutput(commit.ID)
|
||||
if err != nil {
|
||||
return notFound{err}
|
||||
}
|
||||
|
||||
w.Write(output)
|
||||
return nil
|
||||
}
|
||||
|
||||
// PostCommit gets the commit for the repository and schedules to re-build.
|
||||
// GET /v1/repos/{host}/{owner}/{name}/branches/{branch}/commits/{commit}
|
||||
func (h *CommitHandler) PostCommit(w http.ResponseWriter, r *http.Request) error {
|
||||
@@ -86,6 +121,7 @@ func (h *CommitHandler) PostCommit(w http.ResponseWriter, r *http.Request) error
|
||||
}
|
||||
|
||||
func (h *CommitHandler) Register(r *pat.Router) {
|
||||
r.Get("/v1/repos/{host}/{owner}/{name}/branches/{branch}/commits/{commit}/console", errorHandler(h.GetCommitOutput))
|
||||
r.Get("/v1/repos/{host}/{owner}/{name}/branches/{branch}/commits/{commit}", errorHandler(h.GetCommit))
|
||||
r.Post("/v1/repos/{host}/{owner}/{name}/branches/{branch}/commits/{commit}", errorHandler(h.PostCommit)).Queries("action", "rebuild")
|
||||
r.Get("/v1/repos/{host}/{owner}/{name}/branches/{branch}/commits", errorHandler(h.GetFeed))
|
||||
|
||||
Reference in New Issue
Block a user