Implement the Gitea extension

The repository was a bare Nova scaffold. This builds it out to match the
capabilities of the official Gitea VS Code extension.

Sidebar sections:
  - Current Branch: pull requests and workflow runs for the checked-out
    branch, with a current/all/pinned branch filter
  - Workflows: runs grouped by workflow file, expanding into jobs, steps,
    and artifacts
  - Pull Requests: open pull requests across repositories, expanding into
    reviews, review comments, and changed files
  - Settings: per-instance connection state, plus repository Actions
    secrets and variables

Commands cover run control (re-run, re-run failed jobs, re-run a job,
cancel), job logs, artifact download/reveal/open, pull request overview,
diff, checkout, creation, merge and close, the full review cycle, and
secret and variable management. Multiple instances are supported, routed
by git remote host, with tokens held per instance in the Keychain.

Nova exposes no webview, diff editor, editor decorations, or extension
status bar, so four features are shaped differently from the VS Code
original: the pull request timeline renders as Markdown, diffs open as
unified .diff documents, review comments are published through an
IssueCollection so they appear in the gutter and the Issues sidebar, and
a failed run posts a notification. OAuth and insecureSkipVerify have no
Nova equivalent and are omitted. README.md records all of this.

Endpoints were taken from Gitea's published swagger.v1.json. Servers
predating the workflow runs API fall back to /actions/tasks.

Tests/ runs the extension's real code under Node against a stubbed Nova
runtime and a canned Gitea instance: 88 checks, no install step and no
network. Images are generated by Tools/make-icons.py.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MQuusXgZC2dzwpJJ1qhtti
This commit is contained in:
2026-08-28 19:55:54 -03:00
co-authored by Claude Opus 5
commit 694609a3cc
58 changed files with 6231 additions and 0 deletions
+172
View File
@@ -0,0 +1,172 @@
//
// Entry point. Builds the store, the four sidebar sections, and the command
// handlers, then keeps the sections in step with the store.
//
const artifacts = require("./controllers/artifacts.js");
const auth = require("./controllers/auth.js");
const browser = require("./controllers/browser.js");
const log = require("./util/log.js");
const logs = require("./controllers/logs.js");
const pullRequests = require("./controllers/pullRequests.js");
const review = require("./controllers/review.js");
const runControl = require("./controllers/runControl.js");
const secretsVariables = require("./controllers/secretsVariables.js");
const selection = require("./controllers/selection.js");
const ui = require("./ui.js");
const { BranchProvider } = require("./views/branchView.js");
const { PullRequestsProvider } = require("./views/pullRequestsView.js");
const { ReviewCommentsController } = require("./controllers/reviewComments.js");
const { SettingsProvider } = require("./views/settingsView.js");
const { Store } = require("./store.js");
const { WorkflowsProvider } = require("./views/workflowsView.js");
const RELOAD_DEBOUNCE_MS = 150;
// Preferences that change which repositories exist, rather than only how they
// are displayed, force a full rediscovery.
const REDISCOVERY_KEYS = ["gitea.baseUrl", "gitea.instances", "gitea.discovery.mode"];
const DISPLAY_KEYS = [
"gitea.maxRunsPerRepo",
"gitea.maxJobsPerRun",
"gitea.branchFilter",
"gitea.branchFilter.custom",
];
let state = null;
function buildSections(store) {
const definitions = [
{ id: "gitea.branch", provider: new BranchProvider(store) },
{ id: "gitea.workflows", provider: new WorkflowsProvider(store) },
{ id: "gitea.pullRequests", provider: new PullRequestsProvider(store) },
{ id: "gitea.settings", provider: new SettingsProvider(store) },
];
return definitions.map((definition) => {
const view = new TreeView(definition.id, { dataProvider: definition.provider });
nova.subscriptions.add(view);
return Object.assign(definition, { view: view });
});
}
/** Rebuilds every section from current store state. */
function reloadSections(sections) {
for (const section of sections) {
section.provider.invalidate();
section.view.reload().catch((error) => log.debug("reload failed", String(error)));
}
}
function registerCommands(store, refresh, sections, reviewComments) {
auth.register(store, refresh);
logs.register(store);
artifacts.register(store);
runControl.register(store, refresh);
pullRequests.register(store, refresh);
review.register(store, refresh, reviewComments);
secretsVariables.register(store);
browser.register();
nova.commands.register("gitea.refresh", async () => {
await refresh({ rediscover: true });
await reviewComments.reload({ force: true });
});
// The per-section refresh buttons all drive the same fetch; they exist so
// each section header has an affordance of its own.
for (const name of ["gitea.refreshRuns", "gitea.refreshPullRequests", "gitea.refreshSettings"]) {
nova.commands.register(name, () => refresh());
}
nova.commands.register("gitea.refreshRepo", async (argument) => {
const repo = await selection.resolveRepo(argument, {
prompt: "Refresh which repository?",
});
if (repo) await store.refreshRepo(repo.key);
});
}
function watchPreferences(refresh) {
const subscriptions = [];
for (const key of REDISCOVERY_KEYS) {
subscriptions.push(nova.config.onDidChange(key, () => refresh({ rediscover: true })));
}
for (const key of DISPLAY_KEYS) {
subscriptions.push(nova.config.onDidChange(key, () => refresh()));
if (nova.workspace && nova.workspace.config) {
subscriptions.push(nova.workspace.config.onDidChange(key, () => refresh()));
}
}
if (nova.workspace && nova.workspace.config) {
subscriptions.push(
nova.workspace.config.onDidChange("gitea.baseUrl", () =>
refresh({ rediscover: true }),
),
);
}
for (const subscription of subscriptions) {
if (subscription) nova.subscriptions.add(subscription);
}
}
exports.activate = function () {
const store = new Store();
const sections = buildSections(store);
const reviewComments = new ReviewCommentsController(store);
selection.configure(
store,
sections.map((section) => section.view),
);
let timer = null;
const scheduleReload = () => {
if (timer) clearTimeout(timer);
timer = setTimeout(() => {
timer = null;
reloadSections(sections);
}, RELOAD_DEBOUNCE_MS);
};
const subscription = store.onDidChange(scheduleReload);
const refresh = (options) =>
store.refresh(options).catch((error) => {
log.error("refresh failed", String(error));
});
registerCommands(store, refresh, sections, reviewComments);
watchPreferences(refresh);
state = {
store: store,
sections: sections,
reviewComments: reviewComments,
subscription: subscription,
cancelReload: () => {
if (timer) clearTimeout(timer);
},
};
log.info(`activated for ${store.router.baseUrls.join(", ") || "no configured instance"}`);
if (!store.router.baseUrls.length) {
ui.warn("Gitea: set an instance URL in the extension preferences to get started.");
return;
}
refresh({ rediscover: true }).then(() => reviewComments.reload({ force: true }));
};
exports.deactivate = function () {
if (!state) return;
state.cancelReload();
state.subscription.dispose();
state.reviewComments.dispose();
state.store.dispose();
state = null;
};