Hi… I am well aware that this diff view is very suboptimal. It will be fixed when the refactored server comes along!
*.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
}