summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--git-shell-commands.go22
1 files changed, 9 insertions, 13 deletions
diff --git a/git-shell-commands.go b/git-shell-commands.go
index 3f0950e..afd9e0d 100644
--- a/git-shell-commands.go
+++ b/git-shell-commands.go
@@ -61,23 +61,19 @@ Create a new git repo named REPO.
if err := git.Run(); err != nil {
return err
}
- infoWeb := filepath.Join(dir, "info", "web")
- fmt.Fprintf(os.Stderr, "mkdir %s\n", shellQuote(infoWeb))
- if err := os.Mkdir(infoWeb, 0755); err != nil {
+ hooks := filepath.Join(dir, "hooks")
+ fmt.Fprintf(os.Stderr, "rm -rf %s\n", shellQuote(hooks))
+ if err := os.RemoveAll(hooks); err != nil {
return err
}
- postReceiveHook := filepath.Join(dir, "hooks", "post-receive")
- const postReceiveScript = "TZ=UTC0 git log -1 --reflog --date='format-local:%Y-%m-%d %H:%M:%S' --pretty=%cd > $GIT_DIR/info/web/last-modified"
- fmt.Fprintf(os.Stderr, "echo %s > %s && chmod +x %[2]s\n", shellQuote(postReceiveScript), shellQuote(postReceiveHook))
- postReceive, err := os.OpenFile(postReceiveHook, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0755)
- if err != nil {
+ const linkTarget = "../git-shell-commands.git/hooks"
+ fmt.Fprintf(os.Stderr, "ln -s %s %s\n", shellQuote(linkTarget), shellQuote(hooks))
+ if err := os.Symlink(linkTarget, hooks); err != nil {
return err
}
- defer postReceive.Close()
- if _, err := io.WriteString(postReceive, postReceiveScript+"\n"); err != nil {
- return err
- }
- if err := postReceive.Close(); err != nil {
+ infoWeb := filepath.Join(dir, "info", "web")
+ fmt.Fprintf(os.Stderr, "mkdir %s\n", shellQuote(infoWeb))
+ if err := os.Mkdir(infoWeb, 0755); err != nil {
return err
}
if *d != "" {