-
Notifications
You must be signed in to change notification settings - Fork 6
Supporting Gogs integration with existing tools #80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
8a03d19
Add Gogs VCS adapter, tests, Docker service and CI config
Copilot 91907fd
Fix Gogs container health: use /install endpoint bootstrap instead of…
Copilot aaa2cc0
Fix gogs setup
Meldiron 0bc9339
Default brank override support
Meldiron 5569978
Fix gogs implementation
Meldiron 41adce0
Fix more default branch tests
Meldiron af8b3d5
Skip failing gogs tests
Meldiron 3cbc1a1
Fixing more gogs tests
Meldiron 1550e08
Fix more tests
Meldiron 0572958
Merge branch 'copilot/add-forgejo-adapter-and-tests' into copilot/add…
Meldiron e39c8f8
Merge branch 'copilot/add-forgejo-adapter-and-tests' into copilot/add…
Meldiron 79550c2
Enable tags tests
Meldiron e39b5a9
fix: use pre-written app.ini mount for Gogs webhook support
b0e4d0c
updated with suggestions
7c9a22f
updated with suggestions-2
c9f73c1
updated with random string
f9b144a
Merge pull request #82 from jaysomani/fix/gogs-fixes-2
Meldiron 89b654e
Fix tests
Meldiron be1f921
Merge branch 'main' of https://github.com/utopia-php/vcs into fix/gog…
f09164d
fix: resolve testGetPullRequestFiles failures for Forgejo and Gogs
8bec208
removed dead code
90e6a4f
Merge pull request #83 from jaysomani/fix/gogs-final
Meldiron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| <?php | ||
|
|
||
| namespace Utopia\VCS\Adapter\Git; | ||
|
|
||
| class Gogs extends Gitea | ||
| { | ||
| protected string $endpoint = 'http://gogs:3000/api/v1'; | ||
|
Meldiron marked this conversation as resolved.
|
||
|
|
||
| /** | ||
| * Get Adapter Name | ||
| * | ||
| * @return string | ||
| */ | ||
| public function getName(): string | ||
| { | ||
| return 'gogs'; | ||
| } | ||
|
|
||
| protected function getHookType(): string | ||
| { | ||
| return 'gogs'; | ||
| } | ||
|
|
||
| /** | ||
| * Get commit statuses | ||
| * | ||
| * Overrides the Gitea implementation to normalise the 'state' field | ||
| * returned by Gogs into the 'status' field used by the rest of the | ||
| * adapter interface (Gitea changed the JSON key from 'state' to | ||
| * 'status', but Gogs still uses 'state'). | ||
| * | ||
| * @param string $owner Owner of the repository | ||
| * @param string $repositoryName Name of the repository | ||
| * @param string $commitHash SHA of the commit | ||
| * @return array<mixed> List of commit statuses | ||
| */ | ||
| public function getCommitStatuses(string $owner, string $repositoryName, string $commitHash): array | ||
| { | ||
| $statuses = parent::getCommitStatuses($owner, $repositoryName, $commitHash); | ||
|
|
||
| return array_map(function ($status) { | ||
| if (isset($status['state']) && !isset($status['status'])) { | ||
| $status['status'] = $status['state']; | ||
| } | ||
| return $status; | ||
| }, $statuses); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| <?php | ||
|
|
||
| namespace Utopia\Tests\Adapter; | ||
|
|
||
| use Utopia\Cache\Adapter\None; | ||
| use Utopia\Cache\Cache; | ||
| use Utopia\System\System; | ||
| use Utopia\VCS\Adapter\Git; | ||
| use Utopia\VCS\Adapter\Git\Gogs; | ||
|
|
||
| class GogsTest extends GiteaTest | ||
| { | ||
| protected static string $accessToken = ''; | ||
|
|
||
| protected static string $owner = ''; | ||
|
|
||
| protected string $webhookEventHeader = 'X-Gogs-Event'; | ||
| protected string $webhookSignatureHeader = 'X-Gogs-Signature'; | ||
| protected string $avatarDomain = 'gravatar.com'; | ||
|
|
||
| protected function createVCSAdapter(): Git | ||
| { | ||
| return new Gogs(new Cache(new None())); | ||
| } | ||
|
|
||
| public function setUp(): void | ||
| { | ||
| if (empty(static::$accessToken)) { | ||
| $this->setupGogs(); | ||
| } | ||
|
|
||
| $adapter = new Gogs(new Cache(new None())); | ||
| $gogsUrl = System::getEnv('TESTS_GOGS_URL', 'http://gogs:3000') ?? ''; | ||
|
|
||
| $adapter->initializeVariables( | ||
| installationId: '', | ||
| privateKey: '', | ||
| appId: '', | ||
| accessToken: static::$accessToken, | ||
| refreshToken: '' | ||
| ); | ||
| $adapter->setEndpoint($gogsUrl); | ||
| if (empty(static::$owner)) { | ||
| $orgName = 'test-org-' . \uniqid(); | ||
| static::$owner = $adapter->createOrganization($orgName); | ||
| } | ||
|
|
||
| $this->vcsAdapter = $adapter; | ||
| } | ||
|
|
||
| protected function setupGogs(): void | ||
| { | ||
| $tokenFile = '/gogs-data/gogs/token.txt'; | ||
|
|
||
| if (file_exists($tokenFile)) { | ||
| $contents = file_get_contents($tokenFile); | ||
| if ($contents !== false) { | ||
| static::$accessToken = trim($contents); | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| APP_NAME = Gogs | ||
| RUN_MODE = prod | ||
| RUN_USER = git | ||
|
|
||
| [server] | ||
| DOMAIN = gogs | ||
| HTTP_PORT = 3000 | ||
| ROOT_URL = http://gogs:3000/ | ||
| LOCAL_ROOT_URL = http://gogs:3000/ | ||
| DISABLE_SSH = true | ||
|
|
||
| [database] | ||
| DB_TYPE = sqlite3 | ||
| PATH = /data/gogs.db | ||
|
|
||
| [repository] | ||
| ROOT = /data/repositories | ||
|
|
||
| [security] | ||
| INSTALL_LOCK = true | ||
| # SECRET_KEY is intentionally hardcoded — this config is for local/CI testing only. | ||
| SECRET_KEY = verySecretGogsKey1234567890 | ||
|
|
||
| [service] | ||
| REGISTER_EMAIL_CONFIRM = false | ||
| ENABLE_NOTIFY_MAIL = false | ||
| DISABLE_REGISTRATION = false | ||
| ENABLE_CAPTCHA = false | ||
|
|
||
| [webhook] | ||
| DELIVER_TIMEOUT = 10 | ||
| SKIP_TLS_VERIFY = true | ||
|
|
||
| [log] | ||
| MODE = console | ||
| LEVEL = Info |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.