Found during a full new-user walkthrough (signup -> import -> clone -> push
-> PR -> merge -> issue -> CI -> Ritgram connect -> link repo -> post):
- apps/gitea/custom/options/locale/locale_en-US.ini: the Actions tab's
empty-state ("There are no workflows yet") said "Gitea Actions" twice,
user-facing on every repo with no workflow yet. Now says "Rithub Actions".
- Ritgram's "Continue with Rithub" OAuth login/register buttons requested
scope=read:user only, so GET /forges/gitea/repos 500'd for every connected
user ("token does not have at least one of required scope(s),
required=[read:repository]"). Added read:repository to the authorize URL
in both login/page.tsx and register/page.tsx.
- RepoLinker's "My Repos" tab called githubService.getProjects() only, so a
Rithub-only user's own repos never appeared (My Repos (0) even with a real
repo). Now reads forgeService.list()'s connected forges and merges
forgeService.myRepos() (the existing GET /forges/:forge/repos endpoint,
already implemented backend-side but never called from the web app) with
the GitHub path.
- repositoryRouting.ts's parseRepositoryInput only recognized github.com
URLs, so pasting a real rithub.dev repo URL into the repo picker fell
through to "No repositories match your search." Now recognizes rithub.dev
(and git@rithub.dev: SSH) the same way as github.com.
- repositoryService.ts's searchRepositories() merged the cached DB with a
live GitHub search only; a brand-new, never-cached Rithub repo was
unsearchable by name. Wired in the Gitea adapter's already-built
searchRepos() as a third live source, same pattern as the GitHub one.
Verified live: Actions empty-state now says "Rithub Actions" (0 "Gitea"
text) on a fresh repo; backend tsc --noEmit and web tsc --noEmit both clean.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
92 lines
2.4 KiB
TypeScript
92 lines
2.4 KiB
TypeScript
import api from './api'
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Types (mirror backend ForgeConnectionInfo — see
|
|
// apps/ritgram/backend/src/services/forgeConnectionService.ts)
|
|
// ---------------------------------------------------------------------------
|
|
|
|
export type ForgeKind = 'github' | 'gitea'
|
|
|
|
export interface ForgeConnection {
|
|
forge: ForgeKind
|
|
login: string | null
|
|
forgeUserId: string | null
|
|
baseUrl: string | null
|
|
avatarUrl: string | null
|
|
profileUrl: string | null
|
|
tokenType: string
|
|
connectedAt: string
|
|
updatedAt: string
|
|
}
|
|
|
|
export interface ForgeAvailability {
|
|
forge: ForgeKind
|
|
baseUrl: string
|
|
connected: boolean
|
|
}
|
|
|
|
export interface ForgeListResult {
|
|
connections: ForgeConnection[]
|
|
available: ForgeAvailability[]
|
|
}
|
|
|
|
export interface GiteaProfile {
|
|
id: string
|
|
login: string
|
|
avatarUrl?: string
|
|
htmlUrl?: string
|
|
}
|
|
|
|
// Mirrors backend ForgeRepo (apps/ritgram/backend/src/forge/types.ts).
|
|
export interface ForgeRepo {
|
|
forge: ForgeKind
|
|
id: string
|
|
owner: string
|
|
name: string
|
|
fullName: string
|
|
description: string | null
|
|
stars: number
|
|
forks: number
|
|
language: string | null
|
|
htmlUrl: string
|
|
isPrivate: boolean
|
|
}
|
|
|
|
export const forgeService = {
|
|
/** All of the current user's forge connections (GitHub + Gitea/Rithub). */
|
|
list: async (): Promise<ForgeListResult> => {
|
|
const { data } = await api.get('/forges')
|
|
return data.data
|
|
},
|
|
|
|
/**
|
|
* Connect a Rithub (Gitea) account with a personal access token. The server
|
|
* verifies the token against the instance's `/api/v1/user` before storing it.
|
|
*/
|
|
connectGitea: async (
|
|
token: string,
|
|
baseUrl?: string,
|
|
): Promise<{ connection: ForgeConnection; profile: GiteaProfile }> => {
|
|
const { data } = await api.post('/forges/gitea/connect', {
|
|
token,
|
|
...(baseUrl ? { baseUrl } : {}),
|
|
})
|
|
return data.data
|
|
},
|
|
|
|
/** Disconnect a forge (GitHub or Rithub/Gitea) for the current user. */
|
|
disconnect: async (forge: ForgeKind): Promise<void> => {
|
|
await api.delete(`/forges/${forge}`)
|
|
},
|
|
|
|
/**
|
|
* The current user's own repos on a connected forge (GET /forges/:forge/repos).
|
|
* Throws if that forge isn't connected for this user — callers should check
|
|
* `list()`'s `available`/`connections` first, or catch and fall back.
|
|
*/
|
|
myRepos: async (forge: ForgeKind): Promise<ForgeRepo[]> => {
|
|
const { data } = await api.get(`/forges/${forge}/repos`)
|
|
return data.data
|
|
},
|
|
}
|