TODO: add logic
(ctx *gin.Context)
| 111 | |
| 112 | // TODO: add logic |
| 113 | func (h *InternalHandler) PostReceive(ctx *gin.Context) { |
| 114 | var req types.PostReceiveReq |
| 115 | if err := ctx.ShouldBind(&req); err != nil { |
| 116 | slog.Error("Bad request format", "error", err) |
| 117 | httpbase.BadRequest(ctx, err.Error()) |
| 118 | return |
| 119 | } |
| 120 | strs := strings.Split(req.Changes, " ") |
| 121 | // the format of originalRef is refs/heads/main |
| 122 | originalRef := strings.ReplaceAll(strs[2], "\n", "") |
| 123 | ref := strings.Split(strs[2], "/")[2] |
| 124 | // the format of ref is main |
| 125 | ref = strings.ReplaceAll(ref, "\n", "") |
| 126 | paths := strings.Split(req.GlRepository, "/") |
| 127 | diffReq := types.GetDiffBetweenTwoCommitsReq{ |
| 128 | LeftCommitId: strs[0], |
| 129 | RightCommitId: strs[1], |
| 130 | Namespace: paths[1], |
| 131 | Name: paths[2], |
| 132 | Ref: ref, |
| 133 | RepoType: types.RepositoryType(strings.TrimSuffix(paths[0], "s")), |
| 134 | } |
| 135 | callback, err := h.c.GetCommitDiff(ctx, diffReq) |
| 136 | if err != nil { |
| 137 | slog.Error("post receive: failed to get commit diff", slog.Any("error", err)) |
| 138 | httpbase.ServerError(ctx, err) |
| 139 | return |
| 140 | } |
| 141 | callback.Ref = originalRef |
| 142 | err = h.cbc.HandlePush(ctx, callback) |
| 143 | if err != nil { |
| 144 | slog.Error("failed to handle git push callback", slog.Any("error", err)) |
| 145 | httpbase.ServerError(ctx, err) |
| 146 | return |
| 147 | } |
| 148 | |
| 149 | ctx.PureJSON(http.StatusOK, gin.H{ |
| 150 | "reference_counter_decreased": true, |
| 151 | "messages": []Messages{ |
| 152 | { |
| 153 | Message: "Welcome to OpenCSG!", |
| 154 | Type: "alert", |
| 155 | }, |
| 156 | }, |
| 157 | }) |
| 158 | } |
| 159 | |
| 160 | func (h *InternalHandler) GetAuthorizedKeys(ctx *gin.Context) { |
| 161 | key := ctx.Query("key") |
nothing calls this directly
no test coverage detected