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

Manual build trigger button (#45) resolved #80

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions cmd/ginvalid/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func registerRoutes(r *mux.Router) {
r.HandleFunc("/", web.Root)
r.HandleFunc("/pubvalidate", web.PubValidateGet).Methods("GET")
r.HandleFunc("/pubvalidate", web.PubValidatePost).Methods("POST")
r.HandleFunc("/privalidate", web.PriValidatePost).Methods("POST")
r.HandleFunc("/validate/{validator}/{user}/{repo}", web.Validate).Methods("POST")
r.HandleFunc("/status/{validator}/{user}/{repo}", web.Status).Methods("GET")
r.HandleFunc("/results/{validator}/{user}/{repo}", web.Results).Methods("GET")
Expand Down
5 changes: 5 additions & 0 deletions internal/resources/templates/repolist.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ const RepoPage = `
{{range $hookname, $hook := .Hooks}}
<tr>
<td class="name text bold four wide"><a href="">{{$hookname | ToUpper}}</a></td>
<td class="name four wide"><form action="/privalidate" method="post">
<input type="hidden" name="validator" value="{{$hookname}}" />
<input type="hidden" name="repopath" value="{{$.FullName}}" />
<input type="submit" value="Run validation" />
</form></td>
{{if eq $hook.State 0}}
<td class="name nine wide"><a href="/results/{{$hookname | ToLower}}/{{$.FullName}}">RESULTS</a></td>
<td class="name three wide"><a href="/repos/{{$.FullName}}/{{$hook.ID}}/disable">DEACTIVATE</a></td>
Expand Down
13 changes: 12 additions & 1 deletion internal/web/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,17 @@ func PubValidateGet(w http.ResponseWriter, r *http.Request) {
// PubValidatePost parses the POST data from the root form and calls the
// validator using the built-in ServiceWaiter.
func PubValidatePost(w http.ResponseWriter, r *http.Request) {
validatePost(w, r, true)
}

// PriValidatePost parses the POST data from the root form and calls the
// validator using the built-in ServiceWaiter. Private repositories are
// allowed here
func PriValidatePost(w http.ResponseWriter, r *http.Request) {
validatePost(w, r, false)
}

func validatePost(w http.ResponseWriter, r *http.Request, private bool) {
srvcfg := config.Read()
ginuser := srvcfg.Settings.GINUser

Expand Down Expand Up @@ -665,7 +676,7 @@ func PubValidatePost(w http.ResponseWriter, r *http.Request) {
fail(w, http.StatusNotFound, err.Error())
return
}
if repoinfo.Private {
if repoinfo.Private && private {
// We (the built in ServiceWaiter) have access, but the repository is
// marked private. This can happen if an owner of the private
// repository adds the user as a collaborator to the repository. We
Expand Down