diff --git a/main.go b/main.go index 9620cd3a..ca516320 100644 --- a/main.go +++ b/main.go @@ -1,14 +1,11 @@ package main import ( - "bufio" "fmt" "log" - "os" "os/exec" "path/filepath" "runtime" - "strings" "time" "git.sandpoints.org/Drawwell/SandpointsGitHook/giq" @@ -61,32 +58,6 @@ func gitExePath(hook *Hook) string { } } -func hookContext(hook *Hook) { - scanner := bufio.NewScanner(os.Stdin) - scanner.Scan() - if scanner.Text() == "" { - hook.Context = "PostCommit" - } else if strings.HasPrefix(scanner.Text(), "sandpoints-ext") { - revs := strings.Fields(scanner.Text()) - if revs[1] == "publish" { - hook.Publish = true - } - if revs[2] == "offline" { - hook.Offline = true - } - if revs[3] == "file" { - hook.Context = "SandpointsFileProtocol" - } - if revs[3] == "http" { - hook.Context = "SandpointsHTTPProtocol" - } - } else { - // it only handles gitea use case if not Local or sandpoints-ext - hook.Context = "PostReceive" - hook.Stdinput = scanner.Text() - } -} - func main() { startTime := time.Now() logLines := "~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~\n" + startTime.Format(time.RFC822) + "\n" diff --git a/metahook.go b/metahook.go index 228ae23c..eebb6c28 100644 --- a/metahook.go +++ b/metahook.go @@ -1,10 +1,38 @@ package main import ( + "bufio" "os" "path/filepath" + "strings" ) +func hookContext(hook *Hook) { + scanner := bufio.NewScanner(os.Stdin) + scanner.Scan() + if scanner.Text() == "" { + hook.Context = "PostCommit" + } else if strings.HasPrefix(scanner.Text(), "sandpoints-ext") { + revs := strings.Fields(scanner.Text()) + if revs[1] == "publish" { + hook.Publish = true + } + if revs[2] == "offline" { + hook.Offline = true + } + if revs[3] == "file" { + hook.Context = "SandpointsFileProtocol" + } + if revs[3] == "http" { + hook.Context = "SandpointsHTTPProtocol" + } + } else { + // it only handles gitea use case if not Local or sandpoints-ext + hook.Context = "PostReceive" + hook.Stdinput = scanner.Text() + } +} + func cleanUpPublicHTML(hugo *Hugo, hook *Hook) { if hook.Publish { if _, err := os.Stat(filepath.Join(hook.PublicHTMLPath, hugo.PublicHTMLName)); err == nil { diff --git a/sphook b/sphook index 0408cec6..6bfad6a8 100755 Binary files a/sphook and b/sphook differ