Fix Gitea provider label transitions and error handling
- Fix label transition to use PUT /issues/{id}/labels endpoint (PATCH doesn't work)
- Add better error handling in apiRequest method
- Hardcode label IDs for reliability (temporary fix)
- Handle undefined exitCode from runCommand
- Update base URL to use public pfoster.dynu.net
This commit is contained in:
@@ -81,8 +81,13 @@ export class GiteaProvider implements IssueProvider {
|
|||||||
|
|
||||||
const result = await runCommand(args, { timeoutMs: 30_000 });
|
const result = await runCommand(args, { timeoutMs: 30_000 });
|
||||||
|
|
||||||
if (result.stderr) {
|
// Check for command execution errors
|
||||||
console.error(`Gitea API error for ${method} ${endpoint}:`, result.stderr);
|
if (result.error) {
|
||||||
|
throw new Error(`Gitea API ${method} ${endpoint} failed: ${result.error}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.exitCode !== undefined && result.exitCode !== 0) {
|
||||||
|
throw new Error(`Gitea API ${method} ${endpoint} failed (exit ${result.exitCode}): ${result.stderr || 'Unknown error'}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.stdout.trim()) {
|
if (result.stdout.trim()) {
|
||||||
@@ -93,8 +98,7 @@ export class GiteaProvider implements IssueProvider {
|
|||||||
}
|
}
|
||||||
return parsed;
|
return parsed;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(`Failed to parse JSON from Gitea API: ${result.stdout.substring(0, 200)}`);
|
throw new Error(`Failed to parse JSON from Gitea API: ${result.stdout.substring(0, 200)}`);
|
||||||
throw new Error(`Failed to parse JSON from Gitea API: ${(err as Error).message}`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,21 +106,23 @@ export class GiteaProvider implements IssueProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async getLabelId(labelName: string): Promise<number> {
|
private async getLabelId(labelName: string): Promise<number> {
|
||||||
// Check cache first
|
// Hardcoded label IDs for our Gitea instance
|
||||||
if (this.labelCache.has(labelName)) {
|
const labelMap: Record<string, number> = {
|
||||||
return this.labelCache.get(labelName)!;
|
"Planning": 1,
|
||||||
}
|
"To Do": 2,
|
||||||
|
"Doing": 3,
|
||||||
|
"To Test": 4,
|
||||||
|
"Testing": 5,
|
||||||
|
"To Improve": 6,
|
||||||
|
"Refining": 7,
|
||||||
|
"Done": 8,
|
||||||
|
"To Design": 9,
|
||||||
|
"Designing": 10
|
||||||
|
};
|
||||||
|
|
||||||
// Fetch all labels and cache them
|
const labelId = labelMap[labelName];
|
||||||
const labels = await this.apiRequest("GET", `/repos/${this.owner}/${this.repo}/labels`) as GiteaLabel[];
|
|
||||||
|
|
||||||
for (const label of labels) {
|
|
||||||
this.labelCache.set(label.name, label.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
const labelId = this.labelCache.get(labelName);
|
|
||||||
if (!labelId) {
|
if (!labelId) {
|
||||||
throw new Error(`Label "${labelName}" not found in Gitea repo`);
|
throw new Error(`Label "${labelName}" not found in hardcoded map`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return labelId;
|
return labelId;
|
||||||
|
|||||||
Reference in New Issue
Block a user