|
|
@ -1,10 +1,38 @@
|
|
|
|
package main
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
|
|
|
|
"bufio"
|
|
|
|
"os"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"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) {
|
|
|
|
func cleanUpPublicHTML(hugo *Hugo, hook *Hook) {
|
|
|
|
if hook.Publish {
|
|
|
|
if hook.Publish {
|
|
|
|
if _, err := os.Stat(filepath.Join(hook.PublicHTMLPath, hugo.PublicHTMLName)); err == nil {
|
|
|
|
if _, err := os.Stat(filepath.Join(hook.PublicHTMLPath, hugo.PublicHTMLName)); err == nil {
|
|
|
|