Problem: gitRevision does not handle errors
Solution: handle errors in gitRevision
This commit is contained in:
parent
3ee280a124
commit
1acd0e5f0f
13
file.go
13
file.go
|
@ -699,6 +699,9 @@ func (fp *FilePages) PageHistory(p string) ([]Revision, error) {
|
||||||
commitId := line[0:start]
|
commitId := line[0:start]
|
||||||
rest := line[start+1:]
|
rest := line[start+1:]
|
||||||
pageText := gitRevision(fp.dirname, page, commitId)
|
pageText := gitRevision(fp.dirname, page, commitId)
|
||||||
|
if pageText == "" {
|
||||||
|
return nil, errors.New("git revision failed")
|
||||||
|
}
|
||||||
revisions = append(revisions, Revision{
|
revisions = append(revisions, Revision{
|
||||||
Version: commitId,
|
Version: commitId,
|
||||||
Page: DiffPage{Content: pageText},
|
Page: DiffPage{Content: pageText},
|
||||||
|
@ -727,8 +730,14 @@ func gitRevision(dirname, page, version string) string {
|
||||||
cmd.Dir = dirname
|
cmd.Dir = dirname
|
||||||
buf := bytes.Buffer{}
|
buf := bytes.Buffer{}
|
||||||
cmd.Stdout = &buf
|
cmd.Stdout = &buf
|
||||||
cmd.Start()
|
err := cmd.Start()
|
||||||
cmd.Wait()
|
if err != nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
err = cmd.Wait()
|
||||||
|
if err != nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
return buf.String()
|
return buf.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user