@dylanpiercey/work 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +33 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -15566,6 +15566,29 @@ function withoutDismissed(workspaceId, fullName, list) {
|
|
|
15566
15566
|
//#endregion
|
|
15567
15567
|
//#region src/server/diff.ts
|
|
15568
15568
|
var MAX_FILE_BYTES = 5e5;
|
|
15569
|
+
/** Diffs compare against remote-tracking refs, which only move when this
|
|
15570
|
+
* machine fetches or pushes — a PR merged on GitHub leaves them stale and
|
|
15571
|
+
* the diff shows already-merged work until the next fetch. Opening the
|
|
15572
|
+
* diff freshens the base refs itself (throttled per repo; each ref
|
|
15573
|
+
* fetched independently since one missing ref fails a combined fetch,
|
|
15574
|
+
* and capped so a slow remote can't hang the view — stale refs then
|
|
15575
|
+
* self-correct on the next open). */
|
|
15576
|
+
var FETCH_TTL_MS = 3e4;
|
|
15577
|
+
var FETCH_WAIT_MS = 8e3;
|
|
15578
|
+
var lastFetch = /* @__PURE__ */ new Map();
|
|
15579
|
+
async function freshenBaseRefs(dir, fullName, refs) {
|
|
15580
|
+
const now = Date.now();
|
|
15581
|
+
if (now - (lastFetch.get(fullName) ?? 0) < FETCH_TTL_MS) return;
|
|
15582
|
+
lastFetch.set(fullName, now);
|
|
15583
|
+
const fetches = [...new Set(refs)].map((ref) => git([
|
|
15584
|
+
"fetch",
|
|
15585
|
+
"--quiet",
|
|
15586
|
+
"--no-tags",
|
|
15587
|
+
"origin",
|
|
15588
|
+
ref
|
|
15589
|
+
], dir).catch(() => {}));
|
|
15590
|
+
await Promise.race([Promise.all(fetches), new Promise((resolve) => setTimeout(resolve, FETCH_WAIT_MS))]);
|
|
15591
|
+
}
|
|
15569
15592
|
/** The ref the working tree is compared against by default, best first:
|
|
15570
15593
|
* the workspace branch's remote (a lane worktree then shows its whole
|
|
15571
15594
|
* delta vs the pushed workspace branch, and a worktree on the workspace
|
|
@@ -15605,6 +15628,16 @@ async function resolveBase(dir, wsBranch, baseBranch, baseRef) {
|
|
|
15605
15628
|
async function workspaceDiff(ws, baseRef) {
|
|
15606
15629
|
return Promise.all(ws.repos.map(async (repo) => {
|
|
15607
15630
|
const dir = path.join(ws.path, repo.worktree);
|
|
15631
|
+
const branch = await git([
|
|
15632
|
+
"rev-parse",
|
|
15633
|
+
"--abbrev-ref",
|
|
15634
|
+
"HEAD"
|
|
15635
|
+
], dir).catch(() => "HEAD");
|
|
15636
|
+
await freshenBaseRefs(dir, repo.full_name, [
|
|
15637
|
+
ws.branch,
|
|
15638
|
+
...branch !== "HEAD" ? [branch] : [],
|
|
15639
|
+
...baseRef ? [baseRef] : [repo.base_branch]
|
|
15640
|
+
]);
|
|
15608
15641
|
const { mergeBase, label } = await resolveBase(dir, ws.branch, repo.base_branch, baseRef);
|
|
15609
15642
|
const [nameStatus, untracked] = await Promise.all([git([
|
|
15610
15643
|
"diff",
|