1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-10-30 03:36:16 +00:00

Fix recent changes crashing on empty wikis

This is a dirty fix. How come git-handling is so messed?
This commit is contained in:
Timur Ismagilov 2023-08-06 01:50:15 +05:00
parent eae42c310d
commit 353d462bbe

View File

@ -27,7 +27,12 @@ func gitLog(args ...string) ([]Revision, error) {
"log", "--abbrev-commit", "--no-merges",
"--pretty=format:%h\t%ae\t%at\t%s",
}, args...)
args = append(args, "--")
out, err := silentGitsh(args...)
if strings.Contains(out.String(), "bad revision 'HEAD'") {
// Then we have no recent changes! It's a hack.
return nil, nil
}
if err != nil {
return nil, err
}
@ -63,6 +68,7 @@ func (stream *recentChangesStream) next(n int) []Revision {
// currHash is the last revision from the last call, so skip it
args = append(args, "--skip=1", stream.currHash)
}
res, err := gitLog(args...)
if err != nil {
log.Fatal(err)
@ -70,6 +76,7 @@ func (stream *recentChangesStream) next(n int) []Revision {
if len(res) != 0 {
stream.currHash = res[len(res)-1].Hash
}
return res
}