sync-worktrees 3.5.0 → 3.6.1

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.
@@ -27,7 +27,8 @@ var GIT_CONSTANTS = {
27
27
  REMOTES: "refs/remotes/origin",
28
28
  REMOTES_ORIGIN: "refs/remotes/origin/*"
29
29
  },
30
- FETCH_CONFIG: "+refs/heads/*:refs/remotes/origin/*"
30
+ FETCH_CONFIG: "+refs/heads/*:refs/remotes/origin/*",
31
+ PROGRESS_BUCKET_PERCENT: 25
31
32
  };
32
33
  var GIT_OPERATIONS = {
33
34
  MERGE_HEAD: "MERGE_HEAD",
@@ -1484,10 +1485,11 @@ var WorktreeStatusService = class {
1484
1485
  const reasons = [];
1485
1486
  if (!isClean) reasons.push("uncommitted changes");
1486
1487
  if (hasUnpushedCommits) reasons.push("unpushed commits");
1488
+ if (hasStashedChanges) reasons.push("stashed changes");
1487
1489
  if (hasOperationInProgress) reasons.push("operation in progress");
1488
1490
  if (hasModifiedSubmodules) reasons.push("modified submodules");
1489
1491
  if (upstreamGone) reasons.push("upstream gone");
1490
- const canRemove = isClean && !hasUnpushedCommits && !hasOperationInProgress && !hasModifiedSubmodules;
1492
+ const canRemove = isClean && !hasUnpushedCommits && !hasStashedChanges && !hasOperationInProgress && !hasModifiedSubmodules;
1491
1493
  const details = includeDetails ? this.buildStatusDetails(snap) : void 0;
1492
1494
  return {
1493
1495
  isClean,
@@ -1827,13 +1829,33 @@ var GitService = class {
1827
1829
  const key = `${path6.resolve(dirPath)}::${useLfsSkip ? "1" : "0"}`;
1828
1830
  let git = this.gitInstances.get(key);
1829
1831
  if (!git) {
1830
- const block = this.getFetchTimeoutMs();
1831
- const base = block > 0 ? simpleGit4(dirPath, { timeout: { block } }) : simpleGit4(dirPath);
1832
+ const base = simpleGit4(dirPath, this.buildSimpleGitOptions(this.getFetchTimeoutMs()));
1832
1833
  git = useLfsSkip ? base.env({ [ENV_CONSTANTS.GIT_LFS_SKIP_SMUDGE]: "1" }) : base;
1833
1834
  this.gitInstances.set(key, git);
1834
1835
  }
1835
1836
  return git;
1836
1837
  }
1838
+ buildSimpleGitOptions(blockMs) {
1839
+ const options = { progress: this.makeProgressHandler() };
1840
+ if (blockMs > 0) options.timeout = { block: blockMs };
1841
+ return options;
1842
+ }
1843
+ makeProgressHandler() {
1844
+ const lastBucket = /* @__PURE__ */ new Map();
1845
+ return (event) => {
1846
+ if (event.method !== "fetch" && event.method !== "clone" && event.method !== "pull") return;
1847
+ const key = `${event.method}:${event.stage}`;
1848
+ const bucket = Math.floor(event.progress / GIT_CONSTANTS.PROGRESS_BUCKET_PERCENT);
1849
+ let last = lastBucket.get(key) ?? -1;
1850
+ if (bucket < last) {
1851
+ last = -1;
1852
+ }
1853
+ if (bucket <= last && event.progress < 100) return;
1854
+ lastBucket.set(key, bucket);
1855
+ const total = event.total > 0 ? `${event.processed}/${event.total}` : `${event.processed}`;
1856
+ this.logger.info(` \u21B3 ${event.method} ${event.stage}: ${event.progress}% (${total})`);
1857
+ };
1858
+ }
1837
1859
  updateLogger(logger) {
1838
1860
  this.logger = logger;
1839
1861
  this.sparseCheckoutService.updateLogger(logger);
@@ -1845,10 +1867,9 @@ var GitService = class {
1845
1867
  } catch {
1846
1868
  this.logger.info(`Cloning from "${repoUrl}" as bare repository into "${this.bareRepoPath}"...`);
1847
1869
  await fs4.mkdir(path6.dirname(this.bareRepoPath), { recursive: true });
1848
- const cloneBlock = this.getCloneTimeoutMs();
1849
- const cloneBase = cloneBlock > 0 ? simpleGit4({ timeout: { block: cloneBlock } }) : simpleGit4();
1870
+ const cloneBase = simpleGit4(this.buildSimpleGitOptions(this.getCloneTimeoutMs()));
1850
1871
  const cloneGit = this.isLfsSkipEnabled() ? cloneBase.env({ [ENV_CONSTANTS.GIT_LFS_SKIP_SMUDGE]: "1" }) : cloneBase;
1851
- await cloneGit.clone(repoUrl, this.bareRepoPath, ["--bare"]);
1872
+ await cloneGit.clone(repoUrl, this.bareRepoPath, ["--bare", "--progress"]);
1852
1873
  this.logger.info("\u2705 Clone successful.");
1853
1874
  }
1854
1875
  const bareGit = this.getCachedGit(this.bareRepoPath);
@@ -1862,7 +1883,7 @@ var GitService = class {
1862
1883
  await bareGit.addConfig("remote.origin.fetch", "+refs/heads/*:refs/remotes/origin/*");
1863
1884
  }
1864
1885
  this.logger.info("Fetching remote branches...");
1865
- await bareGit.fetch(["--all"]);
1886
+ await bareGit.fetch(["--all", "--progress"]);
1866
1887
  this.defaultBranch = await this.detectDefaultBranch(bareGit);
1867
1888
  this.mainWorktreePath = path6.join(this.config.worktreeDir, this.defaultBranch);
1868
1889
  let needsMainWorktree = true;
@@ -1940,12 +1961,12 @@ var GitService = class {
1940
1961
  this.assertInitialized();
1941
1962
  this.logger.info("Fetching latest data from remote...");
1942
1963
  const git = this.getCachedGit(this.mainWorktreePath, this.isLfsSkipEnabled());
1943
- await git.fetch(["--all", "--prune"]);
1964
+ await git.fetch(["--all", "--prune", "--progress"]);
1944
1965
  }
1945
1966
  async fetchBranch(branchName) {
1946
1967
  this.assertInitialized();
1947
1968
  const git = this.getCachedGit(this.mainWorktreePath, this.isLfsSkipEnabled());
1948
- await git.fetch(["origin", branchName, "--prune"]);
1969
+ await git.fetch(["origin", branchName, "--prune", "--progress"]);
1949
1970
  }
1950
1971
  assertInitialized() {
1951
1972
  if (!this.git) {