@andre.buzeli/git-mcp 16.0.3 → 16.0.5
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/package.json +1 -1
- package/src/tools/git-workflow.js +20 -7
- package/src/utils/gitAdapter.js +6 -6
package/package.json
CHANGED
|
@@ -292,8 +292,13 @@ EXEMPLOS DE USO:
|
|
|
292
292
|
}
|
|
293
293
|
|
|
294
294
|
const ensured = await pm.ensureRepos({ repoName: repo, createIfMissing: true, isPublic, organization });
|
|
295
|
-
|
|
296
|
-
|
|
295
|
+
// Build URLs from actual ensureRepos results (handles GitHub fallback to personal account)
|
|
296
|
+
const githubUrl = ensured.github?.ok && ensured.github.repo
|
|
297
|
+
? `https://github.com/${ensured.github.repo}.git` : "";
|
|
298
|
+
const giteaBase = pm.giteaUrl?.replace(/\/$/, "");
|
|
299
|
+
const giteaUrl = ensured.gitea?.ok && ensured.gitea.repo && giteaBase
|
|
300
|
+
? `${giteaBase}/${ensured.gitea.repo}.git` : "";
|
|
301
|
+
await git.ensureRemotes(projectPath, { githubUrl, giteaUrl, organization });
|
|
297
302
|
const remotes = await git.listRemotes(projectPath);
|
|
298
303
|
return asToolResult({ success: true, ensured, remotes, isPrivate: !isPublic, organization: organization || undefined }, { tool: 'workflow', action: 'ensure-remotes' });
|
|
299
304
|
}
|
|
@@ -311,9 +316,11 @@ EXEMPLOS DE USO:
|
|
|
311
316
|
});
|
|
312
317
|
}
|
|
313
318
|
|
|
319
|
+
const organization = args.organization || undefined;
|
|
320
|
+
|
|
314
321
|
// Retry logic for push (often fails due to network or concurrent updates)
|
|
315
322
|
const result = await withRetry(
|
|
316
|
-
() => git.pushParallel(projectPath, branch, force),
|
|
323
|
+
() => git.pushParallel(projectPath, branch, force, organization),
|
|
317
324
|
3,
|
|
318
325
|
"push"
|
|
319
326
|
);
|
|
@@ -394,15 +401,21 @@ EXEMPLOS DE USO:
|
|
|
394
401
|
const organization = args.organization || undefined;
|
|
395
402
|
if (organization) {
|
|
396
403
|
const repo = getRepoNameFromPath(projectPath);
|
|
397
|
-
|
|
398
|
-
const
|
|
399
|
-
|
|
404
|
+
const isPublic = args.isPublic === true;
|
|
405
|
+
const ensured = await pm.ensureRepos({ repoName: repo, createIfMissing: true, isPublic, organization });
|
|
406
|
+
// Build URLs from actual ensureRepos results (handles GitHub fallback to personal account)
|
|
407
|
+
const githubUrl = ensured.github?.ok && ensured.github.repo
|
|
408
|
+
? `https://github.com/${ensured.github.repo}.git` : "";
|
|
409
|
+
const giteaBase = pm.giteaUrl?.replace(/\/$/, "");
|
|
410
|
+
const giteaUrl = ensured.gitea?.ok && ensured.gitea.repo && giteaBase
|
|
411
|
+
? `${giteaBase}/${ensured.gitea.repo}.git` : "";
|
|
412
|
+
await git.ensureRemotes(projectPath, { githubUrl, giteaUrl, organization });
|
|
400
413
|
}
|
|
401
414
|
|
|
402
415
|
// 4. Push
|
|
403
416
|
const branch = await git.getCurrentBranch(projectPath);
|
|
404
417
|
const pushResult = await withRetry(
|
|
405
|
-
() => git.pushParallel(projectPath, branch, force),
|
|
418
|
+
() => git.pushParallel(projectPath, branch, force, organization),
|
|
406
419
|
3,
|
|
407
420
|
"push"
|
|
408
421
|
);
|
package/src/utils/gitAdapter.js
CHANGED
|
@@ -536,14 +536,14 @@ export class GitAdapter {
|
|
|
536
536
|
}
|
|
537
537
|
|
|
538
538
|
// ============ REMOTES ============
|
|
539
|
-
async ensureRemotes(dir, { githubUrl, giteaUrl }) {
|
|
539
|
+
async ensureRemotes(dir, { githubUrl, giteaUrl, organization } = {}) {
|
|
540
540
|
const remotesOutput = await this._exec(dir, ["remote", "-v"]);
|
|
541
541
|
const remotes = new Set(remotesOutput.split("\n").map(l => l.split("\t")[0]).filter(Boolean));
|
|
542
542
|
|
|
543
543
|
const repoName = getRepoNameFromPath(dir);
|
|
544
|
-
const calcUrls = await this.pm.getRemoteUrls(repoName);
|
|
545
|
-
const targetGithub = calcUrls.github
|
|
546
|
-
const targetGitea = calcUrls.gitea
|
|
544
|
+
const calcUrls = await this.pm.getRemoteUrls(repoName, organization);
|
|
545
|
+
const targetGithub = githubUrl || calcUrls.github;
|
|
546
|
+
const targetGitea = giteaUrl || calcUrls.gitea;
|
|
547
547
|
|
|
548
548
|
const setRemote = async (name, url) => {
|
|
549
549
|
if (!url) return;
|
|
@@ -615,8 +615,8 @@ export class GitAdapter {
|
|
|
615
615
|
}
|
|
616
616
|
}
|
|
617
617
|
|
|
618
|
-
async pushParallel(dir, branch, force = false) {
|
|
619
|
-
await this.ensureRemotes(dir, {});
|
|
618
|
+
async pushParallel(dir, branch, force = false, organization) {
|
|
619
|
+
await this.ensureRemotes(dir, { organization });
|
|
620
620
|
const remotesStr = await this._exec(dir, ["remote"]);
|
|
621
621
|
const remotes = remotesStr.split("\n").filter(r => ["github", "gitea"].includes(r.trim()));
|
|
622
622
|
|