aboutsummaryrefslogtreecommitdiff
path: root/git_hooks_deploy.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-04-06 00:42:11 +0800
committerRunxi Yu <me@runxiyu.org>2025-04-06 00:42:26 +0800
commitf5ebe96649a30658bb8a8bee4cb2ac1b45823b28 (patch)
tree980c5fb915da731335baa30860d2e660bcffa407 /git_hooks_deploy.go
parentLMTP: Fix sed mistake (diff)
downloadforge-f5ebe96649a30658bb8a8bee4cb2ac1b45823b28.tar.gz
forge-f5ebe96649a30658bb8a8bee4cb2ac1b45823b28.tar.zst
forge-f5ebe96649a30658bb8a8bee4cb2ac1b45823b28.zip
Hooks, git2d: Simplify deployment logicv0.1.27
Diffstat (limited to 'git_hooks_deploy.go')
-rw-r--r--git_hooks_deploy.go60
1 files changed, 0 insertions, 60 deletions
diff --git a/git_hooks_deploy.go b/git_hooks_deploy.go
deleted file mode 100644
index afab7f0..0000000
--- a/git_hooks_deploy.go
+++ /dev/null
@@ -1,60 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-only
-// SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org>
-
-package forge
-
-import (
- "errors"
- "io"
- "io/fs"
- "os"
- "path/filepath"
-)
-
-// 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 (s *Server) deployHooks() (err error) {
- err = func() (err error) {
- var srcFD fs.File
- var dstFD *os.File
-
- if srcFD, err = embeddedResourcesFS.Open("hookc/hookc"); err != nil {
- return err
- }
- defer srcFD.Close()
-
- 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()
-
- if _, err = io.Copy(dstFD, srcFD); err != nil {
- return err
- }
-
- return nil
- }()
- if err != nil {
- return err
- }
-
- // Go's embed filesystems do not store permissions; but in any case,
- // they would need to be 0o755:
- 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(s.config.Hooks.Execs, "hookc"), filepath.Join(s.config.Hooks.Execs, hookName)); err != nil {
- if !errors.Is(err, fs.ErrExist) {
- return err
- }
- // TODO: Maybe check if it points to the right place?
- }
- }
-
- return nil
-}