Skip to content

Commit

Permalink
Add debug option to hooks (#11624)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
  • Loading branch information
3 people authored May 29, 2020
1 parent 560744f commit 8730b09
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions cmd/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,33 @@ var (
Usage: "Delegate pre-receive Git hook",
Description: "This command should only be called by Git",
Action: runHookPreReceive,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "debug",
},
},
}
subcmdHookUpdate = cli.Command{
Name: "update",
Usage: "Delegate update Git hook",
Description: "This command should only be called by Git",
Action: runHookUpdate,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "debug",
},
},
}
subcmdHookPostReceive = cli.Command{
Name: "post-receive",
Usage: "Delegate post-receive Git hook",
Description: "This command should only be called by Git",
Action: runHookPostReceive,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "debug",
},
},
}
)

Expand Down Expand Up @@ -138,7 +153,7 @@ func runHookPreReceive(c *cli.Context) error {
return nil
}

setup("hooks/pre-receive.log", false)
setup("hooks/pre-receive.log", c.Bool("debug"))

if len(os.Getenv("SSH_ORIGINAL_COMMAND")) == 0 {
if setting.OnlyAllowPushIfGiteaEnvironmentSet {
Expand Down Expand Up @@ -273,7 +288,7 @@ func runHookPostReceive(c *cli.Context) error {
return nil
}

setup("hooks/post-receive.log", false)
setup("hooks/post-receive.log", c.Bool("debug"))

if len(os.Getenv("SSH_ORIGINAL_COMMAND")) == 0 {
if setting.OnlyAllowPushIfGiteaEnvironmentSet {
Expand Down

0 comments on commit 8730b09

Please sign in to comment.