Mirror of @tangled.org/core. Running on a Raspberry Pi Zero 2 (Please be gentle).
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

knotserver: internal: extract push options from the headers, and implement skipping ci if skip-ci or ci-skip is passed

Signed-off-by: dusk <y.bera003.06@protonmail.com>

Change-Id: prnxlqukyzkuwltoylruvunqkmmwrukx

authored by

dusk and committed by
Tangled
56c2a277 690d4b2f

+19 -2
+19 -2
knotserver/internal.go
··· 64 64 return 65 65 } 66 66 67 + type PushOptions struct { 68 + skipCi bool 69 + } 70 + 67 71 func (h *InternalHandle) PostReceiveHook(w http.ResponseWriter, r *http.Request) { 68 72 l := h.l.With("handler", "PostReceiveHook") 69 73 ··· 94 90 // non-fatal 95 91 } 96 92 93 + // extract any push options 94 + pushOptionsRaw := r.Header.Values("X-Git-Push-Option") 95 + pushOptions := PushOptions{} 96 + for _, option := range pushOptionsRaw { 97 + if option == "skip-ci" || option == "ci-skip" { 98 + pushOptions.skipCi = true 99 + } 100 + } 101 + 97 102 for _, line := range lines { 98 103 err := h.insertRefUpdate(line, gitUserDid, repoDid, repoName) 99 104 if err != nil { ··· 110 97 // non-fatal 111 98 } 112 99 113 - err = h.triggerPipeline(line, gitUserDid, repoDid, repoName) 100 + err = h.triggerPipeline(line, gitUserDid, repoDid, repoName, pushOptions) 114 101 if err != nil { 115 102 l.Error("failed to trigger pipeline", "err", err, "line", line, "did", gitUserDid, "repo", gitRelativeDir) 116 103 // non-fatal ··· 161 148 return h.db.InsertEvent(event, h.n) 162 149 } 163 150 164 - func (h *InternalHandle) triggerPipeline(line git.PostReceiveLine, gitUserDid, repoDid, repoName string) error { 151 + func (h *InternalHandle) triggerPipeline(line git.PostReceiveLine, gitUserDid, repoDid, repoName string, pushOptions PushOptions) error { 152 + if pushOptions.skipCi { 153 + return nil 154 + } 155 + 165 156 didSlashRepo, err := securejoin.SecureJoin(repoDid, repoName) 166 157 if err != nil { 167 158 return err