mirror of
https://github.com/thomiceli/opengist.git
synced 2025-07-09 17:38:04 +02:00
Move Git hook logic to Opengist (#213)
This commit is contained in:
38
internal/cli/hook.go
Normal file
38
internal/cli/hook.go
Normal file
@ -0,0 +1,38 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"github.com/thomiceli/opengist/internal/hooks"
|
||||
"github.com/urfave/cli/v2"
|
||||
"os"
|
||||
)
|
||||
|
||||
var CmdHook = cli.Command{
|
||||
Name: "hook",
|
||||
Usage: "Run Git server hooks, used and should only be called by Opengist itself",
|
||||
Subcommands: []*cli.Command{
|
||||
&CmdHookPreReceive,
|
||||
&CmdHookPostReceive,
|
||||
},
|
||||
}
|
||||
|
||||
var CmdHookPreReceive = cli.Command{
|
||||
Name: "pre-receive",
|
||||
Usage: "Run Git server pre-receive hook for a repository",
|
||||
Action: func(ctx *cli.Context) error {
|
||||
if err := hooks.PreReceive(os.Stdin, os.Stdout, os.Stderr); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
var CmdHookPostReceive = cli.Command{
|
||||
Name: "post-receive",
|
||||
Usage: "Run Git server post-receive hook for a repository",
|
||||
Action: func(ctx *cli.Context) error {
|
||||
if err := hooks.PostReceive(os.Stdin, os.Stdout, os.Stderr); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
Reference in New Issue
Block a user