fix: date fixes; go middleware refactors; regex fixes; etc (#368)

fix: format of date when MR was closed or merged (#367)
refactor: Add Payload Validators + Middleware In Go Code (#366)
fix: Add better checks for leaving comments (#369)
fix: regex support for http credentials embedded in remote url (#372)
fix: Comment on single line selects two lines (#371)

This is a #PATCH release.
This commit is contained in:
Harrison (Harry) Cramer
2024-09-14 16:53:00 -04:00
committed by GitHub
parent f1faf603b0
commit 22bfd0c83e
61 changed files with 1527 additions and 1284 deletions

View File

@@ -22,14 +22,7 @@ type infoService struct {
}
/* infoHandler fetches infomation about the current git project. The data returned here is used in many other API calls */
func (a infoService) handler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
if r.Method != http.MethodGet {
w.Header().Set("Access-Control-Allow-Methods", http.MethodGet)
handleError(w, InvalidRequestError{}, "Expected GET", http.StatusMethodNotAllowed)
return
}
func (a infoService) ServeHTTP(w http.ResponseWriter, r *http.Request) {
mr, res, err := a.client.GetMergeRequest(a.projectInfo.ProjectId, a.projectInfo.MergeId, &gitlab.GetMergeRequestsOptions{})
if err != nil {
handleError(w, err, "Could not get project info", http.StatusInternalServerError)
@@ -37,17 +30,14 @@ func (a infoService) handler(w http.ResponseWriter, r *http.Request) {
}
if res.StatusCode >= 300 {
handleError(w, GenericError{endpoint: "/mr/info"}, "Could not get project info", res.StatusCode)
handleError(w, GenericError{r.URL.Path}, "Could not get project info", res.StatusCode)
return
}
w.WriteHeader(http.StatusOK)
response := InfoResponse{
SuccessResponse: SuccessResponse{
Message: "Merge requests retrieved",
Status: http.StatusOK,
},
Info: mr,
SuccessResponse: SuccessResponse{Message: "Merge requests retrieved"},
Info: mr,
}
err = json.NewEncoder(w).Encode(response)