@andrebuzeli/git-mcp 15.1.4 → 15.1.6

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andrebuzeli/git-mcp",
3
- "version": "15.1.4",
3
+ "version": "15.1.6",
4
4
  "private": false,
5
5
  "description": "MCP server para Git com operações locais e sincronização paralela GitHub/Gitea",
6
6
  "license": "MIT",
@@ -112,11 +112,26 @@ QUANDO USAR:
112
112
  try {
113
113
  if (action === "list") {
114
114
  const remotes = await git.listRemotes(projectPath);
115
+
116
+ // Debug info: calculate what URLs should be
117
+ let repoName = getRepoNameFromPath(projectPath);
118
+ if (repoName === "GIT_MCP") repoName = "git-mcp";
119
+ const calculated = await pm.getRemoteUrls(repoName);
120
+
115
121
  return asToolResult({
116
122
  remotes,
117
123
  configured: remotes.length > 0,
118
124
  hasGithub: remotes.some(r => r.remote === "github"),
119
125
  hasGitea: remotes.some(r => r.remote === "gitea"),
126
+ debug: {
127
+ repoName,
128
+ calculatedUrls: calculated,
129
+ env: {
130
+ hasGithubToken: !!pm.githubToken,
131
+ hasGiteaToken: !!pm.giteaToken,
132
+ giteaUrl: pm.giteaUrl
133
+ }
134
+ },
120
135
  message: remotes.length === 0 ? "Nenhum remote configurado. Use action='ensure' para configurar." : undefined
121
136
  });
122
137
  }
@@ -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
- const repoName = path.basename(dir);
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
  }