orcommit 1.0.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/LICENSE +21 -0
- package/README.md +318 -0
- package/dist/cli.d.ts +70 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +391 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/modules/api.d.ts +48 -0
- package/dist/modules/api.d.ts.map +1 -0
- package/dist/modules/api.js +286 -0
- package/dist/modules/api.js.map +1 -0
- package/dist/modules/cache.d.ts +74 -0
- package/dist/modules/cache.d.ts.map +1 -0
- package/dist/modules/cache.js +284 -0
- package/dist/modules/cache.js.map +1 -0
- package/dist/modules/config.d.ts +53 -0
- package/dist/modules/config.d.ts.map +1 -0
- package/dist/modules/config.js +180 -0
- package/dist/modules/config.js.map +1 -0
- package/dist/modules/core.d.ts +54 -0
- package/dist/modules/core.d.ts.map +1 -0
- package/dist/modules/core.js +474 -0
- package/dist/modules/core.js.map +1 -0
- package/dist/modules/diff-filter.d.ts +71 -0
- package/dist/modules/diff-filter.d.ts.map +1 -0
- package/dist/modules/diff-filter.js +332 -0
- package/dist/modules/diff-filter.js.map +1 -0
- package/dist/modules/git.d.ts +61 -0
- package/dist/modules/git.d.ts.map +1 -0
- package/dist/modules/git.js +362 -0
- package/dist/modules/git.js.map +1 -0
- package/dist/modules/logger.d.ts +67 -0
- package/dist/modules/logger.d.ts.map +1 -0
- package/dist/modules/logger.js +212 -0
- package/dist/modules/logger.js.map +1 -0
- package/dist/modules/tokenizer.d.ts +43 -0
- package/dist/modules/tokenizer.d.ts.map +1 -0
- package/dist/modules/tokenizer.js +200 -0
- package/dist/modules/tokenizer.js.map +1 -0
- package/dist/types/index.d.ts +141 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +70 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/index.d.ts +64 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +154 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +75 -0
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import { logger } from './logger.js';
|
|
2
|
+
export class DiffFilter {
|
|
3
|
+
defaultOptions = {
|
|
4
|
+
ignoreWhitespace: true,
|
|
5
|
+
ignoreGenerated: true,
|
|
6
|
+
ignoreFormatterNoise: true,
|
|
7
|
+
ignoreLockFiles: true,
|
|
8
|
+
maxFileSize: 1024 * 1024, // 1MB
|
|
9
|
+
relevancyThreshold: 0.1,
|
|
10
|
+
};
|
|
11
|
+
// Patterns for generated files
|
|
12
|
+
generatedFilePatterns = [
|
|
13
|
+
/\.lock$/,
|
|
14
|
+
/package-lock\.json$/,
|
|
15
|
+
/yarn\.lock$/,
|
|
16
|
+
/pnpm-lock\.yaml$/,
|
|
17
|
+
/Gemfile\.lock$/,
|
|
18
|
+
/composer\.lock$/,
|
|
19
|
+
/go\.sum$/,
|
|
20
|
+
/\.generated\./,
|
|
21
|
+
/dist\/.*$/,
|
|
22
|
+
/build\/.*$/,
|
|
23
|
+
/coverage\/.*$/,
|
|
24
|
+
/node_modules\/.*$/,
|
|
25
|
+
/\.git\/.*$/,
|
|
26
|
+
/\.vscode\/.*$/,
|
|
27
|
+
/\.idea\/.*$/,
|
|
28
|
+
/\.DS_Store$/,
|
|
29
|
+
/thumbs\.db$/i,
|
|
30
|
+
/desktop\.ini$/i,
|
|
31
|
+
// Code generation patterns
|
|
32
|
+
/.*\.g\.ts$/, // Generated TypeScript
|
|
33
|
+
/.*\.g\.dart$/, // Generated Dart
|
|
34
|
+
/.*_pb2\.py$/, // Protocol buffers
|
|
35
|
+
/.*\.pb\.go$/, // Protocol buffers Go
|
|
36
|
+
/.*\.(min|bundle)\.(js|css)$/, // Minified files
|
|
37
|
+
// Database migrations (usually auto-generated)
|
|
38
|
+
/.*migrations\/.*\.py$/,
|
|
39
|
+
/.*migrations\/.*\.sql$/,
|
|
40
|
+
];
|
|
41
|
+
// Patterns for formatter/linter changes (low semantic value)
|
|
42
|
+
formatterPatterns = [
|
|
43
|
+
// Whitespace only changes
|
|
44
|
+
/^\s*$/,
|
|
45
|
+
/^[\s\t]+$/,
|
|
46
|
+
// Import sorting
|
|
47
|
+
/^import\s+/,
|
|
48
|
+
/^from\s+.*import/,
|
|
49
|
+
/^using\s+/,
|
|
50
|
+
/^#include\s+/,
|
|
51
|
+
// Trailing commas, semicolons
|
|
52
|
+
/,\s*$/,
|
|
53
|
+
/;\s*$/,
|
|
54
|
+
// Quote style changes
|
|
55
|
+
/^["']/,
|
|
56
|
+
// Bracket style changes
|
|
57
|
+
/^[\{\[\(]\s*$/,
|
|
58
|
+
/^[\}\]\)]\s*$/,
|
|
59
|
+
];
|
|
60
|
+
// High-value code patterns
|
|
61
|
+
highValuePatterns = [
|
|
62
|
+
// Function/method definitions
|
|
63
|
+
/^[\s]*(?:function|def|class|interface|type|const|let|var)\s+/,
|
|
64
|
+
// Control flow
|
|
65
|
+
/^[\s]*(?:if|else|for|while|switch|case|try|catch|throw|return)\s+/,
|
|
66
|
+
// API endpoints
|
|
67
|
+
/^[\s]*(?:@(?:Get|Post|Put|Delete|Patch)|app\.|router\.)/,
|
|
68
|
+
// Database operations
|
|
69
|
+
/^[\s]*(?:SELECT|INSERT|UPDATE|DELETE|CREATE|DROP|ALTER)\s+/i,
|
|
70
|
+
// Error handling
|
|
71
|
+
/^[\s]*(?:error|throw|catch|except|raise)\s+/i,
|
|
72
|
+
// Configuration changes
|
|
73
|
+
/^[\s]*(?:config|settings|env|environment)/i,
|
|
74
|
+
];
|
|
75
|
+
/**
|
|
76
|
+
* Filter diff based on relevancy and noise reduction
|
|
77
|
+
*/
|
|
78
|
+
filterDiff(diff, options = {}) {
|
|
79
|
+
const opts = { ...this.defaultOptions, ...options };
|
|
80
|
+
logger.debug('Filtering diff', {
|
|
81
|
+
originalFiles: diff.files.length,
|
|
82
|
+
options: opts
|
|
83
|
+
});
|
|
84
|
+
const filteredFiles = diff.files
|
|
85
|
+
.map(file => this.filterFile(file, opts))
|
|
86
|
+
.filter((file) => file !== null);
|
|
87
|
+
// Calculate relevancy scores and sort by importance
|
|
88
|
+
const scoredFiles = this.scoreFiles(filteredFiles);
|
|
89
|
+
const relevantFiles = scoredFiles
|
|
90
|
+
.filter(scored => scored.score >= opts.relevancyThreshold)
|
|
91
|
+
.sort((a, b) => b.score - a.score)
|
|
92
|
+
.map(scored => filteredFiles.find(f => f.path === scored.file))
|
|
93
|
+
.filter(Boolean);
|
|
94
|
+
const filteredDiff = {
|
|
95
|
+
files: relevantFiles,
|
|
96
|
+
totalLines: relevantFiles.reduce((sum, file) => sum + file.chunks.reduce((chunkSum, chunk) => chunkSum + chunk.lines.length, 0), 0),
|
|
97
|
+
totalSize: relevantFiles.reduce((sum, file) => sum + JSON.stringify(file).length, 0),
|
|
98
|
+
};
|
|
99
|
+
logger.debug('Diff filtered', {
|
|
100
|
+
originalFiles: diff.files.length,
|
|
101
|
+
filteredFiles: filteredDiff.files.length,
|
|
102
|
+
originalLines: diff.totalLines,
|
|
103
|
+
filteredLines: filteredDiff.totalLines,
|
|
104
|
+
});
|
|
105
|
+
return filteredDiff;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Filter individual file
|
|
109
|
+
*/
|
|
110
|
+
filterFile(file, options) {
|
|
111
|
+
// Skip generated files
|
|
112
|
+
if (options.ignoreGenerated && this.isGeneratedFile(file.path)) {
|
|
113
|
+
logger.debug('Skipping generated file', { path: file.path });
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
// Skip lock files
|
|
117
|
+
if (options.ignoreLockFiles && this.isLockFile(file.path)) {
|
|
118
|
+
logger.debug('Skipping lock file', { path: file.path });
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
// Skip binary files
|
|
122
|
+
if (file.isBinary) {
|
|
123
|
+
logger.debug('Skipping binary file', { path: file.path });
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
// Filter chunks
|
|
127
|
+
const filteredChunks = file.chunks
|
|
128
|
+
.map(chunk => this.filterChunk(chunk, options))
|
|
129
|
+
.filter((chunk) => chunk !== null);
|
|
130
|
+
// Skip files with no relevant chunks
|
|
131
|
+
if (filteredChunks.length === 0) {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
...file,
|
|
136
|
+
chunks: filteredChunks,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Filter individual chunk
|
|
141
|
+
*/
|
|
142
|
+
filterChunk(chunk, options) {
|
|
143
|
+
let filteredLines = chunk.lines;
|
|
144
|
+
// Filter whitespace-only changes
|
|
145
|
+
if (options.ignoreWhitespace) {
|
|
146
|
+
filteredLines = filteredLines.filter(line => !this.isWhitespaceOnlyLine(line));
|
|
147
|
+
}
|
|
148
|
+
// Filter formatter noise
|
|
149
|
+
if (options.ignoreFormatterNoise) {
|
|
150
|
+
filteredLines = filteredLines.filter(line => !this.isFormatterNoise(line));
|
|
151
|
+
}
|
|
152
|
+
// Skip chunk if no meaningful lines remain
|
|
153
|
+
if (filteredLines.length === 0) {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
// Skip chunk if only context lines remain
|
|
157
|
+
const meaningfulLines = filteredLines.filter(line => line.type !== 'context');
|
|
158
|
+
if (meaningfulLines.length === 0) {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
return {
|
|
162
|
+
...chunk,
|
|
163
|
+
lines: filteredLines,
|
|
164
|
+
context: this.generateChunkContext(filteredLines),
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Check if file is generated
|
|
169
|
+
*/
|
|
170
|
+
isGeneratedFile(path) {
|
|
171
|
+
return this.generatedFilePatterns.some(pattern => pattern.test(path));
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Check if file is a lock file
|
|
175
|
+
*/
|
|
176
|
+
isLockFile(path) {
|
|
177
|
+
const lockPatterns = [
|
|
178
|
+
/\.lock$/,
|
|
179
|
+
/package-lock\.json$/,
|
|
180
|
+
/yarn\.lock$/,
|
|
181
|
+
/pnpm-lock\.yaml$/,
|
|
182
|
+
/Gemfile\.lock$/,
|
|
183
|
+
/composer\.lock$/,
|
|
184
|
+
/go\.sum$/,
|
|
185
|
+
];
|
|
186
|
+
return lockPatterns.some(pattern => pattern.test(path));
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Check if line is whitespace-only change
|
|
190
|
+
*/
|
|
191
|
+
isWhitespaceOnlyLine(line) {
|
|
192
|
+
if (line.type === 'context') {
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
// Check if line contains only whitespace changes
|
|
196
|
+
const content = line.content.trim();
|
|
197
|
+
return content === '' || /^[\s\t]+$/.test(line.content);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Check if line is formatter noise
|
|
201
|
+
*/
|
|
202
|
+
isFormatterNoise(line) {
|
|
203
|
+
if (line.type === 'context') {
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
const content = line.content.trim();
|
|
207
|
+
return this.formatterPatterns.some(pattern => pattern.test(content));
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Score files by relevancy
|
|
211
|
+
*/
|
|
212
|
+
scoreFiles(files) {
|
|
213
|
+
return files.map(file => {
|
|
214
|
+
let score = 0;
|
|
215
|
+
const reasons = [];
|
|
216
|
+
// Base score for any changes
|
|
217
|
+
score += 0.1;
|
|
218
|
+
// Score based on file type
|
|
219
|
+
const fileTypeScore = this.getFileTypeScore(file.path);
|
|
220
|
+
score += fileTypeScore.score;
|
|
221
|
+
if (fileTypeScore.reason) {
|
|
222
|
+
reasons.push(fileTypeScore.reason);
|
|
223
|
+
}
|
|
224
|
+
// Score based on change patterns
|
|
225
|
+
for (const chunk of file.chunks) {
|
|
226
|
+
for (const line of chunk.lines) {
|
|
227
|
+
if (line.type === 'context')
|
|
228
|
+
continue;
|
|
229
|
+
// High-value patterns
|
|
230
|
+
if (this.highValuePatterns.some(pattern => pattern.test(line.content))) {
|
|
231
|
+
score += 0.3;
|
|
232
|
+
reasons.push('High-value code pattern');
|
|
233
|
+
break; // Only count once per chunk
|
|
234
|
+
}
|
|
235
|
+
// Error handling
|
|
236
|
+
if (/error|exception|catch|throw/i.test(line.content)) {
|
|
237
|
+
score += 0.2;
|
|
238
|
+
reasons.push('Error handling');
|
|
239
|
+
}
|
|
240
|
+
// Security-related
|
|
241
|
+
if (/password|token|key|auth|security/i.test(line.content)) {
|
|
242
|
+
score += 0.2;
|
|
243
|
+
reasons.push('Security-related');
|
|
244
|
+
}
|
|
245
|
+
// Performance-related
|
|
246
|
+
if (/performance|optimize|cache|memory|cpu/i.test(line.content)) {
|
|
247
|
+
score += 0.15;
|
|
248
|
+
reasons.push('Performance-related');
|
|
249
|
+
}
|
|
250
|
+
// Bug fixes
|
|
251
|
+
if (/fix|bug|issue|problem|resolve/i.test(line.content)) {
|
|
252
|
+
score += 0.2;
|
|
253
|
+
reasons.push('Bug fix');
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
// Penalize very large files (might be auto-generated)
|
|
258
|
+
const lineCount = file.chunks.reduce((sum, chunk) => sum + chunk.lines.length, 0);
|
|
259
|
+
if (lineCount > 500) {
|
|
260
|
+
score *= 0.7;
|
|
261
|
+
reasons.push('Large file penalty');
|
|
262
|
+
}
|
|
263
|
+
return {
|
|
264
|
+
file: file.path,
|
|
265
|
+
score: Math.min(score, 1.0), // Cap at 1.0
|
|
266
|
+
reasons,
|
|
267
|
+
};
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Get relevancy score based on file type
|
|
272
|
+
*/
|
|
273
|
+
getFileTypeScore(path) {
|
|
274
|
+
const fileTypeScores = [
|
|
275
|
+
{ pattern: /\.(ts|tsx|js|jsx)$/, score: 0.4, reason: 'TypeScript/JavaScript source' },
|
|
276
|
+
{ pattern: /\.(py|rb|php|java|cs|cpp|cc|c|h)$/, score: 0.4, reason: 'Source code' },
|
|
277
|
+
{ pattern: /\.(go|rs|kt|swift|scala)$/, score: 0.4, reason: 'Source code' },
|
|
278
|
+
{ pattern: /\.(vue|svelte|react)$/, score: 0.35, reason: 'Component file' },
|
|
279
|
+
{ pattern: /\.(sql|prisma|graphql)$/, score: 0.3, reason: 'Database/API schema' },
|
|
280
|
+
{ pattern: /\.(yaml|yml|json|toml|ini)$/, score: 0.25, reason: 'Configuration' },
|
|
281
|
+
{ pattern: /\.(md|rst|txt)$/, score: 0.15, reason: 'Documentation' },
|
|
282
|
+
{ pattern: /\.(css|scss|less|sass)$/, score: 0.2, reason: 'Styling' },
|
|
283
|
+
{ pattern: /\.(html|htm|xml)$/, score: 0.2, reason: 'Markup' },
|
|
284
|
+
{ pattern: /Dockerfile|\.dockerignore/, score: 0.25, reason: 'Docker configuration' },
|
|
285
|
+
{ pattern: /package\.json|requirements\.txt|Cargo\.toml/, score: 0.3, reason: 'Dependencies' },
|
|
286
|
+
{ pattern: /\.env|\.env\./, score: 0.35, reason: 'Environment configuration' },
|
|
287
|
+
];
|
|
288
|
+
for (const { pattern, score, reason } of fileTypeScores) {
|
|
289
|
+
if (pattern.test(path)) {
|
|
290
|
+
return { score, reason };
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return { score: 0.1 }; // Default for unknown file types
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Generate context for filtered chunk
|
|
297
|
+
*/
|
|
298
|
+
generateChunkContext(lines) {
|
|
299
|
+
// Get context from meaningful changes
|
|
300
|
+
const meaningfulLines = lines
|
|
301
|
+
.filter(line => line.type !== 'context')
|
|
302
|
+
.slice(0, 3)
|
|
303
|
+
.map(line => line.content.trim())
|
|
304
|
+
.filter(content => content.length > 0);
|
|
305
|
+
return meaningfulLines.join(' | ');
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Get summary of filtering actions
|
|
309
|
+
*/
|
|
310
|
+
getFilteringSummary(original, filtered) {
|
|
311
|
+
const filesRemoved = original.files.length - filtered.files.length;
|
|
312
|
+
const linesRemoved = original.totalLines - filtered.totalLines;
|
|
313
|
+
const sizeReduction = `${Math.round((1 - filtered.totalSize / original.totalSize) * 100)}%`;
|
|
314
|
+
// This is a simplified version - in practice, you'd track reasons during filtering
|
|
315
|
+
const topRemovedReasons = [
|
|
316
|
+
'Generated files',
|
|
317
|
+
'Lock files',
|
|
318
|
+
'Whitespace changes',
|
|
319
|
+
'Formatter noise',
|
|
320
|
+
'Low relevancy score',
|
|
321
|
+
];
|
|
322
|
+
return {
|
|
323
|
+
filesRemoved,
|
|
324
|
+
linesRemoved,
|
|
325
|
+
sizeReduction,
|
|
326
|
+
topRemovedReasons,
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
// Singleton instance
|
|
331
|
+
export const diffFilter = new DiffFilter();
|
|
332
|
+
//# sourceMappingURL=diff-filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff-filter.js","sourceRoot":"","sources":["../../src/modules/diff-filter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAiBrC,MAAM,OAAO,UAAU;IACJ,cAAc,GAA4B;QACzD,gBAAgB,EAAE,IAAI;QACtB,eAAe,EAAE,IAAI;QACrB,oBAAoB,EAAE,IAAI;QAC1B,eAAe,EAAE,IAAI;QACrB,WAAW,EAAE,IAAI,GAAG,IAAI,EAAE,MAAM;QAChC,kBAAkB,EAAE,GAAG;KACxB,CAAC;IAEF,+BAA+B;IACd,qBAAqB,GAAG;QACvC,SAAS;QACT,qBAAqB;QACrB,aAAa;QACb,kBAAkB;QAClB,gBAAgB;QAChB,iBAAiB;QACjB,UAAU;QACV,eAAe;QACf,WAA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AK,CAAC,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC;QACnE,MAAM,YAAY,GAAG,QAAQ,CAAC,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC;QAC/D,MAAM,aAAa,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC;QAE5F,mFAAmF;QACnF,MAAM,iBAAiB,GAAG;YACxB,iBAAiB;YACjB,YAAY;YACZ,oBAAoB;YACpB,iBAAiB;YACjB,qBAAqB;SACtB,CAAC;QAEF,OAAO;YACL,YAAY;YACZ,YAAY;YACZ,aAAa;YACb,iBAAiB;SAClB,CAAC;IACJ,CAAC;CACF;AAED,qBAAqB;AACrB,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { GitDiff, GitFileStatus, ChunkProcessingOptions } from '../types/index.js';
|
|
2
|
+
export declare class GitManager {
|
|
3
|
+
/**
|
|
4
|
+
* Check if current directory is a git repository
|
|
5
|
+
*/
|
|
6
|
+
isGitRepository(): Promise<boolean>;
|
|
7
|
+
/**
|
|
8
|
+
* Get staged changes as a structured diff
|
|
9
|
+
*/
|
|
10
|
+
getStagedDiff(options?: Partial<ChunkProcessingOptions>): Promise<GitDiff>;
|
|
11
|
+
/**
|
|
12
|
+
* Get list of staged files with their status
|
|
13
|
+
*/
|
|
14
|
+
getStagedFiles(): Promise<Array<{
|
|
15
|
+
path: string;
|
|
16
|
+
status: GitFileStatus;
|
|
17
|
+
}>>;
|
|
18
|
+
/**
|
|
19
|
+
* Create a commit with the given message
|
|
20
|
+
*/
|
|
21
|
+
createCommit(message: string): Promise<string>;
|
|
22
|
+
/**
|
|
23
|
+
* Check if there are any uncommitted changes
|
|
24
|
+
*/
|
|
25
|
+
hasUncommittedChanges(): Promise<boolean>;
|
|
26
|
+
/**
|
|
27
|
+
* Get the current branch name
|
|
28
|
+
*/
|
|
29
|
+
getCurrentBranch(): Promise<string>;
|
|
30
|
+
/**
|
|
31
|
+
* Get repository root directory
|
|
32
|
+
*/
|
|
33
|
+
getRepositoryRoot(): Promise<string>;
|
|
34
|
+
private parseDiff;
|
|
35
|
+
private splitDiffIntoFiles;
|
|
36
|
+
private parseFileSection;
|
|
37
|
+
private extractFilePath;
|
|
38
|
+
private determineFileStatus;
|
|
39
|
+
private parseChunks;
|
|
40
|
+
private parseChunkHeader;
|
|
41
|
+
private parseGitLine;
|
|
42
|
+
private generateChunkContext;
|
|
43
|
+
private splitLargeChunks;
|
|
44
|
+
private splitSingleChunk;
|
|
45
|
+
private parseFileStatus;
|
|
46
|
+
private mergeChunkOptions;
|
|
47
|
+
/**
|
|
48
|
+
* Check if there is an upstream branch configured
|
|
49
|
+
*/
|
|
50
|
+
hasUpstream(): Promise<boolean>;
|
|
51
|
+
/**
|
|
52
|
+
* Push commits to remote repository
|
|
53
|
+
*/
|
|
54
|
+
pushToRemote(setUpstream?: boolean): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Check if there are unpushed commits
|
|
57
|
+
*/
|
|
58
|
+
hasUnpushedCommits(): Promise<boolean>;
|
|
59
|
+
}
|
|
60
|
+
export declare const gitManager: GitManager;
|
|
61
|
+
//# sourceMappingURL=git.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/modules/git.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAwC,aAAa,EAAE,sBAAsB,EAAgB,MAAM,mBAAmB,CAAC;AAKvI,qBAAa,UAAU;IACrB;;OAEG;IACG,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;IASzC;;OAEG;IACG,aAAa,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;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