瀏覽代碼

Fix SHA crash

tags/v0.3.1
Russ Garrett 5 年之前
父節點
當前提交
310f8f9135
沒有連結到貢獻者的電子郵件帳戶。
共有 1 個檔案被更改,包括 4 行新增1 行删除
  1. 4
    1
      httplistener/templates.go

+ 4
- 1
httplistener/templates.go 查看文件

@@ -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…
取消
儲存