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.
- package/dist/index.js +31 -10
- package/dist/index.js.map +2 -2
- package/dist/mcp-server.js +31 -10
- package/dist/mcp-server.js.map +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -25,7 +25,8 @@ var GIT_CONSTANTS = {
|
|
|
25
25
|
REMOTES: "refs/remotes/origin",
|
|
26
26
|
REMOTES_ORIGIN: "refs/remotes/origin/*"
|
|
27
27
|
},
|
|
28
|
-
FETCH_CONFIG: "+refs/heads/*:refs/remotes/origin/*"
|
|
28
|
+
FETCH_CONFIG: "+refs/heads/*:refs/remotes/origin/*",
|
|
29
|
+
PROGRESS_BUCKET_PERCENT: 25
|
|
29
30
|
};
|
|
30
31
|
var GIT_OPERATIONS = {
|
|
31
32
|
MERGE_HEAD: "MERGE_HEAD",
|
|
@@ -2755,10 +2756,11 @@ var WorktreeStatusService = class {
|
|
|
2755
2756
|
const reasons = [];
|
|
2756
2757
|
if (!isClean) reasons.push("uncommitted changes");
|
|
2757
2758
|
if (hasUnpushedCommits) reasons.push("unpushed commits");
|
|
2759
|
+
if (hasStashedChanges) reasons.push("stashed changes");
|
|
2758
2760
|
if (hasOperationInProgress) reasons.push("operation in progress");
|
|
2759
2761
|
if (hasModifiedSubmodules) reasons.push("modified submodules");
|
|
2760
2762
|
if (upstreamGone) reasons.push("upstream gone");
|
|
2761
|
-
const canRemove = isClean && !hasUnpushedCommits && !hasOperationInProgress && !hasModifiedSubmodules;
|
|
2763
|
+
const canRemove = isClean && !hasUnpushedCommits && !hasStashedChanges && !hasOperationInProgress && !hasModifiedSubmodules;
|
|
2762
2764
|
const details = includeDetails ? this.buildStatusDetails(snap) : void 0;
|
|
2763
2765
|
return {
|
|
2764
2766
|
isClean,
|
|
@@ -3098,13 +3100,33 @@ var GitService = class {
|
|
|
3098
3100
|
const key = `${path6.resolve(dirPath)}::${useLfsSkip ? "1" : "0"}`;
|
|
3099
3101
|
let git = this.gitInstances.get(key);
|
|
3100
3102
|
if (!git) {
|
|
3101
|
-
const
|
|
3102
|
-
const base = block > 0 ? simpleGit4(dirPath, { timeout: { block } }) : simpleGit4(dirPath);
|
|
3103
|
+
const base = simpleGit4(dirPath, this.buildSimpleGitOptions(this.getFetchTimeoutMs()));
|
|
3103
3104
|
git = useLfsSkip ? base.env({ [ENV_CONSTANTS.GIT_LFS_SKIP_SMUDGE]: "1" }) : base;
|
|
3104
3105
|
this.gitInstances.set(key, git);
|
|
3105
3106
|
}
|
|
3106
3107
|
return git;
|
|
3107
3108
|
}
|
|
3109
|
+
buildSimpleGitOptions(blockMs) {
|
|
3110
|
+
const options = { progress: this.makeProgressHandler() };
|
|
3111
|
+
if (blockMs > 0) options.timeout = { block: blockMs };
|
|
3112
|
+
return options;
|
|
3113
|
+
}
|
|
3114
|
+
makeProgressHandler() {
|
|
3115
|
+
const lastBucket = /* @__PURE__ */ new Map();
|
|
3116
|
+
return (event) => {
|
|
3117
|
+
if (event.method !== "fetch" && event.method !== "clone" && event.method !== "pull") return;
|
|
3118
|
+
const key = `${event.method}:${event.stage}`;
|
|
3119
|
+
const bucket = Math.floor(event.progress / GIT_CONSTANTS.PROGRESS_BUCKET_PERCENT);
|
|
3120
|
+
let last = lastBucket.get(key) ?? -1;
|
|
3121
|
+
if (bucket < last) {
|
|
3122
|
+
last = -1;
|
|
3123
|
+
}
|
|
3124
|
+
if (bucket <= last && event.progress < 100) return;
|
|
3125
|
+
lastBucket.set(key, bucket);
|
|
3126
|
+
const total = event.total > 0 ? `${event.processed}/${event.total}` : `${event.processed}`;
|
|
3127
|
+
this.logger.info(` \u21B3 ${event.method} ${event.stage}: ${event.progress}% (${total})`);
|
|
3128
|
+
};
|
|
3129
|
+
}
|
|
3108
3130
|
updateLogger(logger) {
|
|
3109
3131
|
this.logger = logger;
|
|
3110
3132
|
this.sparseCheckoutService.updateLogger(logger);
|
|
@@ -3116,10 +3138,9 @@ var GitService = class {
|
|
|
3116
3138
|
} catch {
|
|
3117
3139
|
this.logger.info(`Cloning from "${repoUrl}" as bare repository into "${this.bareRepoPath}"...`);
|
|
3118
3140
|
await fs4.mkdir(path6.dirname(this.bareRepoPath), { recursive: true });
|
|
3119
|
-
const
|
|
3120
|
-
const cloneBase = cloneBlock > 0 ? simpleGit4({ timeout: { block: cloneBlock } }) : simpleGit4();
|
|
3141
|
+
const cloneBase = simpleGit4(this.buildSimpleGitOptions(this.getCloneTimeoutMs()));
|
|
3121
3142
|
const cloneGit = this.isLfsSkipEnabled() ? cloneBase.env({ [ENV_CONSTANTS.GIT_LFS_SKIP_SMUDGE]: "1" }) : cloneBase;
|
|
3122
|
-
await cloneGit.clone(repoUrl, this.bareRepoPath, ["--bare"]);
|
|
3143
|
+
await cloneGit.clone(repoUrl, this.bareRepoPath, ["--bare", "--progress"]);
|
|
3123
3144
|
this.logger.info("\u2705 Clone successful.");
|
|
3124
3145
|
}
|
|
3125
3146
|
const bareGit = this.getCachedGit(this.bareRepoPath);
|
|
@@ -3133,7 +3154,7 @@ var GitService = class {
|
|
|
3133
3154
|
await bareGit.addConfig("remote.origin.fetch", "+refs/heads/*:refs/remotes/origin/*");
|
|
3134
3155
|
}
|
|
3135
3156
|
this.logger.info("Fetching remote branches...");
|
|
3136
|
-
await bareGit.fetch(["--all"]);
|
|
3157
|
+
await bareGit.fetch(["--all", "--progress"]);
|
|
3137
3158
|
this.defaultBranch = await this.detectDefaultBranch(bareGit);
|
|
3138
3159
|
this.mainWorktreePath = path6.join(this.config.worktreeDir, this.defaultBranch);
|
|
3139
3160
|
let needsMainWorktree = true;
|
|
@@ -3211,12 +3232,12 @@ var GitService = class {
|
|
|
3211
3232
|
this.assertInitialized();
|
|
3212
3233
|
this.logger.info("Fetching latest data from remote...");
|
|
3213
3234
|
const git = this.getCachedGit(this.mainWorktreePath, this.isLfsSkipEnabled());
|
|
3214
|
-
await git.fetch(["--all", "--prune"]);
|
|
3235
|
+
await git.fetch(["--all", "--prune", "--progress"]);
|
|
3215
3236
|
}
|
|
3216
3237
|
async fetchBranch(branchName) {
|
|
3217
3238
|
this.assertInitialized();
|
|
3218
3239
|
const git = this.getCachedGit(this.mainWorktreePath, this.isLfsSkipEnabled());
|
|
3219
|
-
await git.fetch(["origin", branchName, "--prune"]);
|
|
3240
|
+
await git.fetch(["origin", branchName, "--prune", "--progress"]);
|
|
3220
3241
|
}
|
|
3221
3242
|
assertInitialized() {
|
|
3222
3243
|
if (!this.git) {
|