Browse Source

Fix SHA crash

tags/v0.3.1
Russ Garrett 5 years ago
parent
commit
310f8f9135
No account linked to committer's email address
1 changed files with 4 additions and 1 deletions
  1. 4
    1
      httplistener/templates.go

+ 4
- 1
httplistener/templates.go View File

@@ -36,6 +36,9 @@ func refType(ref string) string {
36 36
 }
37 37
 
38 38
 func truncateSha(sha string) string {
39
+	if len(sha) < 8 {
40
+		return ""
41
+	}
39 42
 	return sha[len(sha)-7:]
40 43
 }
41 44
 
@@ -99,7 +102,7 @@ func commitLimit(pl github.PushPayload, length int) []Commit {
99 102
 		if !c.Distinct {
100 103
 			continue
101 104
 		}
102
-		res = append(res, Commit{Message: c.Message, Username: c.Author.Username, Sha: c.Sha})
105
+		res = append(res, Commit{Message: c.Message, Username: c.Author.Username, Sha: c.ID})
103 106
 		i += 1
104 107
 		if i == length {
105 108
 			break

Loading…
Cancel
Save