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]
|
||||
rest := line[start+1:]
|
||||
pageText := gitRevision(fp.dirname, page, commitId)
|
||||
if pageText == "" {
|
||||
return nil, errors.New("git revision failed")
|
||||
}
|
||||
revisions = append(revisions, Revision{
|
||||
Version: commitId,
|
||||
Page: DiffPage{Content: pageText},
|
||||
|
@ -727,8 +730,14 @@ func gitRevision(dirname, page, version string) string {
|
|||
cmd.Dir = dirname
|
||||
buf := bytes.Buffer{}
|
||||
cmd.Stdout = &buf
|
||||
cmd.Start()
|
||||
cmd.Wait()
|
||||
err := cmd.Start()
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
err = cmd.Wait()
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user