@andrebuzeli/git-mcp 3.0.1 → 3.1.0
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/README.md +329 -356
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +83 -82
- package/dist/server.js.map +1 -1
- package/dist/tools/git-branches.d.ts +359 -125
- package/dist/tools/git-branches.d.ts.map +1 -1
- package/dist/tools/git-branches.js +530 -179
- package/dist/tools/git-branches.js.map +1 -1
- package/dist/tools/git-commits.d.ts +2 -2
- package/dist/tools/git-config.d.ts +2 -2
- package/dist/tools/git-files.d.ts +406 -246
- package/dist/tools/git-files.d.ts.map +1 -1
- package/dist/tools/git-files.js +499 -556
- package/dist/tools/git-files.js.map +1 -1
- package/dist/tools/git-issues.d.ts +10 -10
- package/dist/tools/git-packages.d.ts +2 -2
- package/dist/tools/git-projects.d.ts +57 -142
- package/dist/tools/git-projects.d.ts.map +1 -1
- package/dist/tools/git-projects.js +283 -281
- package/dist/tools/git-projects.js.map +1 -1
- package/dist/tools/git-publish.d.ts +327 -0
- package/dist/tools/git-publish.d.ts.map +1 -0
- package/dist/tools/git-publish.js +632 -0
- package/dist/tools/git-publish.js.map +1 -0
- package/dist/tools/git-pulls.d.ts +16 -16
- package/dist/tools/git-releases.d.ts +401 -131
- package/dist/tools/git-releases.d.ts.map +1 -1
- package/dist/tools/git-releases.js +469 -374
- package/dist/tools/git-releases.js.map +1 -1
- package/dist/tools/git-remote.d.ts +4 -4
- package/dist/tools/git-repositories.d.ts +8 -8
- package/dist/tools/git-reset.d.ts +65 -106
- package/dist/tools/git-reset.d.ts.map +1 -1
- package/dist/tools/git-reset.js +149 -265
- package/dist/tools/git-reset.js.map +1 -1
- package/dist/tools/git-stash.d.ts +68 -110
- package/dist/tools/git-stash.d.ts.map +1 -1
- package/dist/tools/git-stash.js +186 -311
- package/dist/tools/git-stash.js.map +1 -1
- package/dist/tools/git-sync.d.ts +80 -149
- package/dist/tools/git-sync.d.ts.map +1 -1
- package/dist/tools/git-sync.js +246 -346
- package/dist/tools/git-sync.js.map +1 -1
- package/dist/tools/git-tags.d.ts +2 -2
- package/dist/tools/git-update-project.d.ts +159 -4
- package/dist/tools/git-update-project.d.ts.map +1 -1
- package/dist/tools/git-update-project.js +349 -7
- package/dist/tools/git-update-project.js.map +1 -1
- package/dist/tools/git-workflow.d.ts +259 -200
- package/dist/tools/git-workflow.d.ts.map +1 -1
- package/dist/tools/git-workflow.js +498 -424
- package/dist/tools/git-workflow.js.map +1 -1
- package/package.json +14 -5
- package/dist/tools/git-undo.d.ts +0 -268
- package/dist/tools/git-undo.d.ts.map +0 -1
- package/dist/tools/git-undo.js +0 -516
- package/dist/tools/git-undo.js.map +0 -1
- package/dist/tools/git-versioning.d.ts +0 -286
- package/dist/tools/git-versioning.d.ts.map +0 -1
- package/dist/tools/git-versioning.js +0 -483
- package/dist/tools/git-versioning.js.map +0 -1
package/dist/tools/git-reset.js
CHANGED
|
@@ -2,338 +2,222 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.gitResetTool = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
const
|
|
5
|
+
const terminal_controller_js_1 = require("../utils/terminal-controller.js");
|
|
6
6
|
/**
|
|
7
7
|
* Tool: git-reset
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
9
|
+
* DESCRIÇÃO:
|
|
10
|
+
* Gerenciamento de reset Git (GitHub + Gitea) com múltiplas ações
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
* FUNCIONALIDADES:
|
|
13
|
+
* - Reset soft (mantém mudanças no staging)
|
|
14
|
+
* - Reset mixed (padrão, remove do staging)
|
|
15
|
+
* - Reset hard (remove todas as mudanças)
|
|
16
|
+
* - Reset para commit específico
|
|
17
|
+
* - Reset de branch
|
|
18
|
+
*
|
|
19
|
+
* USO:
|
|
20
|
+
* - Para desfazer commits
|
|
21
|
+
* - Para limpar staging area
|
|
22
|
+
* - Para voltar a estado anterior
|
|
23
|
+
* - Para remover mudanças não commitadas
|
|
24
|
+
*
|
|
25
|
+
* RECOMENDAÇÕES:
|
|
26
|
+
* - Use com cuidado, especialmente reset hard
|
|
27
|
+
* - Faça backup antes de resets destrutivos
|
|
28
|
+
* - Teste em branches locais primeiro
|
|
14
29
|
*/
|
|
15
|
-
const GitResetInputSchema = zod_1.z.
|
|
16
|
-
zod_1.z.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
zod_1.z.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
preview: zod_1.z.boolean().optional().default(true)
|
|
29
|
-
}),
|
|
30
|
-
zod_1.z.object({
|
|
31
|
-
action: zod_1.z.literal('hard'),
|
|
32
|
-
projectPath: zod_1.z.string(),
|
|
33
|
-
to: zod_1.z.string().optional().default('HEAD~1'),
|
|
34
|
-
confirm: zod_1.z.boolean().optional().default(false),
|
|
35
|
-
preview: zod_1.z.boolean().optional().default(true)
|
|
36
|
-
}),
|
|
37
|
-
zod_1.z.object({
|
|
38
|
-
action: zod_1.z.literal('preview'),
|
|
39
|
-
projectPath: zod_1.z.string(),
|
|
40
|
-
to: zod_1.z.string().optional().default('HEAD~1'),
|
|
41
|
-
mode: zod_1.z.enum(['soft', 'mixed', 'hard']).optional().default('mixed')
|
|
42
|
-
}),
|
|
43
|
-
zod_1.z.object({
|
|
44
|
-
action: zod_1.z.literal('undo-last-reset'),
|
|
45
|
-
projectPath: zod_1.z.string(),
|
|
46
|
-
confirm: zod_1.z.boolean().optional().default(false)
|
|
47
|
-
})
|
|
48
|
-
]);
|
|
30
|
+
const GitResetInputSchema = zod_1.z.object({
|
|
31
|
+
action: zod_1.z.enum(['soft', 'mixed', 'hard', 'reset-to-commit', 'reset-branch']),
|
|
32
|
+
// owner: obtido automaticamente do provider,
|
|
33
|
+
repo: zod_1.z.string(),
|
|
34
|
+
provider: zod_1.z.enum(['gitea', 'github']).describe('Provider to use (gitea or github)'),
|
|
35
|
+
projectPath: zod_1.z.string().describe('Local project path for git operations'),
|
|
36
|
+
// Para reset
|
|
37
|
+
commit_hash: zod_1.z.string().optional(),
|
|
38
|
+
branch_name: zod_1.z.string().optional(),
|
|
39
|
+
reset_type: zod_1.z.enum(['soft', 'mixed', 'hard']).optional(),
|
|
40
|
+
// Para reset-branch
|
|
41
|
+
target_branch: zod_1.z.string().optional(),
|
|
42
|
+
});
|
|
49
43
|
const GitResetResultSchema = zod_1.z.object({
|
|
50
44
|
success: zod_1.z.boolean(),
|
|
51
45
|
action: zod_1.z.string(),
|
|
52
46
|
message: zod_1.z.string(),
|
|
53
47
|
data: zod_1.z.any().optional(),
|
|
54
|
-
error: zod_1.z.string().optional()
|
|
55
|
-
recoverable: zod_1.z.boolean().optional(),
|
|
56
|
-
suggestion: zod_1.z.string().optional(),
|
|
57
|
-
warning: zod_1.z.string().optional()
|
|
48
|
+
error: zod_1.z.string().optional()
|
|
58
49
|
});
|
|
59
|
-
/**
|
|
60
|
-
* Safe Reset Manager - Preview e segurança para operações de reset
|
|
61
|
-
*/
|
|
62
|
-
class SafeResetManager {
|
|
63
|
-
static async getResetPreview(projectPath, to, mode) {
|
|
64
|
-
const gitOps = new git_operations_js_1.GitOperations(projectPath);
|
|
65
|
-
try {
|
|
66
|
-
// Get commits that will be affected
|
|
67
|
-
const logResult = await gitOps.log({ maxCount: 10, oneline: true });
|
|
68
|
-
const commits = logResult.output.trim().split('\n').filter(line => line.trim());
|
|
69
|
-
// Get status of working directory
|
|
70
|
-
const statusResult = await gitOps.status();
|
|
71
|
-
const status = statusResult.output;
|
|
72
|
-
// Simulate what would be lost based on mode
|
|
73
|
-
const losses = {
|
|
74
|
-
soft: 'No files will be lost (changes stay in staging)',
|
|
75
|
-
mixed: 'Staged changes will be unstaged',
|
|
76
|
-
hard: 'ALL uncommitted changes will be permanently lost'
|
|
77
|
-
};
|
|
78
|
-
return {
|
|
79
|
-
target: to,
|
|
80
|
-
mode,
|
|
81
|
-
affectedCommits: commits.length,
|
|
82
|
-
currentStatus: status,
|
|
83
|
-
whatWillBeLost: losses[mode],
|
|
84
|
-
risk: mode === 'hard' ? 'HIGH' : mode === 'mixed' ? 'MEDIUM' : 'LOW'
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
catch (error) {
|
|
88
|
-
return {
|
|
89
|
-
target: to,
|
|
90
|
-
mode,
|
|
91
|
-
error: 'Could not generate preview',
|
|
92
|
-
risk: 'UNKNOWN'
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
static async canUndoReset(projectPath) {
|
|
97
|
-
// Check if there are stashed changes from before the reset
|
|
98
|
-
const gitOps = new git_operations_js_1.GitOperations(projectPath);
|
|
99
|
-
try {
|
|
100
|
-
const stashResult = await gitOps.stash('list');
|
|
101
|
-
return stashResult.success && stashResult.output.trim().length > 0;
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
static async validateResetTarget(projectPath, to) {
|
|
108
|
-
const gitOps = new git_operations_js_1.GitOperations(projectPath);
|
|
109
|
-
try {
|
|
110
|
-
// Try to resolve the target
|
|
111
|
-
const showResult = await gitOps.runCommand('git', ['rev-parse', '--verify', to]);
|
|
112
|
-
return { valid: showResult.success };
|
|
113
|
-
}
|
|
114
|
-
catch (error) {
|
|
115
|
-
return {
|
|
116
|
-
valid: false,
|
|
117
|
-
message: `${to} is not a valid reset target`
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Enhanced Error Handler for Reset
|
|
124
|
-
*/
|
|
125
|
-
class ResetErrorHandler {
|
|
126
|
-
static handleError(error, context) {
|
|
127
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
128
|
-
const errorPatterns = [
|
|
129
|
-
{
|
|
130
|
-
pattern: /unknown revision/i,
|
|
131
|
-
suggestion: "Check the commit hash or reference",
|
|
132
|
-
recoverable: true
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
pattern: /cannot reset/i,
|
|
136
|
-
suggestion: "Check repository state and target commit",
|
|
137
|
-
recoverable: true
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
pattern: /uncommitted changes/i,
|
|
141
|
-
suggestion: "Stash changes before reset or use --hard",
|
|
142
|
-
recoverable: true
|
|
143
|
-
}
|
|
144
|
-
];
|
|
145
|
-
const matchedPattern = errorPatterns.find(p => p.pattern.test(errorMessage));
|
|
146
|
-
return {
|
|
147
|
-
success: false,
|
|
148
|
-
action: context,
|
|
149
|
-
message: `Error in ${context}: ${errorMessage}`,
|
|
150
|
-
error: errorMessage,
|
|
151
|
-
recoverable: matchedPattern?.recoverable || false,
|
|
152
|
-
suggestion: matchedPattern?.suggestion
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
50
|
exports.gitResetTool = {
|
|
157
51
|
name: 'git-reset',
|
|
158
|
-
description:
|
|
159
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
160
|
-
🔄 RESET OPERATIONS:
|
|
161
|
-
• soft: Desfazer commit mantendo mudanças staged
|
|
162
|
-
• mixed: Desfazer commit removendo do stage
|
|
163
|
-
• hard: Desfazer commit perdendo mudanças (PERIGOSO)
|
|
164
|
-
|
|
165
|
-
👁️ SAFETY FEATURES:
|
|
166
|
-
• preview: Visualizar o que será perdido antes
|
|
167
|
-
• confirm: Confirmação obrigatória para operações perigosas
|
|
168
|
-
• validate: Validação do target antes da operação
|
|
169
|
-
|
|
170
|
-
🔧 ADVANCED OPERATIONS:
|
|
171
|
-
• undo-last-reset: Tentar desfazer último reset (se stash existir)
|
|
172
|
-
|
|
173
|
-
⚠️ RISK LEVELS:
|
|
174
|
-
• LOW: soft reset (nada perdido)
|
|
175
|
-
• MEDIUM: mixed reset (changes unstaged)
|
|
176
|
-
• HIGH: hard reset (changes lost forever)
|
|
177
|
-
|
|
178
|
-
🛡️ SAFE BY DEFAULT:
|
|
179
|
-
• Preview automático antes de operações destrutivas
|
|
180
|
-
• Confirmação obrigatória para hard reset
|
|
181
|
-
• Sugestões de recovery para erros`,
|
|
52
|
+
description: 'tool: Gerencia operações Git reset para desfazer mudanças\n──────────────\naction soft: reset soft mantém mudanças no staging\naction soft requires: repo, commit_hash, provider, projectPath\n───────────────\naction mixed: reset mixed limpa staging area\naction mixed requires: repo, commit_hash, provider, projectPath\n───────────────\naction hard: reset hard remove todas as mudanças\naction hard requires: repo, commit_hash, provider, projectPath\n───────────────\naction reset-to-commit: reseta para commit específico\naction reset-to-commit requires: repo, commit_hash, reset_type, provider, projectPath\n───────────────\naction reset-branch: reseta branch específica\naction reset-branch requires: repo, branch_name, target_branch, provider, projectPath',
|
|
182
53
|
inputSchema: {
|
|
183
54
|
type: 'object',
|
|
184
55
|
properties: {
|
|
185
56
|
action: {
|
|
186
57
|
type: 'string',
|
|
187
|
-
enum: ['soft', 'mixed', 'hard', '
|
|
188
|
-
description: '
|
|
58
|
+
enum: ['soft', 'mixed', 'hard', 'reset-to-commit', 'reset-branch'],
|
|
59
|
+
description: 'Action to perform on reset'
|
|
189
60
|
},
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
61
|
+
owner: { type: 'string', description: 'Repository owner' },
|
|
62
|
+
repo: { type: 'string', description: 'Repository name' },
|
|
63
|
+
provider: { type: 'string', enum: ['gitea', 'github'], description: 'Provider to use (gitea or github)' },
|
|
64
|
+
projectPath: { type: 'string', description: 'Local project path for git operations' },
|
|
65
|
+
commit_hash: { type: 'string', description: 'Commit hash to reset to' },
|
|
66
|
+
branch_name: { type: 'string', description: 'Branch name for reset' },
|
|
67
|
+
reset_type: { type: 'string', enum: ['soft', 'mixed', 'hard'], description: 'Type of reset' },
|
|
68
|
+
target_branch: { type: 'string', description: 'Target branch for reset' }
|
|
195
69
|
},
|
|
196
|
-
required: ['action', 'projectPath']
|
|
70
|
+
required: ['action', 'repo', 'provider', 'projectPath']
|
|
197
71
|
},
|
|
198
72
|
async handler(input) {
|
|
199
73
|
try {
|
|
200
74
|
const validatedInput = GitResetInputSchema.parse(input);
|
|
201
75
|
switch (validatedInput.action) {
|
|
202
76
|
case 'soft':
|
|
203
|
-
return await this.
|
|
77
|
+
return await this.softReset(validatedInput);
|
|
204
78
|
case 'mixed':
|
|
205
|
-
return await this.
|
|
79
|
+
return await this.mixedReset(validatedInput);
|
|
206
80
|
case 'hard':
|
|
207
|
-
return await this.
|
|
208
|
-
case '
|
|
209
|
-
return await this.
|
|
210
|
-
case '
|
|
211
|
-
return await this.
|
|
81
|
+
return await this.hardReset(validatedInput);
|
|
82
|
+
case 'reset-to-commit':
|
|
83
|
+
return await this.resetToCommit(validatedInput);
|
|
84
|
+
case 'reset-branch':
|
|
85
|
+
return await this.resetBranch(validatedInput);
|
|
212
86
|
default:
|
|
213
|
-
throw new Error(`
|
|
87
|
+
throw new Error(`Ação não suportada: ${validatedInput.action}`);
|
|
214
88
|
}
|
|
215
89
|
}
|
|
216
90
|
catch (error) {
|
|
217
|
-
return ResetErrorHandler.handleError(error, `reset.${input.action}`);
|
|
218
|
-
}
|
|
219
|
-
},
|
|
220
|
-
async handleReset(params, mode) {
|
|
221
|
-
const { projectPath, to, confirm, preview } = params;
|
|
222
|
-
// Validate target
|
|
223
|
-
const targetValidation = await SafeResetManager.validateResetTarget(projectPath, to);
|
|
224
|
-
if (!targetValidation.valid) {
|
|
225
91
|
return {
|
|
226
92
|
success: false,
|
|
227
|
-
action:
|
|
228
|
-
message:
|
|
229
|
-
|
|
230
|
-
recoverable: true
|
|
93
|
+
action: input.action,
|
|
94
|
+
message: 'Erro na operação de reset',
|
|
95
|
+
error: error instanceof Error ? error.message : String(error)
|
|
231
96
|
};
|
|
232
97
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
message: `Reset ${mode} requires confirmation - HIGH RISK`,
|
|
241
|
-
data: previewData,
|
|
242
|
-
suggestion: 'Review preview and set confirm=true to proceed',
|
|
243
|
-
recoverable: true
|
|
244
|
-
};
|
|
98
|
+
},
|
|
99
|
+
async softReset(params) {
|
|
100
|
+
try {
|
|
101
|
+
const target = params.commit_hash || params.branch_name || 'HEAD~1';
|
|
102
|
+
const result = await (0, terminal_controller_js_1.runGitCommand)(`reset --soft ${target}`, params.projectPath, 'Executando reset soft');
|
|
103
|
+
if (result.exitCode !== 0) {
|
|
104
|
+
throw new Error(`Falha no reset soft: ${result.output}`);
|
|
245
105
|
}
|
|
246
|
-
}
|
|
247
|
-
// Additional confirmation for hard reset
|
|
248
|
-
if (mode === 'hard' && !confirm) {
|
|
249
|
-
const previewData = await SafeResetManager.getResetPreview(projectPath, to, mode);
|
|
250
106
|
return {
|
|
251
|
-
success:
|
|
252
|
-
action: '
|
|
253
|
-
message:
|
|
254
|
-
data:
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
107
|
+
success: true,
|
|
108
|
+
action: 'soft',
|
|
109
|
+
message: `Reset soft executado com sucesso para ${target}`,
|
|
110
|
+
data: {
|
|
111
|
+
target,
|
|
112
|
+
type: 'soft',
|
|
113
|
+
output: result.output
|
|
114
|
+
}
|
|
258
115
|
};
|
|
259
116
|
}
|
|
260
|
-
|
|
117
|
+
catch (error) {
|
|
118
|
+
throw new Error(`Falha ao executar reset soft: ${error instanceof Error ? error.message : String(error)}`);
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
async mixedReset(params) {
|
|
261
122
|
try {
|
|
262
|
-
const
|
|
263
|
-
|
|
264
|
-
|
|
123
|
+
const target = params.commit_hash || params.branch_name || 'HEAD~1';
|
|
124
|
+
const result = await (0, terminal_controller_js_1.runGitCommand)(`reset --mixed ${target}`, params.projectPath, 'Executando reset mixed');
|
|
125
|
+
if (result.exitCode !== 0) {
|
|
126
|
+
throw new Error(`Falha no reset mixed: ${result.output}`);
|
|
265
127
|
}
|
|
266
|
-
const riskLevel = mode === 'hard' ? 'HIGH' : mode === 'mixed' ? 'MEDIUM' : 'LOW';
|
|
267
|
-
const warnings = {
|
|
268
|
-
hard: 'All uncommitted changes permanently lost',
|
|
269
|
-
mixed: 'Changes unstaged but recoverable',
|
|
270
|
-
soft: 'Changes kept in staging area'
|
|
271
|
-
};
|
|
272
128
|
return {
|
|
273
129
|
success: true,
|
|
274
|
-
action:
|
|
275
|
-
message: `Reset ${
|
|
276
|
-
data: {
|
|
277
|
-
|
|
130
|
+
action: 'mixed',
|
|
131
|
+
message: `Reset mixed executado com sucesso para ${target}`,
|
|
132
|
+
data: {
|
|
133
|
+
target,
|
|
134
|
+
type: 'mixed',
|
|
135
|
+
output: result.output
|
|
136
|
+
}
|
|
278
137
|
};
|
|
279
138
|
}
|
|
280
139
|
catch (error) {
|
|
281
|
-
|
|
140
|
+
throw new Error(`Falha ao executar reset mixed: ${error instanceof Error ? error.message : String(error)}`);
|
|
282
141
|
}
|
|
283
142
|
},
|
|
284
|
-
async
|
|
285
|
-
const { projectPath, to, mode } = params;
|
|
143
|
+
async hardReset(params) {
|
|
286
144
|
try {
|
|
287
|
-
const
|
|
145
|
+
const target = params.commit_hash || params.branch_name || 'HEAD~1';
|
|
146
|
+
const result = await (0, terminal_controller_js_1.runGitCommand)(`reset --hard ${target}`, params.projectPath, 'Executando reset hard');
|
|
147
|
+
if (result.exitCode !== 0) {
|
|
148
|
+
throw new Error(`Falha no reset hard: ${result.output}`);
|
|
149
|
+
}
|
|
288
150
|
return {
|
|
289
151
|
success: true,
|
|
290
|
-
action: '
|
|
291
|
-
message: `Reset
|
|
292
|
-
data:
|
|
152
|
+
action: 'hard',
|
|
153
|
+
message: `Reset hard executado com sucesso para ${target}`,
|
|
154
|
+
data: {
|
|
155
|
+
target,
|
|
156
|
+
type: 'hard',
|
|
157
|
+
output: result.output
|
|
158
|
+
}
|
|
293
159
|
};
|
|
294
160
|
}
|
|
295
161
|
catch (error) {
|
|
296
|
-
|
|
162
|
+
throw new Error(`Falha ao executar reset hard: ${error instanceof Error ? error.message : String(error)}`);
|
|
297
163
|
}
|
|
298
164
|
},
|
|
299
|
-
async
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
165
|
+
async resetToCommit(params) {
|
|
166
|
+
try {
|
|
167
|
+
if (!params.commit_hash) {
|
|
168
|
+
throw new Error('commit_hash é obrigatório para reset-to-commit');
|
|
169
|
+
}
|
|
170
|
+
const resetType = params.reset_type || 'mixed';
|
|
171
|
+
const result = await (0, terminal_controller_js_1.runTerminalCmd)({
|
|
172
|
+
command: `cd "${params.projectPath}" && git reset --${resetType} ${params.commit_hash}`,
|
|
173
|
+
is_background: false,
|
|
174
|
+
explanation: `Executando reset ${resetType} para commit`
|
|
175
|
+
});
|
|
176
|
+
if (result.exitCode !== 0) {
|
|
177
|
+
throw new Error(`Falha no reset para commit: ${result.output}`);
|
|
178
|
+
}
|
|
303
179
|
return {
|
|
304
|
-
success:
|
|
305
|
-
action: '
|
|
306
|
-
message:
|
|
307
|
-
data: {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
180
|
+
success: true,
|
|
181
|
+
action: 'reset-to-commit',
|
|
182
|
+
message: `Reset ${resetType} executado com sucesso para commit ${params.commit_hash}`,
|
|
183
|
+
data: {
|
|
184
|
+
commit_hash: params.commit_hash,
|
|
185
|
+
type: resetType,
|
|
186
|
+
output: result.output
|
|
187
|
+
}
|
|
312
188
|
};
|
|
313
189
|
}
|
|
314
|
-
|
|
190
|
+
catch (error) {
|
|
191
|
+
throw new Error(`Falha ao executar reset para commit: ${error instanceof Error ? error.message : String(error)}`);
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
async resetBranch(params) {
|
|
315
195
|
try {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
196
|
+
if (!params.target_branch) {
|
|
197
|
+
throw new Error('target_branch é obrigatório para reset-branch');
|
|
198
|
+
}
|
|
199
|
+
const resetType = params.reset_type || 'mixed';
|
|
200
|
+
const result = await (0, terminal_controller_js_1.runTerminalCmd)({
|
|
201
|
+
command: `cd "${params.projectPath}" && git reset --${resetType} ${params.target_branch}`,
|
|
202
|
+
is_background: false,
|
|
203
|
+
explanation: `Executando reset ${resetType} para branch`
|
|
204
|
+
});
|
|
205
|
+
if (result.exitCode !== 0) {
|
|
206
|
+
throw new Error(`Falha no reset para branch: ${result.output}`);
|
|
326
207
|
}
|
|
327
208
|
return {
|
|
328
209
|
success: true,
|
|
329
|
-
action: '
|
|
330
|
-
message:
|
|
331
|
-
data: {
|
|
332
|
-
|
|
210
|
+
action: 'reset-branch',
|
|
211
|
+
message: `Reset ${resetType} executado com sucesso para branch ${params.target_branch}`,
|
|
212
|
+
data: {
|
|
213
|
+
target_branch: params.target_branch,
|
|
214
|
+
type: resetType,
|
|
215
|
+
output: result.output
|
|
216
|
+
}
|
|
333
217
|
};
|
|
334
218
|
}
|
|
335
219
|
catch (error) {
|
|
336
|
-
|
|
220
|
+
throw new Error(`Falha ao executar reset para branch: ${error instanceof Error ? error.message : String(error)}`);
|
|
337
221
|
}
|
|
338
222
|
}
|
|
339
223
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-reset.js","sourceRoot":"","sources":["../../src/tools/git-reset.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,
|
|
1
|
+
{"version":3,"file":"git-reset.js","sourceRoot":"","sources":["../../src/tools/git-reset.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,4EAAgF;AAEhF;;;;;;;;;;;;;;;;;;;;;;;GAuB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