+19
-2
knotserver/internal.go
+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
···
90
94
// non-fatal
91
95
}
92
96
97
+
// extract any push options
98
+
pushOptionsRaw := r.Header.Values("X-Git-Push-Option")
99
+
pushOptions := PushOptions{}
100
+
for _, option := range pushOptionsRaw {
101
+
if option == "skip-ci" || option == "ci-skip" {
102
+
pushOptions.skipCi = true
103
+
}
104
+
}
105
+
93
106
for _, line := range lines {
94
107
err := h.insertRefUpdate(line, gitUserDid, repoDid, repoName)
95
108
if err != nil {
···
97
110
// non-fatal
98
111
}
99
112
100
-
err = h.triggerPipeline(line, gitUserDid, repoDid, repoName)
113
+
err = h.triggerPipeline(line, gitUserDid, repoDid, repoName, pushOptions)
101
114
if err != nil {
102
115
l.Error("failed to trigger pipeline", "err", err, "line", line, "did", gitUserDid, "repo", gitRelativeDir)
103
116
// non-fatal
···
148
161
return h.db.InsertEvent(event, h.n)
149
162
}
150
163
151
-
func (h *InternalHandle) triggerPipeline(line git.PostReceiveLine, gitUserDid, repoDid, repoName string) error {
164
+
func (h *InternalHandle) triggerPipeline(line git.PostReceiveLine, gitUserDid, repoDid, repoName string, pushOptions PushOptions) error {
165
+
if pushOptions.skipCi {
166
+
return nil
167
+
}
168
+
152
169
didSlashRepo, err := securejoin.SecureJoin(repoDid, repoName)
153
170
if err != nil {
154
171
return err