fixed regression about _preview not deleting published web site
This commit is contained in:
parent
fd5223b281
commit
dad20ec835
2 changed files with 23 additions and 10 deletions
33
main.go
33
main.go
|
@ -168,6 +168,8 @@ func main() {
|
||||||
err = os.MkdirAll(filepath.Join(outDir, outSandpointsDir, "_preview"), 0755)
|
err = os.MkdirAll(filepath.Join(outDir, outSandpointsDir, "_preview"), 0755)
|
||||||
check(err)
|
check(err)
|
||||||
|
|
||||||
|
published := isPublished(gitRepoPath, gitIndexPath, prevCommit, lastCommit)
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
lastPreviewCommitLog, err := os.Create(filepath.Join(outDir, outSandpointsDir, "_preview", "last-commit-log.txt"))
|
lastPreviewCommitLog, err := os.Create(filepath.Join(outDir, outSandpointsDir, "_preview", "last-commit-log.txt"))
|
||||||
check(err)
|
check(err)
|
||||||
|
@ -175,8 +177,9 @@ func main() {
|
||||||
fmt.Fprintln(lastPreviewCommitLog, logLines)
|
fmt.Fprintln(lastPreviewCommitLog, logLines)
|
||||||
log.Printf(logLines)
|
log.Printf(logLines)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
if isPublished(gitRepoPath, gitIndexPath, prevCommit, lastCommit) {
|
if published {
|
||||||
lastGiteaCommitLog, err := os.Create(filepath.Join(outDir, outSandpointsDir, "last-commit-log.txt"))
|
lastGiteaCommitLog, err := os.Create(filepath.Join(outDir, outSandpointsDir, "last-commit-log.txt"))
|
||||||
check(err)
|
check(err)
|
||||||
defer lastGiteaCommitLog.Close()
|
defer lastGiteaCommitLog.Close()
|
||||||
|
@ -184,7 +187,7 @@ func main() {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if isPublished(gitRepoPath, gitIndexPath, prevCommit, lastCommit) {
|
if published {
|
||||||
hugoGiteaLogs := cage.Start()
|
hugoGiteaLogs := cage.Start()
|
||||||
respGitea := commands.Execute([]string{"-s", tmpRepoPath, "-d", tmpHugoGiteaPath, "-e", "gitea"})
|
respGitea := commands.Execute([]string{"-s", tmpRepoPath, "-d", tmpHugoGiteaPath, "-e", "gitea"})
|
||||||
cage.Stop(hugoGiteaLogs)
|
cage.Stop(hugoGiteaLogs)
|
||||||
|
@ -209,23 +212,33 @@ func main() {
|
||||||
|
|
||||||
logLines = hugoLogs(logLines, hugoPreviewLogs.Data, "for _preview instance")
|
logLines = hugoLogs(logLines, hugoPreviewLogs.Data, "for _preview instance")
|
||||||
|
|
||||||
if _, err := os.Stat(filepath.Join(outDir, outSandpointsDir)); err == nil {
|
if published {
|
||||||
err := os.RemoveAll(filepath.Join(outDir, outSandpointsDir))
|
if _, err := os.Stat(filepath.Join(outDir, outSandpointsDir)); err == nil {
|
||||||
|
err := os.RemoveAll(filepath.Join(outDir, outSandpointsDir))
|
||||||
|
check(err)
|
||||||
|
}
|
||||||
|
} else if _, err := os.Stat(filepath.Join(outDir, outSandpointsDir, "_preview")); err == nil {
|
||||||
|
err := os.RemoveAll(filepath.Join(outDir, outSandpointsDir, "_preview"))
|
||||||
check(err)
|
check(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = os.MkdirAll(outDir, 0755)
|
err = os.MkdirAll(outDir, 0755)
|
||||||
check(err)
|
check(err)
|
||||||
|
|
||||||
err = os.Rename(tmpHugoGiteaPath, filepath.Join(outDir, outSandpointsDir))
|
if published {
|
||||||
check(err)
|
err = os.Rename(tmpHugoGiteaPath, filepath.Join(outDir, outSandpointsDir))
|
||||||
|
check(err)
|
||||||
|
} else {
|
||||||
|
err = os.Rename(tmpHugoPreviewPath, filepath.Join(outDir, outSandpointsDir, "_preview"))
|
||||||
|
check(err)
|
||||||
|
}
|
||||||
|
|
||||||
published := ""
|
publishedMessage := ""
|
||||||
if isPublished(gitRepoPath, gitIndexPath, prevCommit, lastCommit) {
|
if published {
|
||||||
published = " + published instance"
|
publishedMessage = " + published instance"
|
||||||
}
|
}
|
||||||
|
|
||||||
durationMillseconds := int64(time.Since(startTime) / time.Millisecond)
|
durationMillseconds := int64(time.Since(startTime) / time.Millisecond)
|
||||||
logLines = logLines + fmt.Sprintf("Total processing time (_preview%s): %d ms", published, durationMillseconds)
|
logLines = logLines + fmt.Sprintf("Total processing time (_preview%s): %d ms", publishedMessage, durationMillseconds)
|
||||||
logGiteaLines = logGiteaLines + fmt.Sprintf("Total processing time (published + _preview instance): %d ms", durationMillseconds)
|
logGiteaLines = logGiteaLines + fmt.Sprintf("Total processing time (published + _preview instance): %d ms", durationMillseconds)
|
||||||
}
|
}
|
||||||
|
|
BIN
sphook
BIN
sphook
Binary file not shown.
Loading…
Add table
Reference in a new issue