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
118 lines
4.0 KiB
JavaScript
118 lines
4.0 KiB
JavaScript
//
|
|
// "Current Branch" section: the pull requests and workflow runs that belong to
|
|
// the branch checked out in the workspace (or to the configured branch filter).
|
|
//
|
|
|
|
const builders = require("./builders.js");
|
|
const config = require("../util/config.js");
|
|
const nodes = require("./nodes.js");
|
|
const { NodeProvider } = require("./provider.js");
|
|
|
|
const { node, message, errorNode } = nodes;
|
|
|
|
class BranchProvider extends NodeProvider {
|
|
roots() {
|
|
const store = this.store;
|
|
|
|
if (!store.router.baseUrls.length) {
|
|
return [message("No Gitea instance configured. Open the extension preferences.")];
|
|
}
|
|
if (!store.hasAnyToken) {
|
|
return [message("No token stored. Run “Gitea → Set Token…” to sign in.")];
|
|
}
|
|
if (!store.repos.length) {
|
|
return [
|
|
message(
|
|
store.loading
|
|
? "Loading…"
|
|
: "No repository in this workspace points at a configured Gitea instance.",
|
|
),
|
|
];
|
|
}
|
|
|
|
const filter = config.branchFilter();
|
|
const sections = store.repos.map((repo) => this.repoSection(repo, filter));
|
|
return store.repos.length === 1 ? sections[0].children : sections;
|
|
}
|
|
|
|
repoSection(repo, filter) {
|
|
const branch = this.store.branchFor(repo);
|
|
const label =
|
|
filter.mode === "all"
|
|
? "all branches"
|
|
: branch || "no branch (detached HEAD)";
|
|
|
|
return node("repo", repo.fullName, {
|
|
identifier: `branch-repo-${repo.key}`,
|
|
description: label,
|
|
tooltip: `${repo.htmlUrl}\nBranch filter: ${label}`,
|
|
contextValue: "repo",
|
|
repo: repo,
|
|
data: { repoKey: repo.key },
|
|
expanded: true,
|
|
children: [this.pullRequestsFolder(repo, branch), this.runsFolder(repo, branch)],
|
|
});
|
|
}
|
|
|
|
pullRequestsFolder(repo, branch) {
|
|
const { items, error } = this.store.pullRequestsFor(repo.key);
|
|
const matching = branch
|
|
? items.filter((pull) => pull.head && pull.head.ref === branch)
|
|
: items;
|
|
|
|
let children;
|
|
if (error) children = [errorNode(error)];
|
|
else if (!matching.length) {
|
|
children = [
|
|
message(
|
|
branch
|
|
? `No open pull request from ${branch}.`
|
|
: "No open pull requests.",
|
|
),
|
|
];
|
|
} else {
|
|
children = matching.map((pull) => builders.pullRequestNode(this.store, repo, pull));
|
|
}
|
|
|
|
return node("prFolder", "Pull Requests", {
|
|
identifier: `branch-prs-${repo.key}`,
|
|
description: matching.length ? String(matching.length) : "",
|
|
contextValue: "prFolder",
|
|
repo: repo,
|
|
expanded: true,
|
|
children: children,
|
|
});
|
|
}
|
|
|
|
runsFolder(repo, branch) {
|
|
const { runs, error, legacy } = this.store.runsFor(repo.key);
|
|
const matching = branch ? runs.filter((run) => run.head_branch === branch) : runs;
|
|
|
|
let children;
|
|
if (error) children = [errorNode(error)];
|
|
else if (!matching.length) {
|
|
children = [
|
|
message(branch ? `No runs for ${branch}.` : "No workflow runs."),
|
|
];
|
|
} else {
|
|
children = matching.map((run) =>
|
|
builders.runNode(this.store, repo, run, { showBranch: !branch }),
|
|
);
|
|
}
|
|
|
|
return node("runsFolder", legacy ? "Recent Runs" : "Workflow Runs", {
|
|
identifier: `branch-runs-${repo.key}`,
|
|
description: matching.length ? String(matching.length) : "",
|
|
tooltip: legacy
|
|
? "This Gitea server predates the workflow runs API; showing recent tasks instead."
|
|
: "",
|
|
contextValue: "runsFolder",
|
|
repo: repo,
|
|
expanded: true,
|
|
children: children,
|
|
});
|
|
}
|
|
}
|
|
|
|
exports.BranchProvider = BranchProvider;
|