Skip to content

Commit

Permalink
resolve comment
Browse files Browse the repository at this point in the history
Signed-off-by: Billy Zha <[email protected]>
  • Loading branch information
qweeah committed Dec 13, 2024
1 parent 6f1c3cd commit d24fb9a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cmd/oras/internal/display/metadata/text/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@ func NewAttachHandler(printer *output.Printer) metadata.AttachHandler {

// OnAttached implements AttachHandler.
func (ah *AttachHandler) OnAttached(target *option.Target, root ocispec.Descriptor, subject ocispec.Descriptor) {
ah.subjectRefByDigest = target.AnnotatedReference()
if !strings.HasSuffix(target.RawReference, subject.Digest.String()) {
ah.root = root
if strings.HasSuffix(target.RawReference, subject.Digest.String()) {
ah.subjectRefByDigest = target.AnnotatedReference()

Check warning on line 46 in cmd/oras/internal/display/metadata/text/attach.go

View check run for this annotation

Codecov / codecov/patch

cmd/oras/internal/display/metadata/text/attach.go#L46

Added line #L46 was not covered by tests
} else {
// use subject digest instead of tag
newTarget := *target
newTarget.RawReference = fmt.Sprintf("%s@%s", target.Path, subject.Digest)
ah.subjectRefByDigest = newTarget.AnnotatedReference()
}
ah.root = root
}

// Render is called when the attach command is complete.
Expand Down

0 comments on commit d24fb9a

Please sign in to comment.