Skip to content

feat(build): add --branch option for partial updates of a single branch - #1231

Merged
alcohol merged 8 commits into
composer:mainfrom
immobiliare:feat/branch-filter-option
Oct 26, 2026
Merged

alcohol merged 8 commits into
composer:mainfrom
immobiliare:feat/branch-filter-option

Conversation

@Trusted97

Copy link
Copy Markdown
Contributor

Adds a --branch option to the build command that filters selected
packages to only versions matching a given branch name (e.g. dev-main)
or version constraint (e.g. 1.x). When combined with a package filter,
other packages and non-matching versions are preserved from the existing
repository dump, enabling fast partial rebuilds on branch push.

php bin/satis build --branch main satis.json web/ acme/pkg
php bin/satis build --branch 1.x satis.json web/ acme/pkg

Validation ensures --branch requires at least one package and is mutually
exclusive with --repository-url.

@alcohol

alcohol commented Oct 26, 2026

Copy link
Copy Markdown
Member

Just wondering, why did you change the visibility of a range of methods from private to protected?

@Trusted97

Copy link
Copy Markdown
Contributor Author

@alcohol

That was a leftover from an earlier approach where I tried a separate update-branch command extending BuildCommand and needed those methods accessible.
In the final implementation i've put everything directly into BuildCommand via --branch, subclass access isn't needed.
I've reverted all to private in the follow-up commit.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Cleaning discards the branch filter, and merging can restore stale target versions from the existing dump.

2 open issues
What changed in this PR

Adds --branch to Satis builds to support targeted branch or version-range updates while preserving existing repository content outside the requested scope.

Changes:

  • Adds branch matching and validation requiring package names and rejecting --repository-url.
  • Adjusts partial-update merging to retain existing versions.
  • Documents usage and adds command tests for filtering, preservation, and validation.
File Description
tests/​Console/​Command/​BuildCommandTest.php Adds branch-update and option-validation tests.
src/​Console/​Command/​BuildCommand.php Implements the option, version matching, and merge changes.
docs/​using.md Documents branch and version-range update commands.

Review effort: Balanced

Comment thread src/Console/Command/BuildCommand.php Resolved
Comment thread src/Console/Command/BuildCommand.php Resolved

@JellyBellyDev JellyBellyDev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great job!
I'd maybe add a few tests with some weird branch names, like ones with special characters, to cover more edge cases, e.g. "feat/super-power-feature", "3.x" or "my.new-feat-&-power".
What do you think?

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The preservation tests need version-level metadata assertions to verify that targeted versions update while non-matching versions remain unchanged.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Verify only the requested branch reference changes

tests/​Console/​Command/​BuildCommandTest.php:1256

This assertion checks only the package name, so the test still passes if dev-feature-x or 1.0.0 is deleted or unexpectedly refreshed. Because both builds use identical metadata, it also cannot show that the requested branch was updated. Change the versions' source references between builds and inspect the generated version metadata, asserting that dev-main has the new reference while the other versions retain their old references.

2 resolved since last review

Review effort: Balanced

@alcohol
alcohol merged commit 9a4cdfe into composer:main Oct 26, 2026
19 checks passed
@alcohol

alcohol commented Oct 26, 2026

Copy link
Copy Markdown
Member

Thank you for contributing 🥳

@Trusted97
Trusted97 deleted the feat/branch-filter-option branch October 29, 2026 09:37
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.

4 participants