@andrebuzeli/git-mcp 15.1.4 → 15.1.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/utils/gitAdapter.js +9 -3
package/package.json
CHANGED
package/src/utils/gitAdapter.js
CHANGED
|
@@ -3,7 +3,7 @@ import fs from "node:fs";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import http from "isomorphic-git/http/node";
|
|
5
5
|
import { MCPError, createError, mapExternalError } from "./errors.js";
|
|
6
|
-
import { getProvidersEnv } from "./repoHelpers.js";
|
|
6
|
+
import { getProvidersEnv, getRepoNameFromPath } from "./repoHelpers.js";
|
|
7
7
|
import { withRetry } from "./retry.js";
|
|
8
8
|
|
|
9
9
|
export class GitAdapter {
|
|
@@ -82,7 +82,10 @@ export class GitAdapter {
|
|
|
82
82
|
|
|
83
83
|
async ensureRemotes(dir, { githubUrl, giteaUrl }) {
|
|
84
84
|
const remotes = await git.listRemotes({ fs, dir });
|
|
85
|
-
|
|
85
|
+
// Usa o helper para normalizar o nome do repo
|
|
86
|
+
let repoName = getRepoNameFromPath(dir);
|
|
87
|
+
// Fix específico para seu caso: se normalizar para GIT_MCP, força git-mcp (padrão kebab-case)
|
|
88
|
+
if (repoName === "GIT_MCP") repoName = "git-mcp";
|
|
86
89
|
|
|
87
90
|
// Tenta obter URLs autenticadas/corretas do ProviderManager
|
|
88
91
|
const calculatedUrls = await this.pm.getRemoteUrls(repoName);
|
|
@@ -92,9 +95,11 @@ export class GitAdapter {
|
|
|
92
95
|
const ensure = async (name, url) => {
|
|
93
96
|
if (!url) return;
|
|
94
97
|
const existing = remotes.find(r => r.remote === name);
|
|
98
|
+
|
|
99
|
+
// SEMPRE força a atualização se a URL for diferente
|
|
100
|
+
// Isso garante que a URL do ENV (mcp.json) tenha prioridade sobre o .git/config local
|
|
95
101
|
if (existing) {
|
|
96
102
|
if (existing.url !== url) {
|
|
97
|
-
// URL mudou (ex: token novo, user diferente, host diferente)
|
|
98
103
|
await git.deleteRemote({ fs, dir, remote: name });
|
|
99
104
|
await git.addRemote({ fs, dir, remote: name, url });
|
|
100
105
|
}
|
|
@@ -107,6 +112,7 @@ export class GitAdapter {
|
|
|
107
112
|
await ensure("gitea", targetGitea);
|
|
108
113
|
|
|
109
114
|
// Origin prefere GitHub, fallback para Gitea
|
|
115
|
+
// Também força atualização do origin se necessário
|
|
110
116
|
const originUrl = targetGithub || targetGitea;
|
|
111
117
|
if (originUrl) await ensure("origin", originUrl);
|
|
112
118
|
}
|