mirror of
https://github.com/thomiceli/opengist
synced 2024-11-12 07:05:50 +01:00
Fix empty commit revision
This commit is contained in:
parent
31ea2f650b
commit
c71185d11e
@ -69,8 +69,16 @@ func parseLog(out io.Reader) []*Commit {
|
|||||||
var currentFile *File
|
var currentFile *File
|
||||||
var isContent bool
|
var isContent bool
|
||||||
var bytesRead = 0
|
var bytesRead = 0
|
||||||
|
scanNext := true
|
||||||
|
|
||||||
|
for {
|
||||||
|
if scanNext && !scanner.Scan() {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
scanNext = true
|
||||||
|
|
||||||
|
fmt.Println("> " + string(scanner.Bytes()))
|
||||||
|
|
||||||
for scanner.Scan() {
|
|
||||||
// new commit found
|
// new commit found
|
||||||
currentFile = nil
|
currentFile = nil
|
||||||
currentCommit = &Commit{Hash: string(scanner.Bytes()[2:]), Files: []File{}}
|
currentCommit = &Commit{Hash: string(scanner.Bytes()[2:]), Files: []File{}}
|
||||||
@ -85,6 +93,16 @@ func parseLog(out io.Reader) []*Commit {
|
|||||||
currentCommit.Timestamp = string(scanner.Bytes()[2:])
|
currentCommit.Timestamp = string(scanner.Bytes()[2:])
|
||||||
|
|
||||||
scanner.Scan()
|
scanner.Scan()
|
||||||
|
|
||||||
|
// if there is no shortstat, it means that the commit is empty, we add it and move onto the next one
|
||||||
|
if scanner.Bytes()[0] != ' ' {
|
||||||
|
commits = append(commits, currentCommit)
|
||||||
|
|
||||||
|
// avoid scanning the next line, as we already did it
|
||||||
|
scanNext = false
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
changed := scanner.Bytes()[1:]
|
changed := scanner.Bytes()[1:]
|
||||||
changed = bytes.ReplaceAll(changed, []byte("(+)"), []byte(""))
|
changed = bytes.ReplaceAll(changed, []byte("(+)"), []byte(""))
|
||||||
changed = bytes.ReplaceAll(changed, []byte("(-)"), []byte(""))
|
changed = bytes.ReplaceAll(changed, []byte("(-)"), []byte(""))
|
||||||
@ -158,9 +176,8 @@ func parseLog(out io.Reader) []*Commit {
|
|||||||
scanner.Scan()
|
scanner.Scan()
|
||||||
}
|
}
|
||||||
|
|
||||||
if currentCommit != nil {
|
|
||||||
commits = append(commits, currentCommit)
|
commits = append(commits, currentCommit)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return commits
|
return commits
|
||||||
|
Loading…
Reference in New Issue
Block a user