Skip to content

feat(restore): select artifacts to restore with --include patterns - #2405

Merged
TerryHowe merged 2 commits into
oras-project:mainfrom
Orion777-cmd:feat/restore-include-patterns
Nov 28, 2026
Merged

TerryHowe merged 2 commits into
oras-project:mainfrom
Orion777-cmd:feat/restore-include-patterns

Conversation

@Orion777-cmd

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:
Implements Mode 2 from #2358: a repeatable --include [<registry>/]<repository>[:<tag>] flag selects the artifacts to restore by their source reference, following the pattern rules in #2367. The target argument is unchanged.

  • Selection runs before mapping, so the collision check only considers selected artifacts, and restoring one of two colliding repositories works.
  • Patterns that match nothing fail before anything is pushed, with suggestions for stored repositories of the same name. Invalid patterns fail when the command starts.
  • The output shows "Selected N of M tag(s)" and lists the skipped repositories, including in --dry-run. Without --include, the output is unchanged.

A few choices the issue left open, happy to change any of them:

  • All unmatched patterns are reported in one error, like the collision error.
  • The collision recommendation mentions --include only when --include is used.
  • Skipped repositories are reported in one line: Skipped N repository(ies) not selected by --include: .... Restored ones are shown by the existing per-tag lines.

Opened as a draft while #2358 is still a draft.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #2367

Please check the following list:

  • Does the affected code have corresponding tests, e.g. unit test, E2E test?
  • Does this change require a documentation update? (help text and examples updated)
  • Does this introduce breaking changes that would require an announcement or bumping the major version?
  • Do all new files have an appropriate license header? (no new files)

Add a repeatable --include [<registry>/]<repository>[:<tag>] flag that
selects the artifacts to restore by their source reference. '*' matches
any sequence of characters within the repository or the tag. The
repository part matches the stored <registry>/<repository> in full or
without its registry, and only a repository part of '*' matches
tag-only entries from earlier backups.

Selection runs before mapping, so the collision check only considers
selected artifacts. Patterns that match nothing fail before anything is
pushed, with suggestions for stored repositories of the same name. The
output reports how many tags are selected and which repositories are
skipped.

Fixes oras-project#2367

Signed-off-by: orion777-cmd <[email protected]>
@codecov

codecov Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.22481% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.62%. Comparing base (ecd186b) to head (d12bfae).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
cmd/oras/internal/display/metadata/text/restore.go 87.50% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2405      +/-   ##
==========================================
+ Coverage   90.55%   90.62%   +0.06%     
==========================================
  Files         158      163       +5     
  Lines        7483     8114     +631     
==========================================
+ Hits         6776     7353     +577     
- Misses        416      444      +28     
- Partials      291      317      +26     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TerryHowe
TerryHowe marked this pull request as ready for review November 28, 2026 13:40
Comment thread cmd/oras/root/restore.go Resolved

@TerryHowe TerryHowe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@TerryHowe
TerryHowe merged commit eea615b into oras-project:main Nov 28, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Draft] feat(restore): select artifacts to restore with --include patterns

2 participants