+19
-2
knotserver/internal.go
+19
-2
knotserver/internal.go
···
64
return
65
}
66
67
func (h *InternalHandle) PostReceiveHook(w http.ResponseWriter, r *http.Request) {
68
l := h.l.With("handler", "PostReceiveHook")
69
···
90
// non-fatal
91
}
92
93
for _, line := range lines {
94
err := h.insertRefUpdate(line, gitUserDid, repoDid, repoName)
95
if err != nil {
···
97
// non-fatal
98
}
99
100
-
err = h.triggerPipeline(line, gitUserDid, repoDid, repoName)
101
if err != nil {
102
l.Error("failed to trigger pipeline", "err", err, "line", line, "did", gitUserDid, "repo", gitRelativeDir)
103
// non-fatal
···
148
return h.db.InsertEvent(event, h.n)
149
}
150
151
-
func (h *InternalHandle) triggerPipeline(line git.PostReceiveLine, gitUserDid, repoDid, repoName string) error {
152
didSlashRepo, err := securejoin.SecureJoin(repoDid, repoName)
153
if err != nil {
154
return err
···
64
return
65
}
66
67
+
type PushOptions struct {
68
+
skipCi bool
69
+
}
70
+
71
func (h *InternalHandle) PostReceiveHook(w http.ResponseWriter, r *http.Request) {
72
l := h.l.With("handler", "PostReceiveHook")
73
···
94
// non-fatal
95
}
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
+
106
for _, line := range lines {
107
err := h.insertRefUpdate(line, gitUserDid, repoDid, repoName)
108
if err != nil {
···
110
// non-fatal
111
}
112
113
+
err = h.triggerPipeline(line, gitUserDid, repoDid, repoName, pushOptions)
114
if err != nil {
115
l.Error("failed to trigger pipeline", "err", err, "line", line, "did", gitUserDid, "repo", gitRelativeDir)
116
// non-fatal
···
161
return h.db.InsertEvent(event, h.n)
162
}
163
164
+
func (h *InternalHandle) triggerPipeline(line git.PostReceiveLine, gitUserDid, repoDid, repoName string, pushOptions PushOptions) error {
165
+
if pushOptions.skipCi {
166
+
return nil
167
+
}
168
+
169
didSlashRepo, err := securejoin.SecureJoin(repoDid, repoName)
170
if err != nil {
171
return err