Skip to content

Commit 6eb01b6

Browse files
committed
Update
1 parent 18061af commit 6eb01b6

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

modules/base/tool.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ func ShortSha(sha1 string) string {
4141
return TruncateString(sha1, 10)
4242
}
4343

44+
// ShortSha256 takes 7-17 indexes of sha256 string as short sha256
45+
func ShortSha256(sha256 string) string {
46+
if utf8.RuneCountInString(sha256) < 17 {
47+
return sha256
48+
}
49+
return string([]rune(sha256)[7:17])
50+
}
51+
4452
// BasicAuthDecode decode basic auth string
4553
func BasicAuthDecode(encoded string) (string, string, error) {
4654
s, err := base64.StdEncoding.DecodeString(encoded)

modules/templates/helper.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ func NewFuncMap() template.FuncMap {
162162
// -----------------------------------------------------------------
163163
// misc
164164
"ShortSha": base.ShortSha,
165+
"ShortSha256": base.ShortSha256,
165166
"ActionContent2Commits": ActionContent2Commits,
166167
"IsMultilineCommitMessage": isMultilineCommitMessage,
167168
"CommentMustAsDiff": gitdiff.CommentMustAsDiff,

templates/package/content/container.tmpl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@
3636
</thead>
3737
<tbody>
3838
{{range .PackageDescriptor.Metadata.Manifests}}
39-
<tr>
40-
<td><a href="{{$.PackageDescriptor.PackageWebLink}}/{{PathEscape .Digest}}">{{.Digest}}</a></td>
41-
<td>{{.Platform}}</td>
42-
<td>{{FileSize .Size}}</td>
43-
</tr>
39+
{{if ne .Platform "unknown/unknown"}}
40+
<tr>
41+
<td><a href="{{$.PackageDescriptor.PackageWebLink}}/{{PathEscape .Digest}}">{{ShortSha256 .Digest}}</a></td>
42+
<td>{{.Platform}}</td>
43+
<td>{{FileSize .Size}}</td>
44+
</tr>
45+
{{end}}
4446
{{end}}
4547
</tbody>
4648
</table>

0 commit comments

Comments
 (0)