Skip to content

fix(vcs): strip only the leading branch namespace from push refs - #15035

Merged
ChiragAgg5k merged 1 commit into
mainfrom
fix/vcs-branch-refs
Oct 27, 2026
Merged

ChiragAgg5k merged 1 commit into
mainfrom
fix/vcs-branch-refs

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

str_replace removed every occurrence of refs/heads/, so a branch whose name itself contains that prefix lost part of its name. Push events now remove just the leading namespace, so branch names reach deployment rules unchanged.

Lint, PHPStan and the touched unit tests passed locally before rebasing on main; e2e runs in CI.

Related: appwrite-labs/cloud#6673

str_replace removed every occurrence of refs/heads/, so a branch whose name itself contains that prefix lost part of its name. Push events now remove just the leading namespace, so branch names reach deployment rules unchanged.
@luxor-code-review

luxor-code-review Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Review complete. No issues found — approved ✅.


This PR replaces str_replace('refs/heads/', '', $ref) with a strict str_starts_with/substr prefix strip in the GitHub, GitLab, and Gitea adapters, so a branch literally named like the ref prefix (e.g. refs/heads/foo) round-trips correctly instead of being mangled. The ref payload value is now type-checked as a string, which also resolves the phpstan mixed warning reflected in the updated phpstan-baseline.neon counts. A new shared test in packages/vcs/tests/Base.php exercises all three adapters with such a branch name and asserts the extracted branch matches.

Files Change
packages/vcs/src/Adapter/Git/GitHub.php, GitLab.php, Gitea.php Replace str_replace with str_starts_with + substr prefix removal and add a string type check on ref
packages/vcs/phpstan-baseline.neon Update baseline counts after the mixed warning is fixed
packages/vcs/tests/Base.php Add a shared regression test covering branch names equal to or containing refs/heads/ across all three adapters

Reviewed commit: 4f65292

@ChiragAgg5k ChiragAgg5k self-assigned this Oct 27, 2026
@ghost

ghost commented Oct 27, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The changed normalization preserves nested branch names while continuing to remove the provider namespace from ordinary push refs.

Push webhook parsing now removes refs/heads/ only when it appears at the beginning of a string ref for GitHub, GitLab, and Gitea-compatible providers. The shared VCS adapter tests include a branch name that itself begins with that namespace.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 5
File Change
packages/vcs/src/Adapter/Git/GitHub.php Normalize push refs by stripping only a leading heads namespace.
packages/vcs/src/Adapter/Git/GitLab.php Normalize push refs by stripping only a leading heads namespace.
packages/vcs/src/Adapter/Git/Gitea.php Normalize push refs by stripping only a leading heads namespace.
packages/vcs/tests/Base.php Add shared regression coverage for branch names beginning with refs/heads/.
packages/vcs/phpstan-baseline.neon Remove baseline entries made obsolete by the ref type checks.

Reviewed 4f65292 · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost 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.

🟢 Tier S · Looks good to merge. Summary

@github-actions

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

6 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (3)
  • php.appwrite.secret-compare-timing (1)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

@github-actions

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/vcs-branch-refs (after).

Metric Before After Change
🚀 Requests/sec 148.92 195.89 🟢 +31.5%
⏱️ Latency P50 114.19 ms 87.99 ms 🟢 -22.9%
⏱️ Latency P95 271.19 ms 207.61 ms 🟢 -23.4%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 87.99 207.61 12,540 195.89 -63.58
Account 160.35 312.47 660 11.04 -88.73
TablesDB 84.75 155.77 6,820 109.71 -57.14
Storage 81.81 198.18 3,300 54.69 -43.38
Functions 125.76 254.7 1,760 29.89 -60.74

Top API waits (after)

API request Max wait (ms)
functions.create 525.53
account.name.update 488.98
account.prefs.update 441.76
functions.variables.update 428.95
functions.variables.create 400.99

@ChiragAgg5k
ChiragAgg5k merged commit 5f13bdd into main Oct 27, 2026
39 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the fix/vcs-branch-refs branch October 27, 2026 19:20
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.

1 participant