add Digest to ReleaseAsset struct

Signed-off-by: Brian DeHamer <bdehamer@github.com>
This commit is contained in:
Brian DeHamer 2025-05-27 09:23:20 -07:00
parent 4fcd6bf6eb
commit bc93b54137
No known key found for this signature in database
3 changed files with 13 additions and 6 deletions

View file

@ -71,6 +71,7 @@ type ReleaseAsset struct {
Name string
Label string
Size int64
Digest *string
State string
APIURL string `json:"url"`
@ -107,6 +108,7 @@ func (rel *Release) ExportData(fields []string) map[string]interface{} {
"name": a.Name,
"label": a.Label,
"size": a.Size,
"digest": a.Digest,
"state": a.State,
"createdAt": a.CreatedAt,
"updatedAt": a.UpdatedAt,

View file

@ -158,6 +158,11 @@ func renderReleaseTTY(io *iostreams.IOStreams, release *shared.Release) error {
table := tableprinter.New(io, tableprinter.NoHeader)
for _, a := range release.Assets {
table.AddField(a.Name)
if a.Digest == nil {
table.AddField("")
} else {
table.AddField(*a.Digest)
}
table.AddField(humanFileSize(a.Size))
table.EndRow()
}

View file

@ -150,8 +150,8 @@ func Test_viewRun(t *testing.T) {
Assets
windows.zip 12 B
linux.tgz 34 B
windows.zip sha256:deadc0de 12 B
linux.tgz 34 B
View on GitHub: https://github.com/OWNER/REPO/releases/tags/v1.2.3
`),
@ -174,8 +174,8 @@ func Test_viewRun(t *testing.T) {
Assets
windows.zip 12 B
linux.tgz 34 B
windows.zip sha256:deadc0de 12 B
linux.tgz 34 B
View on GitHub: https://github.com/OWNER/REPO/releases/tags/v1.2.3
`),
@ -248,8 +248,8 @@ func Test_viewRun(t *testing.T) {
"published_at": "%[1]s",
"html_url": "https://github.com/OWNER/REPO/releases/tags/v1.2.3",
"assets": [
{ "name": "windows.zip", "size": 12 },
{ "name": "linux.tgz", "size": 34 }
{ "name": "windows.zip", "size": 12, "digest": "sha256:deadc0de" },
{ "name": "linux.tgz", "size": 34, "digest": null }
]
}`, tt.releasedAt.Format(time.RFC3339), tt.releaseBody))