Skip to content

Commit 9ca521d

Browse files
authored
Merge pull request #12 from josegonzalez/customize-command
Add ability to customize the executed git command
2 parents a5df8ad + b7854de commit 9ca521d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

server/server.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type Config struct {
3131
UploadPack bool
3232
ReceivePack bool
3333
RoutePrefix string
34+
CommandFunc func(*exec.Cmd)
3435
}
3536

3637
type HandlerReq struct {
@@ -53,6 +54,7 @@ var (
5354
UploadPack: true,
5455
ReceivePack: true,
5556
RoutePrefix: "",
57+
CommandFunc: func(*exec.Cmd) {},
5658
}
5759
)
5860

@@ -148,6 +150,9 @@ func serviceRpc(hr HandlerReq) {
148150
}
149151
cmd.Dir = dir
150152
cmd.Env = env
153+
154+
DefaultConfig.CommandFunc(cmd)
155+
151156
in, err := cmd.StdinPipe()
152157
if err != nil {
153158
log.Print(err)
@@ -347,6 +352,9 @@ func gitCommand(dir string, version string, args ...string) []byte {
347352
command.Env = append(os.Environ(), fmt.Sprintf("GIT_PROTOCOL=%s", version))
348353
}
349354
command.Dir = dir
355+
356+
DefaultConfig.CommandFunc(command)
357+
350358
out, err := command.Output()
351359

352360
if err != nil {

0 commit comments

Comments
 (0)