mirror of
https://github.com/thomiceli/opengist.git
synced 2025-07-09 01:18:04 +02:00
Set gist visibility via Git push options (#215)
This commit is contained in:
@ -1,9 +1,14 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/thomiceli/opengist/internal/config"
|
||||
"github.com/thomiceli/opengist/internal/db"
|
||||
"github.com/thomiceli/opengist/internal/hooks"
|
||||
"github.com/urfave/cli/v2"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
var CmdHook = cli.Command{
|
||||
@ -19,6 +24,7 @@ var CmdHookPreReceive = cli.Command{
|
||||
Name: "pre-receive",
|
||||
Usage: "Run Git server pre-receive hook for a repository",
|
||||
Action: func(ctx *cli.Context) error {
|
||||
initialize(ctx)
|
||||
if err := hooks.PreReceive(os.Stdin, os.Stdout, os.Stderr); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
@ -30,9 +36,21 @@ var CmdHookPostReceive = cli.Command{
|
||||
Name: "post-receive",
|
||||
Usage: "Run Git server post-receive hook for a repository",
|
||||
Action: func(ctx *cli.Context) error {
|
||||
initialize(ctx)
|
||||
if err := hooks.PostReceive(os.Stdin, os.Stdout, os.Stderr); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
func initialize(ctx *cli.Context) {
|
||||
if err := config.InitConfig(ctx.String("config"), io.Discard); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
config.InitLog()
|
||||
|
||||
if err := db.Setup(filepath.Join(config.GetHomeDir(), config.C.DBFilename), false); err != nil {
|
||||
log.Fatal().Err(err).Msg("Failed to initialize database in hooks")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user