aboutsummaryrefslogtreecommitdiff
path: root/git_hooks_deploy.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-04-05 20:21:32 +0800
committerRunxi Yu <me@runxiyu.org>2025-04-05 20:21:32 +0800
commit71ab9b7f14118f02dd18cd733bd4e0ad19ece590 (patch)
tree0303cbee651a4e1cee62a348d25066b9543f4425 /git_hooks_deploy.go
parentgit2d: Remove UTF-8 checks (diff)
downloadforge-71ab9b7f14118f02dd18cd733bd4e0ad19ece590.tar.gz
forge-71ab9b7f14118f02dd18cd733bd4e0ad19ece590.tar.zst
forge-71ab9b7f14118f02dd18cd733bd4e0ad19ece590.zip
config shall no longer be a global variable
Diffstat (limited to '')
-rw-r--r--git_hooks_deploy.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/git_hooks_deploy.go b/git_hooks_deploy.go
index c9039fe..ea11d0c 100644
--- a/git_hooks_deploy.go
+++ b/git_hooks_deploy.go
@@ -14,7 +14,7 @@ import (
// deployHooks deploys the git hooks client to the filesystem. The git hooks
// client is expected to be embedded in resourcesFS and must be pre-compiled
// during the build process; see the Makefile.
-func deployHooks() (err error) {
+func (s *server) deployHooks() (err error) {
err = func() (err error) {
var srcFD fs.File
var dstFD *os.File
@@ -24,7 +24,7 @@ func deployHooks() (err error) {
}
defer srcFD.Close()
- if dstFD, err = os.OpenFile(filepath.Join(config.Hooks.Execs, "hookc"), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o755); err != nil {
+ if dstFD, err = os.OpenFile(filepath.Join(s.config.Hooks.Execs, "hookc"), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o755); err != nil {
return err
}
defer dstFD.Close()
@@ -41,14 +41,14 @@ func deployHooks() (err error) {
// Go's embed filesystems do not store permissions; but in any case,
// they would need to be 0o755:
- if err = os.Chmod(filepath.Join(config.Hooks.Execs, "hookc"), 0o755); err != nil {
+ if err = os.Chmod(filepath.Join(s.config.Hooks.Execs, "hookc"), 0o755); err != nil {
return err
}
for _, hookName := range []string{
"pre-receive",
} {
- if err = os.Symlink(filepath.Join(config.Hooks.Execs, "hookc"), filepath.Join(config.Hooks.Execs, hookName)); err != nil {
+ if err = os.Symlink(filepath.Join(s.config.Hooks.Execs, "hookc"), filepath.Join(s.config.Hooks.Execs, hookName)); err != nil {
if !errors.Is(err, fs.ErrExist) {
return err
}