support paged launcher history queries
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2026-07-07 09:20:18 +09:00
parent b3dbcfd87f
commit 0951283c8b
6 changed files with 98 additions and 6 deletions
+38
View File
@@ -97,9 +97,16 @@ export class GiteaService {
async listCommits(owner: string, repo: string, query: ListGiteaCommitsQuery) {
const params = new URLSearchParams();
params.set('limit', query.limit ?? '20');
params.set('page', query.page ?? '1');
if (query.sha) {
params.set('sha', query.sha);
}
if (query.since) {
params.set('since', query.since);
}
if (query.until) {
params.set('until', query.until);
}
const commits = await this.request<unknown[]>(
`/api/v1/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/commits?${params.toString()}`,
@@ -108,6 +115,17 @@ export class GiteaService {
return { commits };
}
async getCommitDiff(owner: string, repo: string, sha: string) {
const encodedOwner = encodeURIComponent(owner);
const encodedRepo = encodeURIComponent(repo);
const encodedSha = encodeURIComponent(sha);
const diff = await this.requestText(
`/${encodedOwner}/${encodedRepo}/commit/${encodedSha}.diff`,
);
return { diff };
}
async listReleases(owner: string, repo: string) {
const releases = await this.request<unknown[]>(
`/api/v1/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/releases`,
@@ -255,6 +273,26 @@ export class GiteaService {
return (await response.json()) as T;
}
private async requestText(path: string): Promise<string> {
const response = await fetch(`${this.baseUrl}${path}`, {
headers: {
Accept: 'text/plain',
...(this.token ? { Authorization: `token ${this.token}` } : {}),
},
});
if (!response.ok) {
const message = await response.text();
throw new BadGatewayException({
message: 'Gitea API 요청이 실패했습니다.',
status: response.status,
detail: message,
});
}
return response.text();
}
private assertToken() {
if (!this.token) {
throw new UnauthorizedException(