MCPcopy Create free account
hub / github.com/gogs/gogs / runHookUpdate

Function runHookUpdate

internal/cmd/hook.go:154–186  ·  view source on GitHub ↗
(c *cli.Context)

Source from the content-addressed store, hash-verified

152}
153
154func runHookUpdate(c *cli.Context) error {
155 if os.Getenv("SSH_ORIGINAL_COMMAND") == "" {
156 return nil
157 }
158 setup(c, "update.log", false)
159
160 args := c.Args()
161 if len(args) != 3 {
162 fail("Arguments received are not equal to three", "Arguments received are not equal to three")
163 } else if args[0] == "" {
164 fail("First argument 'refName' is empty", "First argument 'refName' is empty")
165 }
166
167 customHooksPath := filepath.Join(os.Getenv(database.EnvRepoCustomHooksPath), "update")
168 if !com.IsFile(customHooksPath) {
169 return nil
170 }
171
172 var hookCmd *exec.Cmd
173 if conf.IsWindowsRuntime() {
174 hookCmd = exec.Command("bash.exe", append([]string{"custom_hooks/update"}, args...)...)
175 } else {
176 hookCmd = exec.Command(customHooksPath, args...)
177 }
178 hookCmd.Dir = database.RepoPath(os.Getenv(database.EnvRepoOwnerName), os.Getenv(database.EnvRepoName))
179 hookCmd.Stdout = os.Stdout
180 hookCmd.Stdin = os.Stdin
181 hookCmd.Stderr = os.Stderr
182 if err := hookCmd.Run(); err != nil {
183 fail("Internal error", "Failed to execute custom pre-receive hook: %v", err)
184 }
185 return nil
186}
187
188func runHookPostReceive(c *cli.Context) error {
189 if os.Getenv("SSH_ORIGINAL_COMMAND") == "" {

Callers

nothing calls this directly

Calls 6

IsWindowsRuntimeFunction · 0.92
RepoPathFunction · 0.92
setupFunction · 0.85
appendFunction · 0.85
failFunction · 0.70
ArgsMethod · 0.45

Tested by

no test coverage detected