MCPcopy Create free account
hub / github.com/OpenCSGs/csghub-server / GitReceivePack

Method GitReceivePack

api/handler/git_http.go:119–152  ·  view source on GitHub ↗
(ctx *gin.Context)

Source from the content-addressed store, hash-verified

117}
118
119func (h *GitHTTPHandler) GitReceivePack(ctx *gin.Context) {
120 gitProtocol := ctx.GetHeader("Git-Protocol")
121 req := types.GitUploadPackReq{
122 Namespace: ctx.GetString("namespace"),
123 Name: ctx.GetString("name"),
124 RepoType: types.RepositoryType(ctx.GetString("repo_type")),
125 GitProtocol: gitProtocol,
126 Request: ctx.Request,
127 Writer: ctx.Writer,
128 CurrentUser: httpbase.GetCurrentUser(ctx),
129 }
130 action := getService(ctx.Request)
131
132 ctx.Header("Content-Type", fmt.Sprintf("application/x-%s-result", action))
133 ctx.Header("Cache-Control", "no-cache")
134
135 err := h.c.GitReceivePack(ctx, req)
136 if err != nil {
137 if err == component.ErrUnauthorized {
138 ctx.Header("WWW-Authenticate", "Basic realm=opencsg-git")
139 ctx.PureJSON(http.StatusUnauthorized, nil)
140 return
141 }
142
143 if err == component.ErrForbidden {
144 ctx.PureJSON(http.StatusForbidden, gin.H{
145 "error": "You do not have permission to access this repository.",
146 })
147 return
148 }
149 httpbase.ServerError(ctx, err)
150 return
151 }
152}
153
154func (h *GitHTTPHandler) LfsBatch(ctx *gin.Context) {
155 var batchRequest types.BatchRequest

Callers

nothing calls this directly

Calls 4

RepositoryTypeTypeAlias · 0.92
GetCurrentUserFunction · 0.92
ServerErrorFunction · 0.92
getServiceFunction · 0.85

Tested by

no test coverage detected