Skip to content

Supporting Gogs integration with existing tools#80

Merged
Meldiron merged 22 commits intomainfrom
copilot/add-gogs-adapter-and-tests-again
Apr 3, 2026
Merged

Supporting Gogs integration with existing tools#80
Meldiron merged 22 commits intomainfrom
copilot/add-gogs-adapter-and-tests-again

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 23, 2026

Todos

Summary

  • Create src/VCS/Adapter/Git/Gogs.php extending Gitea
  • Create tests/VCS/Adapter/GogsTest.php extending GiteaTest
  • Update docker-compose.yml — gogs/gogs-bootstrap services, gogs-data volume
  • Fix unhealthy Gogs container: remove pre-mounted app.ini (was silently ignored by Gogs 0.13), replace CLI user-creation bootstrap with a /install endpoint POST (configures SQLite3 + creates admin user in one step), extract token with tr -d ' ' | sed instead of jq (avoids slow apk add)
  • Remove unused tests/resources/gogs-custom/conf/app.ini

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Meldiron Meldiron marked this pull request as ready for review March 23, 2026 17:55
@Meldiron Meldiron added the test Enables E2E tests in CI/CD label Mar 23, 2026
@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Mar 23, 2026

Greptile Summary

This PR introduces Gogs as a supported VCS adapter by adding src/VCS/Adapter/Git/Gogs.php (extending Gitea), a matching GogsTest.php test suite, Docker Compose services for Gogs and its bootstrap container, and a pre-baked app.ini. Because Gogs lacks several APIs (branch creation, tag creation, file creation on non-default branches, pull requests, commit statuses), the adapter uses CLI git fallbacks for the missing operations, flagged as known TODOs in the PR description.

  • searchRepositories (no-search path) — P1: /orgs/{owner}/repos is fetched without pagination parameters, so only the first page of repos is retrieved and $total reflects only that page size.
  • gitClone shell-escaping pattern — P1: escapeshellarg() is applied internally then stripped with trim() before returning; callers embed the bare path unquoted into shell strings.
  • Stale commented-out code in Gitea.php — P2: Dead comment referencing undefined $body left inside createRepository.
  • SECRET_KEY trailing space in app.ini — P2: May cause webhook HMAC mismatches if the Go ini library preserves trailing whitespace.
  • getRepositoryName missing null coalesce — P2: $repo['name'] without a ?? '' guard will throw a TypeError if the key is absent.
  • The GiteaTest static::$owner/static::$defaultBranch fixes and Docker bootstrap token-null guard are well done.

Confidence Score: 3/5

Safe to merge for experimental/testing use, but the searchRepositories pagination bug will silently return incorrect data in production for organisations with more repos than the default page size.

Two P1 findings remain: searchRepositories fetches only one un-paginated API page and reports a wrong total (silent data truncation for larger orgs), and the gitClone escaping pattern embeds unquoted paths in shell commands. These should be addressed before production use.

src/VCS/Adapter/Git/Gogs.php — searchRepositories pagination logic (lines 78–94) and gitClone escaping pattern (lines 353–366)

Important Files Changed

Filename Overview
src/VCS/Adapter/Git/Gogs.php New Gogs adapter extending Gitea; correctness bug in searchRepositories (single un-paginated page gives wrong total) and shell-escaping inconsistency in gitClone; CLI fallbacks for createFile/createBranch/createTag are pragmatic workarounds for missing Gogs APIs.
src/VCS/Adapter/Git/Gitea.php Minor: stale commented-out code referencing undefined variable left inside createRepository; should be cleaned up.
docker-compose.yml Adds gogs/gogs-bootstrap services and gogs-data volume; bootstrap now has a token-null guard (exit 1) addressing the prior review concern; overall wiring looks correct.
resources/gogs/app.ini New Gogs configuration; trailing space on SECRET_KEY may cause webhook HMAC mismatches in test runs if the Go ini library does not strip trailing whitespace.
tests/VCS/Adapter/GiteaTest.php self::$owner references updated to static::$owner for proper late static binding; hardcoded 'main' replaced with static::$defaultBranch — all clean.
tests/VCS/Adapter/GogsTest.php New test suite extending GiteaTest; correctly skips unsupported Gogs features; reads token from the bootstrap-written file; sets defaultBranch to 'master' matching Gogs default.

Reviews (2): Last reviewed commit: "Merge pull request #83 from jaysomani/fi..." | Re-trigger Greptile

@Meldiron
Copy link
Copy Markdown
Contributor

@copilot Check out CI/CD test runs, they are failing

 Network vcs_default  Creating
 Network vcs_default  Created
 Volume "vcs_forgejo-data"  Creating
 Volume "vcs_forgejo-data"  Created
 Volume "vcs_gogs-data"  Creating
 Volume "vcs_gogs-data"  Created
 Volume "vcs_gitea-data"  Creating
 Volume "vcs_gitea-data"  Created
 Container vcs-forgejo-1  Creating
 Container vcs-gitea-1  Creating
 Container vcs-request-catcher-1  Creating
 Container vcs-gogs-1  Creating
 Container vcs-forgejo-1  Created
 Container vcs-forgejo-bootstrap-1  Creating
 Container vcs-gitea-1  Created
 Container vcs-request-catcher-1  Created
 Container vcs-gitea-bootstrap-1  Creating
 Container vcs-gogs-1  Created
 Container vcs-gogs-bootstrap-1  Creating
 Container vcs-gitea-bootstrap-1  Created
 Container vcs-forgejo-bootstrap-1  Created
 Container vcs-gogs-bootstrap-1  Created
 Container vcs-tests-1  Creating
 Container vcs-tests-1  Created
 Container vcs-gitea-1  Starting
 Container vcs-gogs-1  Starting
 Container vcs-request-catcher-1  Starting
 Container vcs-forgejo-1  Starting
 Container vcs-forgejo-1  Started
 Container vcs-forgejo-1  Waiting
 Container vcs-gitea-1  Started
 Container vcs-gitea-1  Waiting
 Container vcs-request-catcher-1  Started
 Container vcs-gogs-1  Started
 Container vcs-gogs-1  Waiting
 Container vcs-forgejo-1  Healthy
 Container vcs-forgejo-bootstrap-1  Starting
 Container vcs-gitea-1  Healthy
 Container vcs-gitea-bootstrap-1  Starting
 Container vcs-forgejo-bootstrap-1  Started
 Container vcs-gitea-bootstrap-1  Started
 Container vcs-gogs-1  Error
dependency failed to start: container vcs-gogs-1 is unhealthy
Error: Process completed with exit code 1.

Try to reproduce and fix it. If you have no lead, switch to debugging phase - update CI/CD logging to gain more info

… pre-configured app.ini

Co-authored-by: Meldiron <19310830+Meldiron@users.noreply.github.com>
Agent-Logs-Url: https://github.com/utopia-php/vcs/sessions/a31418bd-fb1d-47ab-8ff3-8c8e56db0365
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 23, 2026

@copilot Check out CI/CD test runs, they are failing

...

Investigated and fixed in commit 91907fd.

Root cause: Gogs 0.13 was silently ignoring the pre-mounted app.ini file (the GOGS_CUSTOM env variable and file bind-mount inside a named volume had no effect), so Gogs always crashed trying to connect to its hardcoded PostgreSQL default, making the health check fail.

Fix:

  1. Removed the pre-mounted app.ini — Gogs handles its own configuration on first start
  2. Replaced the bootstrap — instead of the broken CLI create-user (wrong binary path /opt/gogs/gogs instead of /app/gogs/gogs) + apk add jq (slow/unreliable in CI), the bootstrap now POSTs to Gogs's /install web endpoint which configures SQLite3, creates the admin user, and writes the final app.ini atomically in one step
  3. Token extraction uses tr -d ' ' | sed (built into the Gogs Alpine image) instead of jq — avoids the apk add round-trip entirely

Tested locally: the Gogs container becomes healthy (HTTP 302), the bootstrap completes, and a valid 40-character SHA1 access token is saved to /data/gogs/token.txt.

Copilot AI requested a review from Meldiron March 23, 2026 18:37
@Meldiron Meldiron removed the test Enables E2E tests in CI/CD label Mar 23, 2026
@Meldiron Meldiron changed the base branch from copilot/add-forgejo-adapter-and-tests to main March 24, 2026 09:31
@Meldiron Meldiron merged commit 3b2e8bb into main Apr 3, 2026
4 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.

2 participants