Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions modules/base/tool.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ func ShortSha(sha1 string) string {
return TruncateString(sha1, 10)
}

// ShortSha256 takes 7-17 indexes of sha256 string as short sha256
func ShortSha256(sha256 string) string {
if utf8.RuneCountInString(sha256) < 17 {
return sha256
}
return string([]rune(sha256)[7:17])
}

// BasicAuthDecode decode basic auth string
func BasicAuthDecode(encoded string) (string, string, error) {
s, err := base64.StdEncoding.DecodeString(encoded)
Expand Down
1 change: 1 addition & 0 deletions modules/templates/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ func NewFuncMap() template.FuncMap {
// -----------------------------------------------------------------
// misc
"ShortSha": base.ShortSha,
"ShortSha256": base.ShortSha256,
"ActionContent2Commits": ActionContent2Commits,
"IsMultilineCommitMessage": isMultilineCommitMessage,
"CommentMustAsDiff": gitdiff.CommentMustAsDiff,
Expand Down
12 changes: 7 additions & 5 deletions templates/package/content/container.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@
</thead>
<tbody>
{{range .PackageDescriptor.Metadata.Manifests}}
<tr>
<td><a href="{{$.PackageDescriptor.PackageWebLink}}/{{PathEscape .Digest}}">{{.Digest}}</a></td>
<td>{{.Platform}}</td>
<td>{{FileSize .Size}}</td>
</tr>
{{if ne .Platform "unknown/unknown"}}
<tr>
<td><a class="ui sha label" href="{{$.PackageDescriptor.PackageWebLink}}/{{PathEscape .Digest}}">{{ShortSha256 .Digest}}</a></td>
<td>{{.Platform}}</td>
<td>{{FileSize .Size}}</td>
</tr>
{{end}}
{{end}}
</tbody>
</table>
Expand Down
Loading