Skip to content

[#412] Added the '--source' option and deprecated '--src' as its alias. - #417

Merged
AlexSkrypnyk merged 2 commits into
mainfrom
feature/412-align-option-names
Oct 2, 2026
Merged

AlexSkrypnyk merged 2 commits into
mainfrom
feature/412-align-option-names

Conversation

@AlexSkrypnyk

@AlexSkrypnyk AlexSkrypnyk commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

Closes #412

Summary

git-artifact now takes the source repository directory through --source, and --src becomes a deprecated alias of it. ArtifactCommand::configure() in src/Commands/ArtifactCommand.php registers both options, and the new resolveSourceDir() turns whichever one is set into the absolute path that resolveOptions() stores in $sourceDir. Using --src prints a deprecation notice, and passing --source and --src together stops the run with an error.

--src was the only abbreviated name among the command's options (--branch, --message, --gitignore, --show-changes and the rest are spelled out), and --source didn't exist. The inline check that picked the directory had a gap too: empty($options['src']) is TRUE for the string 0, so --src=0 was dropped and the tool used the root directory instead of a directory named 0. resolveSourceDir() counts a value as set when it's a non-empty string, so a directory named 0 now works through both options.

After merge, --source=<dir> packages <dir>, and --src=<dir> does the same and prints The --src option is deprecated and will be removed in a future major release. Use --source instead. once at normal verbosity. The notice is also logged at notice level, so it lands in the --log file, and at -v and above the logger's console copy shows it again. This doesn't touch --cleanup-pattern, which keeps its singular name because each occurrence names 1 pattern, and it doesn't change the default: with neither option, the root directory is still the source.

Before / After

What each invocation uses as the source directory.

┌─ BEFORE ─────────────────────────────────────────────────────────────────┐
│ Invocation                Source directory used                          │
│                                                                          │
│ (no source option)        <root>                                         │
│ --src=/path/to/src        /path/to/src                                   │
│ --src=0                   <root>, the value is dropped                   │
│ --source=/path/to/src     fails: The "--source" option does not exist.   │
└──────────────────────────────────────────────────────────────────────────┘
                                     │
                                     ▼
┌─ AFTER ──────────────────────────────────────────────────────────────────┐
│ Invocation                Source directory used                          │
│                                                                          │
│ (no source option)        <root>                                         │
│ --source=/path/to/src     /path/to/src                                   │
│ --source=0                <root>/0                                       │
│ --src=/path/to/src        /path/to/src, prints the deprecation notice    │
│ --src=0                   <root>/0, prints the deprecation notice        │
│ --source=a --src=b        fails, the 2 options cannot be used together   │
└──────────────────────────────────────────────────────────────────────────┘

<root> is the --root value, or the current directory when --root isn't set.

Changes

Option

  • src/Commands/ArtifactCommand.php: configure() registers --source with the description --src had, and registers --src as a separate option described as Deprecated alias of --source. Will be removed in a future major release. Symfony Console 7.4 has no long-option aliases and no hidden or deprecated flag for options, so --src stays listed in --help.
  • resolveOptions() calls the new resolveSourceDir() in place of the inline empty($options['src']) check.
  • resolveSourceDir(array $options): string is a protected method that returns the absolute path of the source repository. A value counts as set only when it's a non-empty string, so --source=0 and --src=0 name a directory called 0. With both options set it throws a RuntimeException with The --source and --src options cannot be used together., even when the values match. With --src it writes The --src option is deprecated and will be removed in a future major release. Use --source instead. to the console as a <comment> line, logs the same text at notice level and carries on with the --src value. With neither option it returns fsGetRootDir(), and otherwise fsGetAbsolutePath() of the value.

Docs

  • README.md: the options table gains a --source row, and the --src row now describes it as a deprecated alias of --source.

Tests

  • tests/Unit/Commands/ArtifactCommandTest.php: testResolveSourceDir() runs 11 cases from dataProviderResolveSourceDir(): no options, unset values, an empty source, relative and absolute source and src values, a source and a src named 0, and an empty src next to source and the reverse. Each case asserts the resolved path, the exact console output and the exact logged messages, so the notice shows up only for a non-empty src. testResolveSourceDirConflict() covers 3 cases: different values, identical values and a src named 0. A new createSourceCommand() helper wires the root directory, an output buffer and a Monolog TestHandler.
  • tests/Functional/GeneralTest.php: testSrcDefault() is renamed testSourceDefault(). testSrcDeprecated() pushes an artifact through --src and asserts the notice appears exactly once in the output. testSourceSrcConflict() asserts the failure message when both options are passed. testHelp() asserts that --source=SOURCE and the --src description appear in --help.
  • tests/Functional/FunctionalTestCase.php: runArtifactCommand() passes --source instead of --src, so every functional test goes through the new option.

Migration

  • Replace --src with --source. The value and its meaning stay the same.
  • --src keeps working and prints a deprecation notice until a future major release removes it.
  • Passing --source and --src together fails, even when both carry the same value.
  • --cleanup-pattern keeps its name. A repeatable option names 1 occurrence (like --exclude or git log --author), while $cleanupPatterns holds the collected list.
  • Vortex passes --src in .vortex/tooling/src/vortex-deploy-artifact and pins git-artifact by version and SHA256 checksum, so it keeps running unchanged until it bumps to a release that includes this change. After the bump it should pass --source. Its VORTEX_DEPLOY_ARTIFACT_CLEANUP_PATTERN variable mirrors the singular --cleanup-pattern and needs no change.

Summary by CodeRabbit

  • New Features
    • Added --source as the preferred option for specifying the source repository directory. If omitted, the root directory is used.
    • The existing --src option remains available with a deprecation notice. Supplying nonempty values for both options now results in an error.
  • Documentation
    • Updated the options reference and command help to describe --source, its default, and the deprecated --src alias.

'--src' keeps working and prints a deprecation notice that is also recorded in the '--log' report. Passing both '--source' and '--src' fails, since the run cannot tell which one was meant. '--cleanup-pattern' keeps its singular name: a repeatable option names 1 occurrence, while '$cleanupPatterns' holds the collected list.
@coderabbitai

coderabbitai Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (1)
CLAUDE.md — auto-discovered

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Team

Run ID: fb27c1c6-3541-4d42-877f-df1d16aaad9b

📥 Commits

Reviewing files that changed from the base of the PR and between 6a36245 and 78e62db.

📒 Files selected for processing (5)
  • README.md
  • src/Commands/ArtifactCommand.php
  • tests/Functional/FunctionalTestCase.php
  • tests/Functional/GeneralTest.php
  • tests/Unit/Commands/ArtifactCommandTest.php

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.


📝 Walkthrough

Walkthrough

The command now uses --source to select the source repository directory and retains --src as a deprecated alias. It rejects conflicting nonempty values, logs and displays a deprecation notice when --src is used alone, and defaults to the root directory when neither option has a usable value.

Changes

Source option

Layer / File(s) Summary
Source option and resolution
src/Commands/ArtifactCommand.php, README.md
The command adds --source and keeps --src as a deprecated alias. It rejects both options when they have nonempty values, warns when only --src is used, and resolves the selected path or defaults to the root directory. The README documents the options.
Source option tests
tests/Functional/*, tests/Unit/Commands/ArtifactCommandTest.php
Functional and unit tests cover help output, default behavior, path resolution, deprecation notices, and conflicts. The functional test helper now passes the source path through --source.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Merge Risk: ⚪ Minimal · up to 78e62

No actionable issue remains for this change; it is mergeable after normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 4 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding --source and deprecating --src as its alias.
Linked Issues check ✅ Passed Issue #412 requires a safe migration from --src to --source. The PR adds --source, retains --src as a deprecated alias, emits the deprecation notice, logs the notice, rejects both options when…
Out of Scope Changes check ✅ Passed The changes stay within Issue #412. The README update documents the option migration. The command change implements the migration. The unit and functional tests verify option resolution, deprecation b…
Full details: Docstring Coverage

Explanation

Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 4 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Comment @coderabbitai help to get the list of available commands.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.74%. Comparing base (6a36245) to head (78e62db).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #417      +/-   ##
==========================================
+ Coverage   97.70%   97.74%   +0.04%     
==========================================
  Files           6        6              
  Lines         522      533      +11     
==========================================
+ Hits          510      521      +11     
  Misses         12       12              

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

@AlexSkrypnyk AlexSkrypnyk added the Needs review Pull request needs a review from assigned developers label Oct 2, 2026
@AlexSkrypnyk
AlexSkrypnyk merged commit d1adf55 into main Oct 2, 2026
13 checks passed
@AlexSkrypnyk
AlexSkrypnyk deleted the feature/412-align-option-names branch October 2, 2026 03:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs review Pull request needs a review from assigned developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Align the '--src' and '--cleanup-pattern' option names with the other CLI options

2 participants