mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-18 16:08:55 +00:00
fix(vcs): the background incoming check fetches every repository (#3812)
With Explicitly check for incoming commits on remotes on, the background check fetched only the repository selected in the branch widget. It now fetches every repository in the window whose branch has an upstream, one after another, stopping when the project or setting changes or a user's fetch / pull / push starts. With auto, a failure stops the check for that repository only; always retries every time. The interval is a new setting, vcs.git.incomingCheckInterval (minutes, 1-1440, default 15). Closes #3796 Co-authored-by: bertyhell <1710840+bertyhell@users.noreply.github.com>
This commit is contained in:
co-authored by
bertyhell
parent
245679cef8
commit
567e45f830
@@ -57,6 +57,8 @@ pub struct GitSettings {
|
||||
pub warn_detached_head: bool,
|
||||
/// Background check for incoming commits: `auto` | `always` | `never`.
|
||||
pub incoming_check: String,
|
||||
/// Minutes between background checks for incoming commits.
|
||||
pub incoming_check_interval: u32,
|
||||
/// Branch name globs, `;`/`,`-separated; force push to them is prohibited.
|
||||
pub protected_branches: String,
|
||||
/// Initial state of Commit Options › Sign-off Commit.
|
||||
@@ -89,6 +91,7 @@ impl Default for GitSettings {
|
||||
warn_crlf: true,
|
||||
warn_detached_head: true,
|
||||
incoming_check: "auto".into(),
|
||||
incoming_check_interval: 15,
|
||||
protected_branches: "master; main".into(),
|
||||
sign_off: false,
|
||||
warn_large_files: true,
|
||||
|
||||
@@ -147,7 +147,7 @@ With several repositories, the popup shows branches common to all of them, plus
|
||||
|
||||
## Sync with remotes
|
||||
|
||||
- **Fetch** fetches all repositories. OpenIDEA also checks for incoming commits in the background (after 20 seconds, then every 15 minutes); see **Explicitly check for incoming commits on remotes** in the Git settings.
|
||||
- **Fetch** fetches all repositories. OpenIDEA also checks for incoming commits in the background, fetching every repository whose branch has an upstream one after another (after 20 seconds, then every 15 minutes by default); see **Explicitly check for incoming commits on remotes** and **Check for incoming commits every** in the Git settings.
|
||||
- **Update Project…** (`⌘T` / `Ctrl+T`) pulls all repositories, by merge or by rebase. Uncommitted changes are stashed and restored. The **Update Project** dialog only shows when **Show options before Update** is on.
|
||||
- **Pull…** pulls a chosen remote branch into the current branch, with `--rebase`, `--ff-only`, `--no-ff`, `--squash` and other options.
|
||||
- **Push…** (`⇧⌘K` / `Ctrl+Shift+K`) lists outgoing commits and their files. Edit the target branch, pick a remote, and choose **Force (with lease)**, **Set upstream** or push tags. Force push is not allowed to protected branches (`master; main` by default). If the push is rejected, OpenIDEA offers to merge or rebase and push again.
|
||||
|
||||
@@ -145,7 +145,7 @@ OpenIDEA 会找到包含项目的仓库,以及向下最多四层的嵌套仓
|
||||
|
||||
## 与远程同步
|
||||
|
||||
- **获取** 会获取所有仓库。OpenIDEA 还会在后台检查传入的提交(打开项目 20 秒后检查一次,之后每 15 分钟一次),见 Git 设置中的 **显式检查远程上的传入提交**。
|
||||
- **获取** 会获取所有仓库。OpenIDEA 还会在后台检查传入的提交,依次获取每个分支有上游的仓库(打开项目 20 秒后检查一次,之后默认每 15 分钟一次),见 Git 设置中的 **显式检查远程上的传入提交** 和 **检查传入提交的间隔**。
|
||||
- **更新项目…**(`⌘T` / `Ctrl+T`)以合并或变基方式拉取所有仓库,未提交的更改会先贮藏再恢复。只有开启 **更新前显示选项** 时才会显示 **更新项目** 对话框。
|
||||
- **拉取…** 把选定的远程分支拉取到当前分支,可选 `--rebase`、`--ff-only`、`--no-ff`、`--squash` 等选项。
|
||||
- **推送…**(`⇧⌘K` / `Ctrl+Shift+K`)列出待推送的提交及其文件。可以修改目标分支、选择远程,并选择 **强制 (with lease)**、**设置上游** 或推送标签。受保护分支(默认 `master; main`)禁止强制推送。推送被拒绝时,OpenIDEA 会提供合并或变基后重新推送。
|
||||
|
||||
@@ -6041,6 +6041,8 @@ export type GitSettings = {
|
||||
warnDetachedHead?: boolean,
|
||||
/** Background check for incoming commits: `auto` | `always` | `never`. */
|
||||
incomingCheck?: string,
|
||||
/** Minutes between background checks for incoming commits. */
|
||||
incomingCheckInterval?: number,
|
||||
/** Branch name globs, `;`/`,`-separated; force push to them is prohibited. */
|
||||
protectedBranches?: string,
|
||||
/** Initial state of Commit Options › Sign-off Commit. */
|
||||
|
||||
@@ -600,10 +600,18 @@ export const VCS_PAGES: PageSpec[] = [
|
||||
k="vcs.git.incomingCheck"
|
||||
label="Explicitly check for incoming commits on remotes"
|
||||
options={INCOMING}
|
||||
hint="Fetches remotes in the background so incoming commits show in the Branches popup. Auto stops after an authentication failure."
|
||||
hint="Fetches the remotes of every repository in the background so incoming commits show in the Branches popup and the Project view. Auto stops checking a repository after it fails, for example on an authentication failure."
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
kind: "number",
|
||||
key: "vcs.git.incomingCheckInterval",
|
||||
label: "Check for incoming commits every",
|
||||
...L.incomingCheckInterval,
|
||||
integer: true,
|
||||
unit: "min",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
/** Root → upstream of its branch (`null` = none). */
|
||||
let upstreams: Record<string, string | null> = {};
|
||||
/** Roots whose fetch fails. */
|
||||
let failing = new Set<string>();
|
||||
let fetched: (string | null)[] = [];
|
||||
|
||||
vi.mock("@tauri-apps/api/core", async (importOriginal) => ({
|
||||
...(await importOriginal<typeof import("@tauri-apps/api/core")>()),
|
||||
Channel: class {
|
||||
onmessage: (line: string) => void = () => {};
|
||||
},
|
||||
}));
|
||||
|
||||
vi.mock("@/platform/ipc", async (importOriginal) => {
|
||||
const real = await importOriginal<typeof import("@/platform/ipc")>();
|
||||
return {
|
||||
...real,
|
||||
isTauri: () => true,
|
||||
commands: {
|
||||
...real.commands,
|
||||
vcsBranchInfo: async (root: string) => ({
|
||||
status: "ok",
|
||||
data: { head: "main", headCommit: "c1", upstream: upstreams[root] ?? null, ahead: 0, behind: 0 },
|
||||
}),
|
||||
vcsRemote: async (root: string | null) => {
|
||||
fetched.push(root);
|
||||
if (root && failing.has(root)) return { status: "error", error: { kind: "auth", message: "denied" } };
|
||||
return { status: "ok", data: null };
|
||||
},
|
||||
vcsRoots: async () => ({
|
||||
status: "ok",
|
||||
data: Object.keys(upstreams).map((root) => ({ root, operation: null, head: "main", headCommit: "c1" })),
|
||||
}),
|
||||
vcsStatus: async () => ({ status: "ok", data: [] }),
|
||||
vcsBranches: async () => ({ status: "ok", data: [] }),
|
||||
vcsStashes: async () => ({ status: "ok", data: [] }),
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
import { useProject } from "@/platform/project";
|
||||
import { fetchIncoming, installIncomingCheck } from "../incoming";
|
||||
import { useVcs } from "../store";
|
||||
|
||||
const ROOTS = ["/ws/a", "/ws/b", "/ws/c"];
|
||||
|
||||
beforeEach(() => {
|
||||
upstreams = { "/ws/a": "origin/main", "/ws/b": "origin/main", "/ws/c": "origin/dev" };
|
||||
failing = new Set();
|
||||
fetched = [];
|
||||
useVcs.setState({ available: true, root: "/ws", roots: ROOTS, repo: "/ws/a", remoteBusy: null, branch: null });
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.useRealTimers();
|
||||
useProject.setState({ settings: null });
|
||||
useVcs.setState({ available: false, root: null, roots: [], repo: null, remoteBusy: null });
|
||||
});
|
||||
|
||||
describe("fetchIncoming", () => {
|
||||
it("fetches every repository with an upstream, not only the selected one", async () => {
|
||||
upstreams["/ws/b"] = null;
|
||||
expect(await fetchIncoming(ROOTS, new Set())).toBe(true);
|
||||
expect(fetched).toEqual(["/ws/a", "/ws/c"]);
|
||||
});
|
||||
|
||||
it("stops checking only the repository that failed", async () => {
|
||||
failing.add("/ws/a");
|
||||
const failed = new Set<string>();
|
||||
await fetchIncoming(ROOTS, failed);
|
||||
expect(fetched).toEqual(ROOTS);
|
||||
expect([...failed]).toEqual(["/ws/a"]);
|
||||
fetched = [];
|
||||
await fetchIncoming(ROOTS, failed);
|
||||
expect(fetched).toEqual(["/ws/b", "/ws/c"]);
|
||||
});
|
||||
|
||||
it("leaves the remotes alone while the user's own remote operation runs", async () => {
|
||||
useVcs.setState({ remoteBusy: "Fetching" });
|
||||
expect(await fetchIncoming(ROOTS, new Set())).toBe(false);
|
||||
expect(fetched).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("installIncomingCheck", () => {
|
||||
it("checks after the configured interval", async () => {
|
||||
vi.useFakeTimers();
|
||||
useProject.setState({ settings: { vcs: { git: { incomingCheckInterval: 5 } } } } as never);
|
||||
const dispose = installIncomingCheck();
|
||||
await vi.advanceTimersByTimeAsync(20_000);
|
||||
expect(fetched).toEqual(ROOTS);
|
||||
fetched = [];
|
||||
await vi.advanceTimersByTimeAsync(4 * 60_000);
|
||||
expect(fetched).toEqual([]);
|
||||
await vi.advanceTimersByTimeAsync(60_000);
|
||||
expect(fetched).toEqual(ROOTS);
|
||||
dispose();
|
||||
});
|
||||
});
|
||||
@@ -1,65 +1,119 @@
|
||||
/**
|
||||
* Settings › Git › "Explicitly check for incoming commits on remotes": a quiet
|
||||
* background fetch (on project open, then every 15 minutes) so the branch
|
||||
* widget / Branches popup show incoming commits. `auto` stops for the session
|
||||
* after the first failure (credentials needed, offline); `never` disables it.
|
||||
* background fetch (on project open, then every `incomingCheckInterval` minutes)
|
||||
* so the branch widget, the Branches popup and the Project view show incoming
|
||||
* commits. Every repository whose branch has an upstream is fetched, one after
|
||||
* another. `auto` stops checking a repository for the session after its first
|
||||
* failure (credentials needed, offline); `never` disables it.
|
||||
*/
|
||||
import { Channel } from "@tauri-apps/api/core";
|
||||
import { call, commands, isTauri, nextRequestId } from "@/platform/ipc";
|
||||
import { onWorkflowSettingsChange, workflowSettings } from "@/platform/workflowSettings";
|
||||
import { logConsole } from "./ops";
|
||||
import { currentRepo, loadBranches, refreshNow, useVcs } from "./store";
|
||||
import { loadBranches, refreshNow, useVcs } from "./store";
|
||||
|
||||
const FIRST_DELAY = 20_000;
|
||||
const INTERVAL = 15 * 60_000;
|
||||
|
||||
const intervalMs = () => workflowSettings().vcs.git.incomingCheckInterval * 60_000;
|
||||
|
||||
/**
|
||||
* Fetches each of `roots` whose branch has an upstream, one at a time, skipping those in
|
||||
* `failed` (a repository that fails is added). Stops when `stale()` turns true or a fetch /
|
||||
* pull / push of the user's runs. Returns whether anything was fetched.
|
||||
*/
|
||||
export async function fetchIncoming(
|
||||
roots: readonly string[],
|
||||
failed: Set<string>,
|
||||
stale: () => boolean = () => false,
|
||||
): Promise<boolean> {
|
||||
let fetched = false;
|
||||
for (const root of roots) {
|
||||
if (stale() || useVcs.getState().remoteBusy) break;
|
||||
if (failed.has(root)) continue;
|
||||
const info = await call(commands.vcsBranchInfo(root)).catch(() => null);
|
||||
if (!info?.upstream || stale() || useVcs.getState().remoteBusy) continue;
|
||||
const channel = new Channel<string>();
|
||||
channel.onmessage = () => undefined;
|
||||
try {
|
||||
await call(commands.vcsRemote(root, nextRequestId(), { op: "fetch" }, channel));
|
||||
fetched = true;
|
||||
} catch (e) {
|
||||
failed.add(root);
|
||||
logConsole(
|
||||
"info",
|
||||
`Checking for incoming commits in ${root} failed: ${e instanceof Error ? e.message : String(e)}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
return fetched;
|
||||
}
|
||||
|
||||
export function installIncomingCheck(): () => void {
|
||||
if (!isTauri()) return () => undefined;
|
||||
let timer: ReturnType<typeof setTimeout> | undefined;
|
||||
let failed = false;
|
||||
/** Repositories whose check failed; `auto` leaves them alone for the session. */
|
||||
let failed = new Set<string>();
|
||||
let root: string | null = null;
|
||||
/** Bumped when the project or the setting changes; a check started before stops. */
|
||||
let generation = 0;
|
||||
let running = false;
|
||||
let disposed = false;
|
||||
|
||||
const schedule = (delay: number) => {
|
||||
clearTimeout(timer);
|
||||
if (disposed) return;
|
||||
const mode = workflowSettings().vcs.git.incomingCheck;
|
||||
if (mode === "never" || (mode === "auto" && failed) || !useVcs.getState().available) return;
|
||||
if (mode === "never" || !useVcs.getState().available) return;
|
||||
timer = setTimeout(() => void check(), delay);
|
||||
};
|
||||
|
||||
const check = async () => {
|
||||
const s = useVcs.getState();
|
||||
if (!s.available || !s.branch?.upstream || s.remoteBusy) return schedule(INTERVAL);
|
||||
const channel = new Channel<string>();
|
||||
channel.onmessage = () => undefined;
|
||||
// The check already running schedules the next one when it ends.
|
||||
if (running) return;
|
||||
running = true;
|
||||
const started = generation;
|
||||
try {
|
||||
await call(commands.vcsRemote(currentRepo(), nextRequestId(), { op: "fetch" }, channel));
|
||||
await refreshNow();
|
||||
if (useVcs.getState().branchesLoaded) void loadBranches().catch(() => undefined);
|
||||
} catch (e) {
|
||||
failed = true;
|
||||
logConsole("info", `Checking for incoming commits failed: ${e instanceof Error ? e.message : String(e)}`);
|
||||
const s = useVcs.getState();
|
||||
if (!s.available) return;
|
||||
// `always` retries failed repositories on every check.
|
||||
const skip = workflowSettings().vcs.git.incomingCheck === "always" ? new Set<string>() : failed;
|
||||
const roots = s.roots.length ? s.roots : s.root ? [s.root] : [];
|
||||
const fetched = await fetchIncoming(roots, skip, () => disposed || generation !== started);
|
||||
if (fetched && !disposed) {
|
||||
await refreshNow();
|
||||
if (useVcs.getState().branchesLoaded) void loadBranches().catch(() => undefined);
|
||||
}
|
||||
} finally {
|
||||
running = false;
|
||||
schedule(generation === started ? intervalMs() : FIRST_DELAY);
|
||||
}
|
||||
schedule(INTERVAL);
|
||||
};
|
||||
|
||||
const restart = () => {
|
||||
generation++;
|
||||
failed = new Set();
|
||||
schedule(FIRST_DELAY);
|
||||
};
|
||||
|
||||
const unsubVcs = useVcs.subscribe((s, prev) => {
|
||||
if (s.root === root && s.available === prev.available) return;
|
||||
root = s.root;
|
||||
failed = false;
|
||||
schedule(FIRST_DELAY);
|
||||
restart();
|
||||
});
|
||||
const unsubSettings = onWorkflowSettingsChange(
|
||||
(w) => w.vcs.git.incomingCheck,
|
||||
const unsubMode = onWorkflowSettingsChange((w) => w.vcs.git.incomingCheck, restart);
|
||||
const unsubInterval = onWorkflowSettingsChange(
|
||||
(w) => w.vcs.git.incomingCheckInterval,
|
||||
() => {
|
||||
failed = false;
|
||||
schedule(FIRST_DELAY);
|
||||
if (!running) schedule(intervalMs());
|
||||
},
|
||||
);
|
||||
root = useVcs.getState().root;
|
||||
schedule(FIRST_DELAY);
|
||||
return () => {
|
||||
disposed = true;
|
||||
clearTimeout(timer);
|
||||
unsubVcs();
|
||||
unsubSettings();
|
||||
unsubMode();
|
||||
unsubInterval();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2294,5 +2294,7 @@
|
||||
"This is a MySQL dump: restore it into a MySQL data source.": "This is a MySQL dump: restore it into a MySQL data source.",
|
||||
"This is a pg_dump archive: restore it with pg_restore.": "This is a pg_dump archive: restore it with pg_restore.",
|
||||
"This is a plain SQL dump: restore it with psql.": "This is a plain SQL dump: restore it with psql.",
|
||||
"Open the commit when the inline blame is clicked": "Open the commit when the inline blame is clicked"
|
||||
"Open the commit when the inline blame is clicked": "Open the commit when the inline blame is clicked",
|
||||
"Fetches the remotes of every repository in the background so incoming commits show in the Branches popup and the Project view. Auto stops checking a repository after it fails, for example on an authentication failure.": "Fetches the remotes of every repository in the background so incoming commits show in the Branches popup and the Project view. Auto stops checking a repository after it fails, for example on an authentication failure.",
|
||||
"Check for incoming commits every": "Check for incoming commits every"
|
||||
}
|
||||
|
||||
@@ -828,7 +828,6 @@
|
||||
"Fallback font": "Fuente de respaldo",
|
||||
"Fallback font:": "Fuente de respaldo:",
|
||||
"Fetch": "Fetch",
|
||||
"Fetches remotes in the background so incoming commits show in the Branches popup. Auto stops after an authentication failure.": "Obtiene los remotos en segundo plano para que las confirmaciones entrantes aparezcan en la ventana emergente Ramas. El modo Automático se detiene tras un fallo de autenticación.",
|
||||
"Field access": "Acceso a campo",
|
||||
"Field modification": "Modificación de campo",
|
||||
"Field watchpoints can be set on Java field declarations, or from the Variables view while suspended.": "Los puntos de observación de campo se pueden establecer en declaraciones de campos de Java o desde la vista Variables mientras está suspendido.",
|
||||
|
||||
@@ -765,7 +765,6 @@
|
||||
"Fallback font": "Police de secours",
|
||||
"Fallback font:": "Police de secours :",
|
||||
"Fetch": "Fetch",
|
||||
"Fetches remotes in the background so incoming commits show in the Branches popup. Auto stops after an authentication failure.": "Effectue un fetch des dépôts distants en arrière-plan pour afficher les commits entrants dans la fenêtre Branches. Le mode Auto s'arrête après un échec d'authentification.",
|
||||
"Field access": "Accès au champ",
|
||||
"Field modification": "Modification du champ",
|
||||
"Field watchpoints can be set on Java field declarations, or from the Variables view while suspended.": "Les points de surveillance de champ se posent sur les déclarations de champs Java, ou depuis la vue Variables pendant une suspension.",
|
||||
|
||||
@@ -864,7 +864,6 @@
|
||||
"Fallback font": "대체 글꼴",
|
||||
"Fallback font:": "대체 글꼴:",
|
||||
"Fetch": "페치",
|
||||
"Fetches remotes in the background so incoming commits show in the Branches popup. Auto stops after an authentication failure.": "백그라운드에서 원격을 페치하여 수신 커밋이 브랜치 팝업에 표시되도록 합니다. 자동은 인증 실패 후 중지됩니다.",
|
||||
"Field access": "필드 액세스",
|
||||
"Field modification": "필드 수정",
|
||||
"Field watchpoints can be set on Java field declarations, or from the Variables view while suspended.": "필드 감시점은 Java 필드 선언에서 설정하거나 일시 중지된 동안 변수 뷰에서 설정할 수 있습니다.",
|
||||
|
||||
@@ -820,7 +820,6 @@
|
||||
"Fallback font": "Czcionka zastępcza",
|
||||
"Fallback font:": "Czcionka zastępcza:",
|
||||
"Fetch": "Pobierz dane (Fetch)",
|
||||
"Fetches remotes in the background so incoming commits show in the Branches popup. Auto stops after an authentication failure.": "Pobiera dane z repozytoriów zdalnych w tle, aby przychodzące zatwierdzenia pojawiały się w oknie wyskakującym Gałęzie. Tryb Auto zatrzymuje się po niepowodzeniu uwierzytelniania.",
|
||||
"Field access": "Dostęp do pola",
|
||||
"Field modification": "Modyfikacja pola",
|
||||
"Field watchpoints can be set on Java field declarations, or from the Variables view while suspended.": "Punkty obserwacji pola można ustawiać na deklaracjach pól Java lub w widoku Zmienne podczas wstrzymania.",
|
||||
|
||||
@@ -820,7 +820,6 @@
|
||||
"Fallback font": "Fonte reserva",
|
||||
"Fallback font:": "Fonte reserva:",
|
||||
"Fetch": "Fetch",
|
||||
"Fetches remotes in the background so incoming commits show in the Branches popup. Auto stops after an authentication failure.": "Executa fetch dos remotos em segundo plano para que commits de entrada apareçam no pop-up Branches. O modo Auto para após uma falha de autenticação.",
|
||||
"Field access": "Acesso a campo",
|
||||
"Field modification": "Modificação de campo",
|
||||
"Field watchpoints can be set on Java field declarations, or from the Variables view while suspended.": "Pontos de inspeção de campo podem ser definidos em declarações de campos Java ou a partir da visualização Variáveis quando suspenso.",
|
||||
|
||||
@@ -1337,7 +1337,6 @@
|
||||
"Fallback font": "备用字体",
|
||||
"Fallback font:": "备用字体:",
|
||||
"Fetch": "获取",
|
||||
"Fetches remotes in the background so incoming commits show in the Branches popup. Auto stops after an authentication failure.": "在后台获取远程,以便传入的提交显示在“分支”弹出窗口中。“自动”在身份验证失败后停止。",
|
||||
"Field access": "字段访问",
|
||||
"Field modification": "字段修改",
|
||||
"Field watchpoints can be set on Java field declarations, or from the Variables view while suspended.": "字段监视点可以在 Java 字段声明上设置,也可以在挂起时从“变量”视图设置。",
|
||||
@@ -8679,5 +8678,7 @@
|
||||
"This is a MySQL dump: restore it into a MySQL data source.": "这是 MySQL 转储:请恢复到 MySQL 数据源。",
|
||||
"This is a pg_dump archive: restore it with pg_restore.": "这是 pg_dump 归档:请使用 pg_restore 恢复。",
|
||||
"This is a plain SQL dump: restore it with psql.": "这是纯 SQL 转储:请使用 psql 恢复。",
|
||||
"Open the commit when the inline blame is clicked": "点击内联 Git Blame 时打开提交"
|
||||
"Open the commit when the inline blame is clicked": "点击内联 Git Blame 时打开提交",
|
||||
"Fetches the remotes of every repository in the background so incoming commits show in the Branches popup and the Project view. Auto stops checking a repository after it fails, for example on an authentication failure.": "在后台获取每个仓库的远程,以便传入的提交显示在“分支”弹出窗口和项目视图中。“自动”在某个仓库检查失败(例如身份验证失败)后停止检查该仓库。",
|
||||
"Check for incoming commits every": "检查传入提交的间隔"
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ describe("validateWorkflow", () => {
|
||||
const v = validateWorkflow({
|
||||
vcs: {
|
||||
historyLimit: -5,
|
||||
git: { updateMethod: "squash", incomingCheck: "never", largeFileMb: 0 },
|
||||
git: { updateMethod: "squash", incomingCheck: "never", incomingCheckInterval: 0, largeFileMb: 0 },
|
||||
confirmation: { onPatchCreated: "always" },
|
||||
issueNavigation: [{ pattern: "" }, { pattern: "#(\\d+)", link: "x/$1" }],
|
||||
},
|
||||
@@ -47,6 +47,7 @@ describe("validateWorkflow", () => {
|
||||
expect(v.vcs.historyLimit).toBe(10);
|
||||
expect(v.vcs.git.updateMethod).toBe("merge");
|
||||
expect(v.vcs.git.incomingCheck).toBe("never");
|
||||
expect(v.vcs.git.incomingCheckInterval).toBe(1);
|
||||
expect(v.vcs.git.largeFileMb).toBe(1);
|
||||
expect(v.vcs.issueNavigation).toEqual([{ pattern: "#(\\d+)", link: "x/$1" }]);
|
||||
expect(v.vcs.commit.nonModal).toBe(true);
|
||||
|
||||
@@ -27,6 +27,8 @@ export interface GitSettingsValid {
|
||||
warnCrlf: boolean;
|
||||
warnDetachedHead: boolean;
|
||||
incomingCheck: IncomingCheck;
|
||||
/** Minutes between background checks for incoming commits. */
|
||||
incomingCheckInterval: number;
|
||||
protectedBranches: string;
|
||||
signOff: boolean;
|
||||
warnLargeFiles: boolean;
|
||||
@@ -204,6 +206,7 @@ export const WORKFLOW_LIMITS = {
|
||||
historyLimit: { min: 10, max: 100_000 },
|
||||
messageLimit: { min: 20, max: 500 },
|
||||
largeFileMb: { min: 1, max: 100_000 },
|
||||
incomingCheckInterval: { min: 1, max: 1440 },
|
||||
bufferKb: { min: 16, max: 1_048_576 },
|
||||
tooltipDelay: { min: 0, max: 10_000 },
|
||||
terminationTimeoutMs: { min: 0, max: 600_000 },
|
||||
@@ -243,6 +246,7 @@ export const DEFAULT_WORKFLOW: WorkflowSettings = {
|
||||
warnCrlf: true,
|
||||
warnDetachedHead: true,
|
||||
incomingCheck: "auto",
|
||||
incomingCheckInterval: 15,
|
||||
protectedBranches: "master; main",
|
||||
signOff: false,
|
||||
warnLargeFiles: true,
|
||||
@@ -401,6 +405,7 @@ export function validateVcs(raw: unknown): VcsSettingsValid {
|
||||
warnCrlf: bool(g.warnCrlf, d.git.warnCrlf),
|
||||
warnDetachedHead: bool(g.warnDetachedHead, d.git.warnDetachedHead),
|
||||
incomingCheck: oneOf(g.incomingCheck, ["auto", "always", "never"] as const, d.git.incomingCheck),
|
||||
incomingCheckInterval: num(g.incomingCheckInterval, d.git.incomingCheckInterval, L.incomingCheckInterval, true),
|
||||
protectedBranches: text(g.protectedBranches, d.git.protectedBranches),
|
||||
signOff: bool(g.signOff, d.git.signOff),
|
||||
warnLargeFiles: bool(g.warnLargeFiles, d.git.warnLargeFiles),
|
||||
|
||||
Reference in New Issue
Block a user