From e70afe6c058b0bafc10f2204d0769d1d8874f188 Mon Sep 17 00:00:00 2001 From: Isaac Johnson Date: Tue, 2 Jun 2026 18:42:07 -0500 Subject: [PATCH] add issue lables --- src/api.ts | 104 +++++++++++++++- src/index.ts | 10 ++ src/tui.ts | 339 +++++++++++++++++++++++++++++++++++++++++++++++++-- src/types.ts | 20 ++- 4 files changed, 463 insertions(+), 10 deletions(-) diff --git a/src/api.ts b/src/api.ts index 5b01ca3..a3bfd70 100644 --- a/src/api.ts +++ b/src/api.ts @@ -1,5 +1,5 @@ import axios from 'axios'; -import { Config, Issue, Comment, RepoItem } from './types.js'; +import { Config, Issue, Comment, RepoItem, Label } from './types.js'; /** * Normalizes the Gitea/Forgejo URL by stripping trailing slashes @@ -598,3 +598,105 @@ export async function setIssueAssignees( throw new Error(`Network Error: ${error.message}`); } } + +/** + * Fetches all labels for a specific repository. + */ +export async function fetchLabels(config: Config): Promise { + const client = createAxiosInstance(config); + try { + const response = await client.get(`/repos/${config.owner}/${config.repo}/labels`); + return response.data.map((item: any) => ({ + id: item.id, + name: item.name, + color: item.color, + description: item.description, + exclusive: item.exclusive, + })); + } catch (error: any) { + if (error.response) { + throw new Error(`Failed to fetch labels: ${error.response.data?.message || error.message}`); + } + throw new Error(`Network Error: ${error.message}`); + } +} + +/** + * Creates a new label in the specified repository. + */ +export async function createLabel(config: Config, label: Partial