Lindenii Project Forge
Commit info | |
---|---|
ID | 809250243e8f4c52dfda7dbf498582c5a6aca8fb |
Author | Runxi Yu<me@runxiyu.org> |
Author date | Mon, 17 Feb 2025 11:54:29 +0800 |
Committer | Runxi Yu<me@runxiyu.org> |
Committer date | Mon, 17 Feb 2025 11:54:29 +0800 |
Actions | Get patch |
*.go: Reformat
package main import ( "errors" "io" "os" "path/filepath" ) func deploy_hooks_to_filesystem() (err error) { err = func() error { src_fd, err := resources_fs.Open("git_hooks_client/git_hooks_client") if err != nil { return err } defer src_fd.Close() dst_fd, err := os.OpenFile(filepath.Join(config.Hooks.Execs, "git_hooks_client"), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o755) if err != nil { return err } defer dst_fd.Close() _, err = io.Copy(dst_fd, src_fd) if err != nil { return err } return nil }() if err != nil { return err }
err = os.Chmod(filepath.Join(config.Hooks.Execs, "git_hooks_client"), 0755)
err = os.Chmod(filepath.Join(config.Hooks.Execs, "git_hooks_client"), 0o755)
if err != nil { return err } for _, hook_name := range []string{ "pre-receive", } { err = os.Symlink(filepath.Join(config.Hooks.Execs, "git_hooks_client"), filepath.Join(config.Hooks.Execs, hook_name)) if err != nil && !errors.Is(err, os.ErrExist) { return err } } return nil }
package main
import ( "github.com/go-git/go-git/v5" git_format_config "github.com/go-git/go-git/v5/plumbing/format/config" ) func git_bare_init_with_default_hooks(repo_path string) (err error) { repo, err := git.PlainInit(repo_path, true) if err != nil { return err } git_config, err := repo.Config() if err != nil { return err } git_config.Raw.SetOption("core", git_format_config.NoSubsection, "hooksPath", config.Hooks.Execs) err = repo.SetConfig(git_config) if err != nil { return err } return nil }