Skip to content

Chore: Improve compatibility for future#81

Merged
Meldiron merged 4 commits intomainfrom
chore-improve-adapter-compatibility
Mar 23, 2026
Merged

Chore: Improve compatibility for future#81
Meldiron merged 4 commits intomainfrom
chore-improve-adapter-compatibility

Conversation

@Meldiron
Copy link
Contributor

No description provided.

@greptile-apps
Copy link

greptile-apps bot commented Mar 23, 2026

Greptile Summary

This chore PR makes three small improvements to the Gitea adapter and its tests: (1) generalizes two exception messages in Gitea.php from naming "Gitea" explicitly to saying "this adapter", (2) centralizes the hardcoded 'main' default-branch string across GiteaTest.php into a single $defaultBranch static property, and (3) removes redundant ?? '' null-coalescing suffixes after System::getEnv() calls that already supply a non-null default (the library's PHPDoc template guarantees a string return when a non-null default is given).

  • The ?? '' removal in GiteaTest.php and Base.php is safe: System::getEnv(string $name, ?string $default = null): ?string with a non-null default is statically annotated to return string (non-nullable), making the coalescing redundant.
  • The $defaultBranch consolidation is a useful refactor, but the property is hardcoded to 'main' and never read from an environment variable or queried from the live Gitea server. If the test infrastructure uses a different default branch, tests will still break — limiting the stated "future compatibility" benefit. Consider reading the value from an env var (e.g. TESTS_GITEA_DEFAULT_BRANCH) at setup time.

Confidence Score: 4/5

  • Safe to merge — all changes are cosmetic or test-only; no production logic is affected beyond two error message strings.
  • The production change (genericized error messages) is trivial. The test changes correctly eliminate redundant null-coalescing and centralize the default branch string. The only concern is that the new $defaultBranch property is still hardcoded to 'main' rather than being environment-driven, which partially undermines the "future compatibility" goal but does not break anything in the current setup.
  • tests/VCS/Adapter/GiteaTest.php — the $defaultBranch property should ideally be populated dynamically if true portability across different Gitea configurations is desired.

Important Files Changed

Filename Overview
src/VCS/Adapter/Git/Gitea.php Two exception messages generalized from "Gitea adapter"/"Gitea" to "this adapter" — trivial cosmetic change with no functional impact.
tests/VCS/Adapter/GiteaTest.php Replaces all hardcoded 'main' branch strings with static::$defaultBranch and removes redundant ?? '' null-coalescing patterns after System::getEnv() calls with non-null defaults. The $defaultBranch property is initialized to 'main' but is never dynamically populated (e.g. from an env var or the server), which limits the stated future-compatibility goal.
tests/VCS/Base.php Removes two redundant ?? '' null-coalescing suffixes after System::getEnv() calls that already supply non-null defaults — safe cleanup.

Reviews (1): Last reviewed commit: "Upgrade deps" | Re-trigger Greptile

@Meldiron Meldiron merged commit 4f5b370 into main Mar 23, 2026
3 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.

1 participant