@andrebuzeli/git-mcp 10.0.8 → 10.0.9

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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,116 @@
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+ import * as os from 'os';
4
+ import { ProviderManager } from '../providers/providerManager.js';
5
+ import { IsomorphicGitAdapter } from '../utils/gitAdapter.js';
6
+ import { GitWorkflowTool } from '../tools/gitWorkflow.js';
7
+ import { GitFilesTool } from '../tools/gitFiles.js';
8
+ import { GitPushTool } from '../tools/gitPush.js';
9
+ import { GitRemoteTool } from '../tools/gitRemote.js';
10
+ // Set Credentials
11
+ process.env.GITEA_URL = "https://git.hubuzeli.com";
12
+ process.env.GITEA_TOKEN = "09b19262127241b2c608f1e58ac90af0cce21422";
13
+ process.env.GITEA_USERNAME = "andrebuzeli";
14
+ process.env.GITHUB_TOKEN = "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";
15
+ process.env.GITHUB_USERNAME = "Andre-Buzeli";
16
+ async function runCreationTest() {
17
+ const timestamp = Date.now();
18
+ const repoName = `test-gitea-persist-${timestamp}`;
19
+ // Create a persistent temp dir so we can inspect it if needed, or just let it be
20
+ const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'git-mcp-persist-'));
21
+ console.log(`šŸš€ Starting Gitea Persistence Test`);
22
+ console.log(`šŸ“‚ Local Dir: ${tempDir}`);
23
+ console.log(`šŸ“¦ Target Repo: ${repoName}`);
24
+ const providerManager = new ProviderManager();
25
+ const gitAdapter = new IsomorphicGitAdapter(providerManager);
26
+ const ctx = { providerManager, gitAdapter };
27
+ const workflow = new GitWorkflowTool();
28
+ const files = new GitFilesTool();
29
+ const push = new GitPushTool();
30
+ const remote = new GitRemoteTool();
31
+ try {
32
+ // 0. Init
33
+ console.log('\n0. Initializing Local Repo...');
34
+ // @ts-ignore
35
+ await workflow.handle({
36
+ action: 'init',
37
+ projectPath: tempDir
38
+ }, ctx);
39
+ // 1. Create (This creates repo on Gitea and GitHub)
40
+ console.log('\n1. Creating Remote Repositories...');
41
+ // @ts-ignore
42
+ const createResult = await workflow.handle({
43
+ action: 'create',
44
+ projectPath: tempDir,
45
+ name: repoName,
46
+ description: 'Test repository that should persist in Gitea',
47
+ private: true
48
+ }, ctx);
49
+ console.log('Create Result:', JSON.stringify(createResult, null, 2));
50
+ // 1.5 Add Remotes
51
+ console.log('\n1.5 Adding Remotes...');
52
+ if (createResult.providers.gitea?.success) {
53
+ const giteaUrl = createResult.providers.gitea.repo.clone_url;
54
+ // @ts-ignore
55
+ await remote.handle({
56
+ action: 'add',
57
+ projectPath: tempDir,
58
+ remoteName: 'gitea',
59
+ url: giteaUrl
60
+ }, ctx);
61
+ console.log(`Added gitea remote: ${giteaUrl}`);
62
+ }
63
+ if (createResult.providers.github?.success) {
64
+ const githubUrl = createResult.providers.github.repo.clone_url;
65
+ // @ts-ignore
66
+ await remote.handle({
67
+ action: 'add',
68
+ projectPath: tempDir,
69
+ remoteName: 'github',
70
+ url: githubUrl
71
+ }, ctx);
72
+ console.log(`Added github remote: ${githubUrl}`);
73
+ }
74
+ // 2. Create a file
75
+ console.log('\n2. Creating README...');
76
+ // @ts-ignore
77
+ await files.handle({
78
+ action: 'create',
79
+ projectPath: tempDir,
80
+ filePath: 'README.md',
81
+ content: `# Persistent Test Repo\n\nCreated at ${new Date().toISOString()}\n\nThis repository proves that the MCP tool can create and push to Gitea.`
82
+ });
83
+ // 3. Commit
84
+ console.log('\n3. Committing...');
85
+ // @ts-ignore
86
+ await workflow.handle({
87
+ action: 'commit',
88
+ projectPath: tempDir,
89
+ message: 'Initial commit with proof of life',
90
+ files: ['.']
91
+ }, ctx);
92
+ // 4. Push to Gitea
93
+ console.log('\n4. Pushing to Gitea...');
94
+ // @ts-ignore
95
+ await push.handle({
96
+ projectPath: tempDir,
97
+ remote: 'gitea',
98
+ branch: 'master'
99
+ }, ctx);
100
+ // 5. Push to GitHub
101
+ console.log('\n5. Pushing to GitHub...');
102
+ // @ts-ignore
103
+ await push.handle({
104
+ projectPath: tempDir,
105
+ remote: 'github',
106
+ branch: 'master'
107
+ }, ctx);
108
+ console.log('\nāœ… SUCCESS!');
109
+ console.log(`\nšŸ‘€ Verify Gitea: ${process.env.GITEA_URL}/${process.env.GITEA_USERNAME}/${repoName}`);
110
+ console.log(`\nšŸ‘€ Verify GitHub: https://github.com/${process.env.GITHUB_USERNAME}/${repoName}`);
111
+ }
112
+ catch (error) {
113
+ console.error('\nāŒ ERROR:', error);
114
+ }
115
+ }
116
+ runCreationTest().catch(console.error);
@@ -251,6 +251,15 @@ export class IsomorphicGitAdapter {
251
251
  // ========================================================================
252
252
  async commit(dir, message, providedAuthor) {
253
253
  const author = await this.getAuthor(dir, providedAuthor);
254
+ // Check if HEAD exists to determine if this is the initial commit
255
+ let parent;
256
+ try {
257
+ await git.resolveRef({ fs, dir, ref: 'HEAD' });
258
+ }
259
+ catch (err) {
260
+ // HEAD not found, this is the first commit
261
+ parent = [];
262
+ }
254
263
  const sha = await git.commit({
255
264
  fs,
256
265
  dir,
@@ -261,6 +270,7 @@ export class IsomorphicGitAdapter {
261
270
  timestamp: author.timestamp,
262
271
  timezoneOffset: author.timezoneOffset,
263
272
  },
273
+ parent,
264
274
  });
265
275
  return sha;
266
276
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andrebuzeli/git-mcp",
3
- "version": "10.0.8",
3
+ "version": "10.0.9",
4
4
  "type": "module",
5
5
  "description": "Professional MCP server for Git operations - STDIO UNIVERSAL: works in ANY IDE (Cursor, VSCode, Claude Desktop, Trae AI, Kiro.dev). Fully autonomous DUAL execution (GitHub + Gitea APIs) with automatic username detection. Smart parameter normalization handles both 'action' and 'command' formats. All tools execute on BOTH providers simultaneously. No manual parameters needed.",
6
6
  "main": "dist/index.js",