mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-17 11:49:33 +01:00
fix(git): the fetch timeout reaches the whole tree, a tick covers every session on its folder, and the rest of the review (review)
`execFile` signals the `git` parent only, so a fetch that times out can leave its http helper still running, and on the interval that repeats every run with nobody watching. `runFetch` now spawns `detached`, so the fetch and the helper it spawns share one process group, and the kill is SIGTERM to the negative pid then SIGKILL `FETCH_KILL_ESCALATION_MS` later; the escalation is not cancelled when the promise settles, because the caller is answered at the timeout while the group is still dying. The output cap is kept, and the clone's slot queue is not needed here. The tick is two passes: every enabled local session is collected by folder, a folder is due when ANY session open on it is due, the folder is probed once for the group, and the run is published to every session on it. A single pass decided by the order the sessions were read, so [long, short] published only the short one and the 3600 s session's row never updated again while its folder was fetched every 30 s. `gitNonInteractiveEnv` writes BatchMode ssh as a default, not an override: `core.sshCommand` is read inside the same slot and the same bound as the fetch it serves, and `fetchEnvFor` keeps the repository's answer when it has one, because that is usually the setup that works on a machine with several ssh setups. The `accept-new` host key it can write is stated next to the BatchMode note: a prompt is stopped, a write is not. The write claim is scoped to the Git panel and to the timer, with cloning and worktree management named as the writes that happen when the user asked for them, and the zh keys sit with the group of the UI surface their English string belongs to. Tests: the process-group test proves the tree by group membership, because the helper is a grandchild (`git fetch` runs `git remote-http`, which spawns `git-remote-http`) and because the group is what the negative pid reaches, and it remembers each process once found instead of re-scanning a group it had already emptied. The non-zero-exit test changed premises: `git fetch --quiet` in a repository with no remote exits 0 on git 2.47.3, so resolving empty stdout there was correct, and the case that has to reject is a remote pointing at a path that is not a repository. The join test asserts after the run and does not await the request before the held run is released, which would wait on the run the test is holding.
This commit is contained in:
1 parent
ea4318947b
commit
3411d7f35a
15 files changed
+686
-165
No files matched your search
+55
-31
@@ -2,9 +2,10 @@
|
||||
* @fileoverview Git fetch on an interval: the cases the user turned on, fetched by a tick the server owns
|
||||
* (`src/git-fetch-scheduler.ts`, wired in `src/web/server.ts`).
|
||||
*
|
||||
* The fetch module (src/git-fetch.ts) is the only place Codeman runs a git command that writes, and on a
|
||||
* timer it is the only one that can run without being asked — which is why the whole feature is off until
|
||||
* the user turns it on, in Settings → Bottom bar, per session in Session Options → Git.
|
||||
* The fetch module (src/git-fetch.ts) is the only git command the Git panel runs that writes, and on a timer
|
||||
* it is the only one that can run without being asked — cloning and worktree management write too, but those
|
||||
* happen when the user asks for them. Which is why the whole feature is off until the user turns it on, in
|
||||
* Settings → Bottom bar, per session in Session Options → Git.
|
||||
*
|
||||
* The scheduler holds no timers of its own. The server ticks it (`GIT_FETCH_TICK_INTERVAL_MS`) and every
|
||||
* tick reads the app setting FRESH, so a live toggle takes effect on the next tick instead of at boot, and
|
||||
@@ -23,7 +24,10 @@
|
||||
* its result. State is keyed by `resolve(workingDir)` — deliberately not `realpath`, because `realpath`
|
||||
* is itself one of the unbounded fs calls rule #516 bounds; the bounded probe below is the fs read.
|
||||
* Every session open on a folder is remembered, so closing the one holding the override does not stop
|
||||
* the folder's fetching while another session is still on it.
|
||||
* the folder's fetching while another session is still on it. A folder is due when ANY session open on it
|
||||
* is due, and the tick decides that per folder in a second pass: the order the sessions were read cannot
|
||||
* change which interval wins, so a 30 s session on a folder a 3600 s session last fetched ten minutes ago
|
||||
* is fetched now. The folder is probed once, not once per session on it.
|
||||
* - Before anything is fetched, the folder is probed BOUNDED with the default options (rule #516): a case
|
||||
* on a mount that stopped answering is skipped, never touched, and a probe that answers `unknown` is not
|
||||
* read as "not a folder".
|
||||
@@ -55,9 +59,10 @@ import {
|
||||
MIN_GIT_FETCH_INTERVAL_SECONDS,
|
||||
gitFetchStatusFrom,
|
||||
type GitFetchOptions,
|
||||
type GitFetchReport,
|
||||
type GitFetchRun,
|
||||
type GitFetchSettings,
|
||||
type GitFetchStatus,
|
||||
type GitFetchTrigger,
|
||||
} from './git-fetch.js';
|
||||
import { clampInt, DEFAULT_GIT_TIMEOUT_MS, MAX_REPOS, createLimiter, mapLimited } from './git-workspace-status.js';
|
||||
import type { PathProbeKind } from './utils/bounded-path-probe.js';
|
||||
@@ -73,6 +78,12 @@ export interface GitFetchSessionView {
|
||||
gitFetchIntervalSeconds?: number;
|
||||
}
|
||||
|
||||
/** A session open on a folder, with the interval that makes IT due. One folder's sessions are a group. */
|
||||
interface GroupMember {
|
||||
view: GitFetchSessionView;
|
||||
intervalSeconds: number;
|
||||
}
|
||||
|
||||
export interface GitFetchPorts {
|
||||
sessionIds(): Iterable<string>;
|
||||
getSession(id: string): GitFetchSessionView | undefined;
|
||||
@@ -86,7 +97,7 @@ export interface GitFetchPorts {
|
||||
*/
|
||||
probePath(path: string): Promise<PathProbeKind>;
|
||||
/** Called through `fetchWorkspaceOnce`, so a run already going for this folder is joined, not stacked. */
|
||||
fetch(cwd: string, opts: GitFetchOptions): Promise<GitFetchReport>;
|
||||
fetch(cwd: string, opts: GitFetchOptions, trigger: GitFetchTrigger): Promise<GitFetchRun>;
|
||||
publish(id: string, status: GitFetchStatus): void;
|
||||
log?(message: string): void;
|
||||
}
|
||||
@@ -139,39 +150,45 @@ export class GitFetchScheduler {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// One entry per folder, holding every session open on it. Stamped here, at selection: a tick that is
|
||||
// still running must not pick the same folder again, and a folder already being fetched is not picked
|
||||
// at all.
|
||||
const due = new Map<string, GitFetchSessionView[]>();
|
||||
// Pass 1 — who is on what, before anything is decided. Every session open on a folder is recorded here,
|
||||
// not only the one that would get picked, so `remove()` can still see who is open on it when the session
|
||||
// holding the override is the one that closes.
|
||||
const groups = new Map<string, GroupMember[]>();
|
||||
for (const id of this.ports.sessionIds()) {
|
||||
const view = this.ports.getSession(id);
|
||||
if (!view || view.remote || view.docker) continue;
|
||||
const effective = effectiveGitFetch(view, settings);
|
||||
if (!effective.enabled) continue;
|
||||
const folder = resolve(view.workingDir);
|
||||
// Recorded for EVERY session on the folder, not just the one that got picked, so `remove()` can still
|
||||
// see who is open on it when the session holding the override is the one that closes.
|
||||
this.folderOf.set(id, folder);
|
||||
// A session on a folder this tick already picked is the same clone: it joins that folder's run rather
|
||||
// than starting its own. Two fetches in one clone collide on git's ref lock, so one run has to serve
|
||||
// every session open on the folder.
|
||||
const group = due.get(folder);
|
||||
if (group) {
|
||||
group.push(view);
|
||||
continue;
|
||||
}
|
||||
const group = groups.get(folder);
|
||||
const member = { view, intervalSeconds: effective.intervalSeconds };
|
||||
if (group) group.push(member);
|
||||
else groups.set(folder, [member]);
|
||||
}
|
||||
|
||||
// Pass 2 — the folder's turn, decided from the whole group rather than from whichever session happened to
|
||||
// be read first. A folder is due when ANY session open on it is due: a session on a 30 s interval on a
|
||||
// folder a 3600 s session last fetched ten minutes ago has to be fetched now, because that same run
|
||||
// satisfies the long interval too. Deciding in one pass means the session read first owns the clock — a
|
||||
// group ordered [short, long] and a group ordered [long, short] would have behaved differently, and the
|
||||
// run belongs to the folder, so no session in the group should.
|
||||
const due = new Map<string, GroupMember[]>();
|
||||
for (const [folder, group] of groups) {
|
||||
if (this.inFlight.has(folder)) continue;
|
||||
const started = this.lastRunAt.get(folder);
|
||||
if (started !== undefined && now - started < effective.intervalSeconds * 1000) continue;
|
||||
const kind = await this.ports.probePath(view.workingDir);
|
||||
const isDue = started === undefined || group.some((m) => now - started >= m.intervalSeconds * 1000);
|
||||
if (!isDue) continue;
|
||||
// Bounded probe (rule #516), once per folder rather than once per session on it.
|
||||
const kind = await this.ports.probePath(folder);
|
||||
if (kind !== 'directory') {
|
||||
this.ports.log?.(`git fetch: ${view.id} skipped, folder answered ${kind}`);
|
||||
this.ports.log?.(`git fetch: ${folder} skipped, answered ${kind}`);
|
||||
continue;
|
||||
}
|
||||
this.inFlight.add(folder);
|
||||
// The clock starts at the selection, so a slow folder does not shift its own schedule.
|
||||
this.lastRunAt.set(folder, now);
|
||||
due.set(folder, [view]);
|
||||
due.set(folder, group);
|
||||
}
|
||||
if (!due.size) return 0;
|
||||
|
||||
@@ -188,13 +205,20 @@ export class GitFetchScheduler {
|
||||
// processes than the module's ceiling.
|
||||
await mapLimited([...due.entries()], FETCH_CONCURRENCY, async ([folder, group]) => {
|
||||
try {
|
||||
const report = await this.ports.fetch(folder, {
|
||||
dockerWorkspaces,
|
||||
maxRepos: MAX_REPOS,
|
||||
timeoutMs: DEFAULT_GIT_TIMEOUT_MS,
|
||||
limiter: fetches,
|
||||
});
|
||||
for (const view of group) this.ports.publish(view.id, gitFetchStatusFrom(report, 'interval'));
|
||||
const run = await this.ports.fetch(
|
||||
folder,
|
||||
{
|
||||
dockerWorkspaces,
|
||||
maxRepos: MAX_REPOS,
|
||||
timeoutMs: DEFAULT_GIT_TIMEOUT_MS,
|
||||
limiter: fetches,
|
||||
},
|
||||
'interval'
|
||||
);
|
||||
// Every session on the folder gets the SAME run, with the trigger of the run that actually happened:
|
||||
// if this tick joined a run a click had already started, the row has to say it was a click, because
|
||||
// that is what fetched it.
|
||||
for (const member of group) this.ports.publish(member.view.id, gitFetchStatusFrom(run.report, run.trigger));
|
||||
} catch (err) {
|
||||
// The run that failed keeps its reason in the panel's own row; here only the folder-level failure is
|
||||
// worth a line, because nothing else would say a scheduled fetch could not run at all.
|
||||
|
||||
+204
-26
@@ -4,15 +4,17 @@
|
||||
* (`src/git-fetch-scheduler.ts`).
|
||||
*
|
||||
* The status module (src/git-workspace-status.ts) is deliberately offline: "behind" is as of the last
|
||||
* fetch, so a number that is stale can only be made current by fetching. This is the one place Codeman
|
||||
* runs a git command that writes, and on a timer it is also the only one that can run without being asked.
|
||||
* Nothing here commits, checks out, merges or touches the working tree: `git fetch` updates remote-tracking
|
||||
* fetch, so a number that is stale can only be made current by fetching. This is the only git command the
|
||||
* Git panel runs that writes, and the only git command Codeman runs on a timer. Cloning a repository and
|
||||
* managing worktrees write too, but those are things the user asked for at the moment they asked; this is
|
||||
* the one that can happen later, by itself. Nothing here commits, checks out, merges or touches the working
|
||||
* tree: `git fetch` updates remote-tracking
|
||||
* refs and nothing else, and `FETCH_CONFIG_ARGS` keeps it from starting a gc in a repository an agent is
|
||||
* already using. It is not harmless in the way a read is: a fetch holds git's ref lock, so an agent's own
|
||||
* `git pull` in the same clone can collide with it (`cannot lock ref`), which is why one folder is fetched
|
||||
* by at most one run at a time (`fetchWorkspaceOnce`).
|
||||
*
|
||||
* Same split as git-clone.ts: the pure half (`buildFetchArgs`, `describeFetchFailure`,
|
||||
* Same split as git-clone.ts: the pure half (`buildFetchArgs`, `describeFetchFailure`, `fetchEnvFor`,
|
||||
* `gitFetchSettingsFrom`, `gitFetchStatusFrom`) holds every decision and tests without spawning, and the IO
|
||||
* half runs one bounded `git fetch --quiet` per repository.
|
||||
*
|
||||
@@ -27,19 +29,31 @@
|
||||
* - One run per folder at a time: `fetchWorkspaceOnce` joins a run already going for the same folder
|
||||
* instead of starting a second one, because two fetches in one clone collide on the ref lock.
|
||||
* - Bounded: the git timeout from Settings → Bottom bar per repository, `MAX_REPOS_LIMIT` repositories at
|
||||
* most, a hard `timeout` on each spawn, and `FETCH_CONCURRENCY` git processes at a time for the whole
|
||||
* run — one `Limiter`, shared by the scheduler's tick, not one bound per folder.
|
||||
* most, a hard wall-clock bound on each spawn, and `FETCH_CONCURRENCY` git processes at a time for the
|
||||
* whole run — one `Limiter`, shared by the scheduler's tick, not one bound per folder.
|
||||
* - Non-interactive: `GIT_TERMINAL_PROMPT=0` and BatchMode ssh, so a private repository that needs a
|
||||
* login fails fast instead of hanging the request on an invisible username prompt. Codeman collects
|
||||
* no credentials; a repository the user's own git is already signed in to works because that is the
|
||||
* user's existing setup, so unlike a clone no credential helper is disabled here.
|
||||
* user's existing setup, so unlike a clone no credential helper is disabled here. That BatchMode ssh is
|
||||
* a default, never an override: `fetchEnvFor` keeps whatever the repository's `core.sshCommand` or the
|
||||
* user's own `GIT_SSH_COMMAND` already says, because on a machine with several ssh setups that choice
|
||||
* is usually the one that works. ⚠️ The default still leaves a record: `StrictHostKeyChecking=accept-new`
|
||||
* writes an unknown host key into `~/.ssh/known_hosts` without asking — BatchMode stops a prompt, not a
|
||||
* write.
|
||||
* - The timeout kills the PROCESS GROUP, not just the `git` parent. A fetch over http spawns
|
||||
* `git-remote-http` children, and `execFile`'s `timeout` signals the parent only, so the answer can go
|
||||
* out while a helper is still running — and on a timer that repeats every tick with nobody watching.
|
||||
* `spawn` with `detached: true` puts the tree in its own group so the escalation (SIGTERM, then SIGKILL
|
||||
* `FETCH_KILL_ESCALATION_MS` later) reaches the children too, which is why the negative pid is used
|
||||
* rather than `child.kill()`. Same shape as `runGit` in git-clone.ts, without that module's slot queue:
|
||||
* fetch is bounded by `FETCH_CONCURRENCY`, not by a clone queue.
|
||||
* - Failure text reaching a client is control-stripped and credential-redacted (`sanitizeGitOutput`),
|
||||
* and the browser writes it with `textContent` only.
|
||||
*
|
||||
* @module git-fetch
|
||||
*/
|
||||
|
||||
import { execFile } from 'node:child_process';
|
||||
import { execFile, spawn } from 'node:child_process';
|
||||
import { basename, relative, resolve } from 'node:path';
|
||||
import { promisify } from 'node:util';
|
||||
import { classifyGitFailure, gitNonInteractiveEnv, sanitizeGitOutput, type GitFailureCode } from './git-clone.js';
|
||||
@@ -63,6 +77,15 @@ const execFileAsync = promisify(execFile);
|
||||
export const FETCH_CONCURRENCY = 4;
|
||||
/** A fetch on a busy remote can print a lot; a bound on what we will hold. */
|
||||
const MAX_FETCH_OUTPUT_BYTES = 2 * 1024 * 1024;
|
||||
/** git's stderr is kept as a bounded tail (as in git-clone.ts): enough for the reason, not the whole stream. */
|
||||
const MAX_FETCH_STDERR_BYTES = 8_192;
|
||||
/** A `git config --get` answer is one line; this is a sanity cap, not an expected size. */
|
||||
const MAX_SSH_COMMAND_BYTES = 4_096;
|
||||
/**
|
||||
* How long the process group gets to answer SIGTERM before the same escalation goes to SIGKILL. Kept as a
|
||||
* const so a test can say how long it is willing to wait for the group to actually die.
|
||||
*/
|
||||
export const FETCH_KILL_ESCALATION_MS = 3_000;
|
||||
|
||||
/**
|
||||
* Config overrides set ahead of the argv, so an unattended fetch cannot do more than move refs: no
|
||||
@@ -151,15 +174,148 @@ export function describeFetchFailure(err: unknown): FetchFailure {
|
||||
return failure;
|
||||
}
|
||||
|
||||
/** Fetch is allowed to write refs, so this runner does not carry `--no-optional-locks`: fetch takes a required lock anyway. */
|
||||
/**
|
||||
* The environment a fetch gets, as a pure decision so it can be pinned without spawning git.
|
||||
*
|
||||
* `gitNonInteractiveEnv` supplies the BatchMode default, and the default is only a default: git reads
|
||||
* `GIT_SSH_COMMAND` from the environment ahead of the repository's `core.sshCommand`, so setting it would
|
||||
* override a repository that already chose its own ssh — an alternative host, an identity file, a jump box —
|
||||
* and break a setup that works today. That is the only case where this module makes an ssh choice on the
|
||||
* user's behalf, so it is the whole decision here: the caller supplies the value it read, and this decides
|
||||
* between the user's environment and the repository's own answer.
|
||||
*/
|
||||
export function fetchEnvFor(base: NodeJS.ProcessEnv, repoSshCommand: string | null): NodeJS.ProcessEnv {
|
||||
const env = gitNonInteractiveEnv(base);
|
||||
// `gitNonInteractiveEnv` only writes the default when the environment had nothing, so this is exactly the
|
||||
// case where it was a choice rather than a pass-through — and the repository's own answer wins over it.
|
||||
if (!base.GIT_SSH_COMMAND && repoSshCommand) delete env.GIT_SSH_COMMAND;
|
||||
return env;
|
||||
}
|
||||
|
||||
/**
|
||||
* The repository's own `core.sshCommand`, or null. One bounded, read-only `git config --get` per fetch:
|
||||
* git would honour that config itself if we did not write `GIT_SSH_COMMAND` over it, so honouring it means
|
||||
* not writing one. `--get` reads local and global config, which is the value git would have used, and no
|
||||
* hook or filter runs on the way to it.
|
||||
*
|
||||
* The read happens inside the same slot and the same wall-clock bound as the fetch it serves, so it cannot
|
||||
* add a fifth git process or push a fetch past the user's timeout — it spends part of it.
|
||||
*/
|
||||
export async function readRepoSshCommand(cwd: string, timeoutMs: number): Promise<string | null> {
|
||||
try {
|
||||
const { stdout } = await execFileAsync('git', ['config', '--get', 'core.sshCommand'], {
|
||||
cwd,
|
||||
timeout: timeoutMs,
|
||||
maxBuffer: MAX_SSH_COMMAND_BYTES,
|
||||
env: gitNonInteractiveEnv(),
|
||||
});
|
||||
return stdout.trim() || null;
|
||||
} catch {
|
||||
// A repository with no such setting, or a read that could not finish: the default is what git would have
|
||||
// used anyway, and a fetch must not fail because the check for a config value failed.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch is allowed to write refs, so this runner does not carry `--no-optional-locks`: fetch takes a
|
||||
* required lock anyway.
|
||||
*
|
||||
* `spawn`, not `execFile`, because the bound has to reach the whole tree (see the fileoverview): the
|
||||
* caller is answered at the timeout, and the SIGTERM → SIGKILL escalation is deliberately NOT cancelled
|
||||
* when the answer goes out, because the promise is a promise about the answer while the group still has to
|
||||
* die. That is the difference from `runGit` in git-clone.ts, which disarms the escalation at `finish` and so
|
||||
* can leave a `git-remote-http` child running after a timed-out call.
|
||||
*
|
||||
* The thrown error keeps the shape `describeFetchFailure` reads: `stderr` for the reason, `message` for a
|
||||
* spawn failure (`spawn git ENOENT` → GIT_MISSING), `killed` and `code` for the timeout. A non-zero exit
|
||||
* rejects the way `execFile` would — `code` is then the exit code — because resolving it would report a real
|
||||
* failure as a clean run with an empty reason.
|
||||
*/
|
||||
export const runFetch: GitRunner = async (cwd, args, opts) => {
|
||||
const { stdout } = await execFileAsync('git', [...FETCH_CONFIG_ARGS, ...args], {
|
||||
cwd,
|
||||
timeout: opts?.timeoutMs ?? DEFAULT_GIT_TIMEOUT_MS,
|
||||
maxBuffer: MAX_FETCH_OUTPUT_BYTES,
|
||||
env: gitNonInteractiveEnv(),
|
||||
const timeoutMs = opts?.timeoutMs ?? DEFAULT_GIT_TIMEOUT_MS;
|
||||
const env = fetchEnvFor(process.env, await readRepoSshCommand(cwd, timeoutMs));
|
||||
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
let child: ReturnType<typeof spawn>;
|
||||
try {
|
||||
child = spawn('git', [...FETCH_CONFIG_ARGS, ...args], {
|
||||
cwd,
|
||||
env,
|
||||
stdio: ['ignore', 'pipe', 'pipe'],
|
||||
detached: true,
|
||||
});
|
||||
} catch (err) {
|
||||
reject(err);
|
||||
return;
|
||||
}
|
||||
|
||||
let stdout = '';
|
||||
let stderr = '';
|
||||
let stdoutBytes = 0;
|
||||
let timedOut = false;
|
||||
let settled = false;
|
||||
let killTimer: NodeJS.Timeout | undefined;
|
||||
|
||||
const killTree = (signal: NodeJS.Signals) => {
|
||||
try {
|
||||
if (child.pid) process.kill(-child.pid, signal);
|
||||
} catch {
|
||||
try {
|
||||
child.kill(signal);
|
||||
} catch {
|
||||
/* already gone */
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const fail = (spawnError?: string, exitCode?: number | null) => {
|
||||
if (settled) return;
|
||||
settled = true;
|
||||
// Only the timeout timer is disarmed here. On a timeout the escalation is what the caller is waiting
|
||||
// for, and cancelling it is the bug this runner exists to fix.
|
||||
clearTimeout(timeoutTimer);
|
||||
reject(
|
||||
Object.assign(new Error(spawnError ?? `Command failed: git ${args.join(' ')}`), {
|
||||
stderr,
|
||||
killed: timedOut,
|
||||
code: timedOut ? 'ETIMEDOUT' : (exitCode ?? undefined),
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
const timeoutTimer = setTimeout(() => {
|
||||
timedOut = true;
|
||||
killTree('SIGTERM');
|
||||
killTimer = setTimeout(() => killTree('SIGKILL'), FETCH_KILL_ESCALATION_MS);
|
||||
fail();
|
||||
}, timeoutMs);
|
||||
|
||||
child.stdout?.on('data', (chunk: Buffer) => {
|
||||
stdoutBytes += chunk.length;
|
||||
if (stdoutBytes <= MAX_FETCH_OUTPUT_BYTES) stdout += chunk.toString('utf-8');
|
||||
});
|
||||
child.stderr?.on('data', (chunk: Buffer) => {
|
||||
stderr += chunk.toString('utf-8');
|
||||
if (stderr.length > MAX_FETCH_STDERR_BYTES * 2) stderr = stderr.slice(-MAX_FETCH_STDERR_BYTES);
|
||||
});
|
||||
|
||||
const finish = (code: number | null) => {
|
||||
if (settled) return;
|
||||
// execFile's contract, which `describeFetchFailure` depends on: a non-zero exit rejects, so a real
|
||||
// git failure keeps its reason in `stderr` instead of becoming a green row with an empty one. `null`
|
||||
// means a signal, reachable only when something outside this runner killed the group — our own timeout
|
||||
// has already answered by then, and `settled` above is what keeps that answer the answer.
|
||||
if (code !== 0) return fail(undefined, code);
|
||||
settled = true;
|
||||
clearTimeout(timeoutTimer);
|
||||
if (killTimer) clearTimeout(killTimer);
|
||||
resolve(stdout);
|
||||
};
|
||||
|
||||
child.on('error', (err) => fail(String(err)));
|
||||
child.on('close', (code) => finish(code));
|
||||
});
|
||||
return stdout;
|
||||
};
|
||||
|
||||
export interface GitFetchEntry {
|
||||
@@ -191,9 +347,12 @@ export interface GitFetchReport {
|
||||
* whether the user clicked or the interval fired, because a number the user did not ask for should read
|
||||
* differently from one they did.
|
||||
*/
|
||||
/** What a run was, and why it happened. */
|
||||
export type GitFetchTrigger = 'click' | 'interval';
|
||||
|
||||
export interface GitFetchStatus {
|
||||
ranAt: number;
|
||||
trigger: 'click' | 'interval';
|
||||
trigger: GitFetchTrigger;
|
||||
/** As in the report: `ok`, or the state that stopped the run. */
|
||||
state: GitFetchReport['state'];
|
||||
/** Repositories this run covered. */
|
||||
@@ -204,7 +363,17 @@ export interface GitFetchStatus {
|
||||
firstFailure?: { name: string; code: FetchFailureCode };
|
||||
}
|
||||
|
||||
export function gitFetchStatusFrom(report: GitFetchReport, trigger: GitFetchStatus['trigger']): GitFetchStatus {
|
||||
/**
|
||||
* One run, with the trigger that caused it. A joiner gets the run already going, so what it reports is that
|
||||
* run's trigger rather than the one that made it ask: a click that joins an interval run did not fetch
|
||||
* anything itself, and the row the panel shows has to describe the fetch that actually happened.
|
||||
*/
|
||||
export interface GitFetchRun {
|
||||
report: GitFetchReport;
|
||||
trigger: GitFetchTrigger;
|
||||
}
|
||||
|
||||
export function gitFetchStatusFrom(report: GitFetchReport, trigger: GitFetchTrigger): GitFetchStatus {
|
||||
const failed = report.repos.filter((r) => !r.ok);
|
||||
const status: GitFetchStatus = {
|
||||
ranAt: report.fetchedAt,
|
||||
@@ -283,25 +452,34 @@ export async function fetchGitWorkspaceOverview(cwd: string, opts: GitFetchOptio
|
||||
* Runs already going, keyed by the resolved folder. A request for a folder another run is already working on
|
||||
* JOINS that run instead of starting a second `git fetch` in the same clone: two fetches there collide on
|
||||
* git's ref lock (`cannot lock ref 'refs/remotes/origin/main'`), which is what a click during a tick would
|
||||
* otherwise do. A joiner gets the run already going's answer, including its limits — the point is not to
|
||||
* fetch twice, not to fetch with the freshest options.
|
||||
* otherwise do. A joiner gets the run already going's answer, including its limits and its trigger — the point
|
||||
* is not to fetch twice, not to fetch with the freshest options, and a click that fetched nothing cannot
|
||||
* report itself as the fetch.
|
||||
*
|
||||
* Keyed by `resolve`, not `realpath`, because `realpath` is itself one of the unbounded fs calls rule #516
|
||||
* bounds for user-chosen paths; the scheduler probes the folder bounded and calls this. Two paths that
|
||||
* resolve the same are the same folder here; a workspace reached through a symlink resolves to the link, so
|
||||
* a link and its target can be fetched by two runs — the accepted trade for keeping the probe bounded.
|
||||
*/
|
||||
const lane = new Map<string, Promise<GitFetchReport>>();
|
||||
const lane = new Map<string, Promise<GitFetchRun>>();
|
||||
|
||||
export async function fetchWorkspaceOnce(folder: string, opts: GitFetchOptions = {}): Promise<GitFetchReport> {
|
||||
export async function fetchWorkspaceOnce(
|
||||
folder: string,
|
||||
opts: GitFetchOptions = {},
|
||||
trigger: GitFetchTrigger
|
||||
): Promise<GitFetchRun> {
|
||||
const key = resolve(folder);
|
||||
const going = lane.get(key);
|
||||
// The joiner is handed the run already going as it is, trigger included: it did not cause that fetch, so it
|
||||
// must not report itself as having.
|
||||
if (going) return going;
|
||||
const run = fetchGitWorkspaceOverview(key, opts).finally(() => {
|
||||
// Only the run that is still the lane's own: a later run for the same folder must not be dropped by an
|
||||
// earlier one finishing late.
|
||||
if (lane.get(key) === run) lane.delete(key);
|
||||
});
|
||||
const run: Promise<GitFetchRun> = fetchGitWorkspaceOverview(key, opts)
|
||||
.then((report) => ({ report, trigger }))
|
||||
.finally(() => {
|
||||
// Only the run that is still the lane's own: a later run for the same folder must not be dropped by an
|
||||
// earlier one finishing late.
|
||||
if (lane.get(key) === run) lane.delete(key);
|
||||
});
|
||||
lane.set(key, run);
|
||||
return run;
|
||||
}
|
||||
|
||||
@@ -11,8 +11,10 @@
|
||||
* `GET /api/sessions/:id/git-status` for the active session on a slow poll (and at once when the
|
||||
* session changes or the window regains focus). The status route is read-only: it never changes the
|
||||
* repository, so the "behind" number reflects the last `git fetch`, which the panel footer says. Fetching
|
||||
* happens only when the user clicks Fetch in that window's header (`POST /api/sessions/:id/git-fetch`,
|
||||
* src/git-fetch.ts): the only git command Codeman runs that writes, and only on that click. Remote (SSH)
|
||||
* happens when the user clicks Fetch in that window's header (`POST /api/sessions/:id/git-fetch`,
|
||||
* src/git-fetch.ts), or on the interval when the session is on: this is the only git command the Git panel
|
||||
* runs that writes, and the only one Codeman runs on a timer — cloning and worktree management write too,
|
||||
* but only when the user asked for them at that moment. Remote (SSH)
|
||||
* and Docker sessions answer `unsupported`, show no indicator, and cannot be fetched.
|
||||
*
|
||||
* Everything that comes from git (file names, commit subjects, author names) is untrusted text: it is
|
||||
@@ -269,10 +271,13 @@ Object.assign(CodemanApp.prototype, {
|
||||
|
||||
/**
|
||||
* Fetch, on this click only: one `git fetch --quiet` per repository the panel shows
|
||||
* (`POST /api/sessions/:id/git-fetch`). It is the only git command Codeman runs that writes, and it
|
||||
* updates remote-tracking refs only, so an agent working in the same repository is not disturbed. One
|
||||
* click means one fetch per repository: the button is busy and a second click is ignored while it runs.
|
||||
* The panel then re-reads, so the "behind" number reflects what this fetch brought.
|
||||
* (`POST /api/sessions/:id/git-fetch`). It is the only git command the Git panel runs that writes, and the
|
||||
* only one Codeman runs on a timer, and it updates remote-tracking refs only: nothing here commits or
|
||||
* touches the working tree, so an agent's own work is left alone — though a fetch does hold git's ref lock,
|
||||
* so an agent's `git pull` in the same repository can hit the same `cannot lock ref` while it runs. One
|
||||
* click means one fetch per repository: the button is busy and a second click is ignored while it runs, and
|
||||
* a click that joins a fetch already running reports that run, not itself. The panel then re-reads, so the
|
||||
* "behind" number reflects what this fetch brought.
|
||||
*/
|
||||
async fetchGitStatusNow() {
|
||||
const sid = this.activeSessionId || null;
|
||||
|
||||
+28
-26
@@ -520,12 +520,13 @@
|
||||
'Connection tile: offline': '离线',
|
||||
'Connection tile: queued': '已排队',
|
||||
'Connection tile: retry': '重连中',
|
||||
// App Settings → Bottom bar, translated as one group (the Git status rows,
|
||||
// #543's two included). Keys are the trimmed label text, without the scope tag.
|
||||
// App Settings → Bottom bar, translated as one group (the Git status rows, #543's two included, and the
|
||||
// two Git fetch rows, in the order the page lists them). Keys are the trimmed label text, without the
|
||||
// scope tag. The Session Options → Git strings are in that group's own block further down.
|
||||
'Bottom bar': '底部栏',
|
||||
'Git status': 'Git 状态',
|
||||
"Shows, at the right of the bottom bar, when the active session's repository (or each repository inside its folder, up to two levels down) has uncommitted files or commits that are not pushed. Click it for the list. Read-only apart from Fetch: Codeman never commits or changes the repository, and `git fetch` — the one git command here that writes — runs only when you click Fetch in that window, or on the interval below if you turned it on. Not shown for Docker or remote sessions. Off by default.":
|
||||
'在底部栏右侧显示当前会话的仓库(或其文件夹内向下两层以内的每个仓库)是否有未提交的文件或未推送的提交。点击可查看列表。除拉取外只读:{name} 从不提交或更改仓库,而拉取(这里唯一会写入的 git 命令)只在您点击该窗口中的拉取按钮时运行,或在您开启了下方的定时后按间隔运行。Docker 和远程会话不显示。默认关闭。',
|
||||
"Shows, at the right of the bottom bar, when the active session's repository (or each repository inside its folder, up to two levels down) has uncommitted files or commits that are not pushed. Click it for the list. Read-only apart from Fetch: Codeman never commits or changes the repository, and `git fetch` — the only git command the Git window runs that writes, and the only one Codeman runs on a timer (cloning and worktree management write too, but only when you asked for them at the moment you asked) — runs when you click Fetch in that window, or on the interval below if you turned it on. Not shown for Docker or remote sessions. Off by default.":
|
||||
'在底部栏右侧显示当前会话的仓库(或其文件夹内向下两层以内的每个仓库)是否有未提交的文件或未推送的提交。点击可查看列表。除拉取外只读:{name} 从不提交或更改仓库,而拉取是 Git 窗口运行的唯一会写入的 git 命令,也是 {name} 唯一会按间隔自行运行的命令(克隆和工作树管理也会写入,但只在您当时要求时才运行),它只在您点击该窗口中的拉取按钮时运行,或在您开启了下方的定时后按间隔运行。Docker 和远程会话不显示。默认关闭。',
|
||||
'Git status: group files by folder': 'Git 状态:按文件夹分组显示文件',
|
||||
'In the Git window, show changed files under their folders, collapsed until you click a folder. Off lists every file by its full path. On by default.':
|
||||
'在 Git 窗口中,将更改的文件显示在各自的文件夹下,点击文件夹前保持折叠。关闭时按完整路径列出每个文件。默认开启。',
|
||||
@@ -535,32 +536,15 @@
|
||||
'Git status: git timeout': 'Git 状态:git 超时',
|
||||
'Seconds one git command may run before that repository is reported as unreadable (5 to 120, default 30). Raise it for repositories on a slow network share.':
|
||||
'单条 git 命令可运行的秒数,超时后该仓库会被报告为无法读取(5 到 120,默认 30)。仓库位于较慢的网络共享上时请调高此值。',
|
||||
'Fetch git status': '拉取 Git 状态',
|
||||
'Refresh git status': '刷新 Git 状态',
|
||||
'Close git status': '关闭 Git 状态',
|
||||
// Git fetch on an interval (App Settings → Bottom bar, Session Options → Git, and the save toast in
|
||||
// session-ui.js). 'Status' and 'Git' are not added: the first already has a key, the second stays a
|
||||
// technical name, and the status row's text is written at runtime.
|
||||
"Whether Codeman fetches this session's repositories on a timer.": '{name} 是否按间隔拉取此会话的仓库。',
|
||||
'Git fetch on an interval': 'Git 定时拉取',
|
||||
'Runs `git fetch` for the repositories the Git window lists on a timer, so the "behind" number is current without a click. Off by default: this is the one git command Codeman runs that writes, and the one that runs a repository\'s own hooks, so nothing runs on a timer until you turn it on. A session can override both the switch and the interval in Session Options → Git.':
|
||||
'按间隔为 Git 窗口列出的仓库运行拉取,这样“落后”的数字无需点击就是最新的。默认关闭:这是 {name} 运行的唯一会写入的 git 命令,也是唯一会运行仓库自身钩子的命令,所以在您开启之前不会有任何定时运行。会话可以在“会话选项 → Git”中同时覆盖开关和间隔。',
|
||||
'Runs `git fetch` for the repositories the Git window lists on a timer, so the "behind" number is current without a click. Off by default: this is the only git command the Git panel runs that writes, and the only one Codeman runs on a timer (cloning and worktree management write too, but only when you asked for them at the moment you asked), so nothing runs until you turn it on. A session can override both the switch and the interval in Session Options → Git.':
|
||||
'按间隔为 Git 窗口列出的仓库运行拉取,这样“落后”的数字无需点击就是最新的。默认关闭:这是 {name} 运行的唯一会写入的 git 命令,也是唯一会按间隔自行运行的命令(克隆和工作树管理也会写入,但只在您当时要求时才运行),所以在您开启之前不会有任何运行。会话可以在“会话选项 → Git”中同时覆盖开关和间隔。',
|
||||
'Git fetch: how often': 'Git 定时拉取:多久一次',
|
||||
'Seconds between runs for a session that has no override of its own (30 to 3600, default 300). Only a session that is on — here, or in Session Options → Git — is fetched, and sessions sharing one folder are fetched by one run.':
|
||||
'没有自己覆盖设置的会话,两次运行之间的秒数(30 到 3600,默认 300)。只有已开启的会话——这里,或在“会话选项 → Git”——才会被拉取,共用一个文件夹的会话由一次运行拉取。',
|
||||
'Fetch on an interval': '按间隔拉取',
|
||||
"Fetching is the only git command Codeman runs that writes, and the only one that runs a repository's own hooks, so nothing runs on a timer until you turn it on — here, or in App Settings → Bottom bar. The panel's Fetch button is always just a click.":
|
||||
'拉取是 {name} 运行的唯一会写入的 git 命令,也是唯一会运行仓库自身钩子的命令,所以在您开启之前(这里,或“应用设置 → 底部栏”)不会有任何定时运行。该窗口中的拉取按钮始终只是一次点击。',
|
||||
'Follow the app setting': '跟随应用设置',
|
||||
'Uses the app-wide switch and interval for this session. Switch it off to pick your own.':
|
||||
'为此会话使用应用级的开关和间隔。关闭它即可自行选择。',
|
||||
'Fetch this session': '拉取此会话',
|
||||
"Runs on its own even while the app-wide switch is off: a session that turned itself on means exactly that. Sessions sharing one folder share one run, and each sees that run's result.":
|
||||
'即使应用级开关关闭也自行运行:一个自己开启的会话正是这个意思。共用一个文件夹的会话共享一次运行,每个会话都会看到该运行的结果。',
|
||||
'How often': '多久一次',
|
||||
'30 sec to 1 hr, timed from the start of a run, so a slow repository does not push the next one out.':
|
||||
'30 秒到 1 小时,从一次运行的开始计时,所以较慢的仓库不会把下一次推远。',
|
||||
'Git fetch settings saved': 'Git 定时拉取设置已保存',
|
||||
'Fetch git status': '拉取 Git 状态',
|
||||
'Refresh git status': '刷新 Git 状态',
|
||||
'Close git status': '关闭 Git 状态',
|
||||
Panels: '面板',
|
||||
Monitor: '监视器',
|
||||
'Project Insights': '项目洞察',
|
||||
@@ -857,6 +841,24 @@
|
||||
Memory: '内存',
|
||||
GPUs: 'GPU',
|
||||
|
||||
// Session Options → Git (the tab's blurb, its group head, its hint and its three rows in index.html, plus
|
||||
// the save toast session-ui.js raises). 'Status' is not a key here: that row's text is built at runtime
|
||||
// by updateGitFetchStatus, and 'Git' stays a technical name.
|
||||
"Whether Codeman fetches this session's repositories on a timer.": '{name} 是否按间隔拉取此会话的仓库。',
|
||||
'Fetch on an interval': '按间隔拉取',
|
||||
"Fetching is the only git command the Git panel runs that writes, and the only one Codeman runs on a timer, so nothing runs until you turn it on — here, or in App Settings → Bottom bar. Cloning and worktree management write too, but only when you asked for them at the moment you asked. The panel's Fetch button is always just a click.":
|
||||
'拉取是 Git 窗口运行的唯一会写入的 git 命令,也是 {name} 唯一会按间隔自行运行的命令,所以在您开启之前(这里,或“应用设置 → 底部栏”)不会有任何运行。克隆和工作树管理也会写入,但只在您当时要求时才运行。该窗口中的拉取按钮始终只是一次点击。',
|
||||
'Follow the app setting': '跟随应用设置',
|
||||
'Uses the app-wide switch and interval for this session. Switch it off to pick your own.':
|
||||
'为此会话使用应用级的开关和间隔。关闭它即可自行选择。',
|
||||
'Fetch this session': '拉取此会话',
|
||||
"Runs on its own even while the app-wide switch is off: a session that turned itself on means exactly that. Sessions sharing one folder share one run, and each sees that run's result.":
|
||||
'即使应用级开关关闭也自行运行:一个自己开启的会话正是这个意思。共用一个文件夹的会话共享一次运行,每个会话都会看到该运行的结果。',
|
||||
'How often': '多久一次',
|
||||
'30 sec to 1 hr, timed from the start of a run, so a slow repository does not push the next one out.':
|
||||
'30 秒到 1 小时,从一次运行的开始计时,所以较慢的仓库不会把下一次推远。',
|
||||
'Git fetch settings saved': 'Git 定时拉取设置已保存',
|
||||
|
||||
// Cron / lifecycle / panels
|
||||
'Cron Jobs': '定时任务',
|
||||
'+ New Job': '+ 新建任务',
|
||||
|
||||
@@ -1738,7 +1738,7 @@
|
||||
|
||||
<div class="set-group">
|
||||
<div class="set-group-head"><h4>Fetch on an interval</h4></div>
|
||||
<p class="set-group-hint">Fetching is the only git command Codeman runs that writes, and the only one that runs a repository's own hooks, so nothing runs on a timer until you turn it on — here, or in App Settings → Bottom bar. The panel's Fetch button is always just a click.</p>
|
||||
<p class="set-group-hint">Fetching is the only git command the Git panel runs that writes, and the only one Codeman runs on a timer, so nothing runs until you turn it on — here, or in App Settings → Bottom bar. Cloning and worktree management write too, but only when you asked for them at the moment you asked. The panel's Fetch button is always just a click.</p>
|
||||
<div class="set-group-body">
|
||||
<!-- Live from the session's own last run (session-ui.js: updateGitFetchStatus), which is the
|
||||
run its folder got: several sessions on one folder share one run and read the same row. -->
|
||||
@@ -2252,7 +2252,7 @@
|
||||
<div class="set-row" data-search="git status uncommitted unpushed commit push indicator bottom bar toolbar">
|
||||
<div class="set-row-text">
|
||||
<span class="set-row-label">Git status <span class="set-scope">device</span></span>
|
||||
<span class="set-row-desc">Shows, at the right of the bottom bar, when the active session's repository (or each repository inside its folder, up to two levels down) has uncommitted files or commits that are not pushed. Click it for the list. Read-only apart from Fetch: Codeman never commits or changes the repository, and `git fetch` — the one git command here that writes — runs only when you click Fetch in that window, or on the interval below if you turned it on. Not shown for Docker or remote sessions. Off by default.</span>
|
||||
<span class="set-row-desc">Shows, at the right of the bottom bar, when the active session's repository (or each repository inside its folder, up to two levels down) has uncommitted files or commits that are not pushed. Click it for the list. Read-only apart from Fetch: Codeman never commits or changes the repository, and `git fetch` — the only git command the Git window runs that writes, and the only one Codeman runs on a timer (cloning and worktree management write too, but only when you asked for them at the moment you asked) — runs when you click Fetch in that window, or on the interval below if you turned it on. Not shown for Docker or remote sessions. Off by default.</span>
|
||||
</div>
|
||||
<label class="switch switch-sm"><input type="checkbox" id="appSettingsShowGitStatus"><span class="slider"></span></label>
|
||||
</div>
|
||||
@@ -2280,7 +2280,7 @@
|
||||
<div class="set-row" data-search="git fetch interval timer behind remote tracking refs poll run automatically">
|
||||
<div class="set-row-text">
|
||||
<span class="set-row-label">Git fetch on an interval <span class="set-scope">synced</span></span>
|
||||
<span class="set-row-desc">Runs `git fetch` for the repositories the Git window lists on a timer, so the "behind" number is current without a click. Off by default: this is the one git command Codeman runs that writes, and the one that runs a repository's own hooks, so nothing runs on a timer until you turn it on. A session can override both the switch and the interval in Session Options → Git.</span>
|
||||
<span class="set-row-desc">Runs `git fetch` for the repositories the Git window lists on a timer, so the "behind" number is current without a click. Off by default: this is the only git command the Git panel runs that writes, and the only one Codeman runs on a timer (cloning and worktree management write too, but only when you asked for them at the moment you asked), so nothing runs until you turn it on. A session can override both the switch and the interval in Session Options → Git.</span>
|
||||
</div>
|
||||
<label class="switch switch-sm"><input type="checkbox" id="appSettingsGitFetchEnabled"><span class="slider"></span></label>
|
||||
</div>
|
||||
|
||||
@@ -132,11 +132,13 @@ export function registerGitStatusRoutes(
|
||||
|
||||
// Fetch, and only because the user clicked Fetch in the panel (src/git-fetch.ts): one
|
||||
// `git fetch --quiet` per repository the panel would show, through the same resolver so the two cannot
|
||||
// disagree about which repositories belong to the workspace. This is the only git command Codeman runs
|
||||
// that writes, and it writes remote-tracking refs only — nothing commits, checks out or merges. It is not
|
||||
// as harmless as a read though: a fetch holds git's ref lock, so an agent's own `git pull` in the same
|
||||
// clone can collide with it, which is why the run goes through `fetchWorkspaceOnce` — a click while a tick
|
||||
// is already fetching this folder joins that run instead of starting a second one. It can also run a
|
||||
// disagree about which repositories belong to the workspace. This is the only git command the Git panel runs
|
||||
// that writes, and it writes remote-tracking refs only — nothing commits, checks out or merges. Cloning and
|
||||
// worktree management write too, but those happen when the user asked for them; this route is the one that
|
||||
// can also run later, on a timer. It is not as harmless as a read though: a fetch holds git's ref lock, so
|
||||
// an agent's own `git pull` in the same clone can collide with it, which is why the run goes through
|
||||
// `fetchWorkspaceOnce` — a click while a tick is already fetching this folder joins that run instead of
|
||||
// starting a second one. It can also run a
|
||||
// repository's own hooks (`reference-transaction`, `pre-auto-gc` through the maintenance git runs after a
|
||||
// fetch) and its config commands such as `credential.helper`, so the `FETCH_CONFIG_ARGS` overrides turn
|
||||
// maintenance and gc off, and a repository a container can write to is refused before any git runs. Remote
|
||||
@@ -148,16 +150,18 @@ export function registerGitStatusRoutes(
|
||||
const session = findSessionOrFail(ctx, id, req);
|
||||
if (session.remote) return { success: true, data: emptyReport('unsupported', { reason: 'remote' }) };
|
||||
if (session.docker) return { success: true, data: emptyReport('unsupported', { reason: 'docker' }) };
|
||||
const report = await fetchWorkspaceOnce(session.workingDir, {
|
||||
git,
|
||||
...limits,
|
||||
dockerWorkspaces: await dockerWorkspaces(),
|
||||
});
|
||||
const run = await fetchWorkspaceOnce(
|
||||
session.workingDir,
|
||||
{ git, ...limits, dockerWorkspaces: await dockerWorkspaces() },
|
||||
'click'
|
||||
);
|
||||
// The response answers the click, and the run is also the session's current truth: what the panel's
|
||||
// "behind" number is based on. Publishing it is what the api docs say a click does, and what makes a
|
||||
// second tab open on the same folder see the same run — including a click that joined a tick already
|
||||
// going, where the row has to say who last fetched.
|
||||
if (session.setGitFetchStatus(gitFetchStatusFrom(report, 'click'))) persistAndBroadcastSession(ctx, session);
|
||||
return { success: true, data: report };
|
||||
// second tab open on the same folder see the same run. The trigger recorded is the RUN's, not this
|
||||
// request's: a click that joined a tick already going fetched nothing itself, so the row has to name the
|
||||
// interval as what fetched.
|
||||
if (session.setGitFetchStatus(gitFetchStatusFrom(run.report, run.trigger)))
|
||||
persistAndBroadcastSession(ctx, session);
|
||||
return { success: true, data: run.report };
|
||||
});
|
||||
}
|
||||
+5
-4
@@ -1491,10 +1491,11 @@ export const SettingsUpdateSchema = z
|
||||
/**
|
||||
* Git fetch on an interval (src/git-fetch-scheduler.ts): `git fetch` for the repositories the Git panel
|
||||
* lists, run on a timer instead of only on the panel's Fetch click. SYNCED, default OFF, because the
|
||||
* server is what runs it: `git fetch` is the only git command Codeman runs that writes, and the only
|
||||
* one that can run a repository's own hooks (`reference-transaction`, `pre-auto-gc` through the
|
||||
* automatic maintenance a fetch triggers, config commands such as `credential.helper`), so nothing runs
|
||||
* on a timer until the user turns this on. Cap in seconds between runs (30 to 3600, default 300). A
|
||||
* server is what runs it: `git fetch` is the only git command the Git panel runs that writes — cloning
|
||||
* and worktree management write too, but only when the user asked for them at the moment they asked — and
|
||||
* the only one that can run later by itself, on a timer, and the only one that can run a repository's own
|
||||
* hooks (`reference-transaction`, `pre-auto-gc` through the automatic maintenance a fetch triggers, config
|
||||
* commands such as `credential.helper`), so nothing runs on a timer until the user turns this on. Cap in seconds between runs (30 to 3600, default 300). A
|
||||
* session can override both in Session Options → Git; `null` there clears the override, and sessions
|
||||
* sharing one folder are fetched by one run.
|
||||
*/
|
||||
|
||||
+3
-2
@@ -410,8 +410,9 @@ export class WebServer extends EventEmitter {
|
||||
// never be handed `pastCap`. A folder on a mount that stopped answering is skipped, not fetched.
|
||||
probePath: (path) => probePathKind(path),
|
||||
// Through the join, so the tick and the panel's Fetch button are the same run: a click on a folder the
|
||||
// tick is already fetching joins it rather than starting a second `git fetch` in the same clone.
|
||||
fetch: (cwd, opts) => fetchWorkspaceOnce(cwd, opts),
|
||||
// tick is already fetching joins it rather than starting a second `git fetch` in the same clone — and the
|
||||
// run that gets published is the one that ran, with its own trigger.
|
||||
fetch: (cwd, opts, trigger) => fetchWorkspaceOnce(cwd, opts, trigger),
|
||||
publish: (id, status) => {
|
||||
const session = this.sessions.get(id);
|
||||
if (!session?.setGitFetchStatus(status)) return;
|
||||
|
||||
Reference in new issue
Block a user