⭐️⭐️⭐️ Open-source, self-hosted alternative to Linear and Plane. Project management and issue tracking where teams and AI agents work side by side to plan and ship products.
TypeScript agenticagileai-agentsbug-reportingbug-trackerganttissue-trackerjirajira-alternativekanbanlinearlinear-alternativeopen-sourceproduct-managementproject-managementroadmapself-hostedsprint-planningteam-collaborationtrello-alternative
fix(api): link Gitea and Forgejo branches under /src/branch/ (#611)
Croffe579cd62e6de
diff --git a/apps/api/src/modules/git/__tests__/unit/providers.test.ts b/apps/api/src/modules/git/__tests__/unit/providers.test.tsindex e8300362..23df618b 100644--- a/apps/api/src/modules/git/__tests__/unit/providers.test.ts+++ b/apps/api/src/modules/git/__tests__/unit/providers.test.ts@@ -162,6 +162,25 @@ describe('repository provider events', () => {});});+ it('links a Forgejo branch under /src/branch/', () => {+ const headers = { 'x-forgejo-event': 'create', 'x-gitea-event': 'create' };+ const provider = detectProvider(headers)!;+ expect(+ provider.parse(+ {+ ref: 'feature/MKT-42-summary',+ ref_type: 'branch',+ sha: 'abc123',+ repository: { full_name: 'acme/site', html_url: 'https://git.example/acme/site' },+ },+ headers,+ ),+ ).toMatchObject({+ kind: 'branch',+ url: 'https://git.example/acme/site/src/branch/feature/MKT-42-summary',+ });+ });+it('normalizes a new GitLab branch push', () => {const headers = { 'x-gitlab-event': 'Push Hook' };const provider = detectProvider(headers)!;diff --git a/apps/api/src/modules/git/providers.ts b/apps/api/src/modules/git/providers.tsindex 36aedd48..d515c7ee 100644--- a/apps/api/src/modules/git/providers.ts+++ b/apps/api/src/modules/git/providers.ts@@ -227,12 +227,14 @@ function parseGithubBranch(payload: unknown, headers: DeliveryHeaders): BranchEvif (!['create', 'delete'].includes(event ?? '') || value.ref_type !== 'branch') return null;if (!value.ref || !value.repository?.full_name) return null;const base = httpUrl(value.repository.html_url);+ // Gitea and Forgejo serve a branch under /src/branch/; Forgejo has no /tree/ route.+ const branchPath = gitea.matches(headers) ? 'src/branch' : 'tree';return {kind: 'branch',action: event === 'delete' ? 'deleted' : 'created',repo: value.repository.full_name,branch: value.ref,- url: base ? `${base}/tree/${refPath(value.ref)}` : null,+ url: base ? `${base}/${branchPath}/${refPath(value.ref)}` : null,headSha: event === 'delete' ? null : (value.sha ?? null),defaultBranch: value.repository.default_branch ?? value.master_branch ?? null,};