@@ -20,6 +20,7 @@ class GitRepositoryService
2020 final public const SERVICE_BITBUCKET_SERVER = 'bitbucket-server ' ;
2121 final public const SERVICE_GITHUB = 'github ' ;
2222 final public const SERVICE_GITLAB = 'gitlab ' ;
23+ final public const SERVICE_FORGEJO = 'forgejo ' ;
2324
2425 final public const SERVICE_NAMES = [
2526 self ::SERVICE_GITHUB => 'GitHub ' ,
@@ -32,6 +33,7 @@ class GitRepositoryService
3233 self ::SERVICE_BITBUCKET_SERVER => '{baseUrl}/projects/{project}/repos/{package}/raw/composer.json?at=refs%2F{type}%2F{version} ' ,
3334 self ::SERVICE_GITLAB => '{baseUrl}/raw/{version}/composer.json ' ,
3435 self ::SERVICE_GITHUB => 'https://raw.githubusercontent.com/{repoName}/{version}/composer.json ' ,
36+ self ::SERVICE_FORGEJO => '{baseUrl}/raw/{type}/{version}/composer.json ' ,
3537 ];
3638 protected array $ allowedBranches = ['master ' , 'main ' , 'documentation-draft ' ];
3739
@@ -41,6 +43,7 @@ public function resolvePublicComposerJsonUrlByPayload(\stdClass $payload, string
4143 self ::SERVICE_BITBUCKET_SERVER , self ::SERVICE_BITBUCKET_CLOUD => $ this ->getPublicComposerUrlForBitbucket ($ payload ),
4244 self ::SERVICE_GITHUB => $ this ->getPublicComposerUrlForGithub ($ payload ),
4345 self ::SERVICE_GITLAB => $ this ->getPublicComposerUrlForGitlab ($ payload ),
46+ self ::SERVICE_FORGEJO => $ this ->getPublicComposerUrlForForgejo ($ payload ),
4447 default => '' ,
4548 };
4649 }
@@ -139,6 +142,18 @@ protected function getPublicComposerUrlForGitlab(\stdClass $payload): string
139142 ]);
140143 }
141144
145+ protected function getPublicComposerUrlForForgejo (\stdClass $ payload ): string
146+ {
147+ $ ref = (string ) $ payload ->ref ;
148+ $ version = str_replace (['refs/tags/ ' , 'refs/heads/ ' ], '' , $ ref );
149+
150+ return $ this ->getParsedUrl ($ this ->composerJsonUrlFormat [self ::SERVICE_FORGEJO ], [
151+ '{baseUrl} ' => (string ) $ payload ->repository ->html_url ,
152+ '{type} ' => str_starts_with ($ ref , 'refs/tags/ ' ) ? 'tag ' : 'branch ' ,
153+ '{version} ' => $ version ,
154+ ]);
155+ }
156+
142157 protected function getPublicComposerUrlForGithub (\stdClass $ payload ): string
143158 {
144159 $ version = str_replace (['refs/tags/ ' , 'refs/heads/ ' ], '' , (string ) $ payload ->ref );
0 commit comments