git-it-done 1.0.3 → 1.1.1
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/dist/index.js +22 -30
- package/dist/index.js.map +1 -1
- package/dist/utils/branches.d.ts +2 -0
- package/dist/utils/branches.js +60 -0
- package/dist/utils/branches.js.map +1 -0
- package/dist/utils/checkGitStatus.js +37 -22
- package/dist/utils/checkGitStatus.js.map +1 -1
- package/dist/utils/commitWorkflow.d.ts +1 -0
- package/dist/utils/commitWorkflow.js +33 -0
- package/dist/utils/commitWorkflow.js.map +1 -0
- package/dist/utils/conflicts.d.ts +7 -0
- package/dist/utils/conflicts.js +96 -0
- package/dist/utils/conflicts.js.map +1 -0
- package/dist/utils/diffSignals.d.ts +22 -0
- package/dist/utils/diffSignals.js +75 -0
- package/dist/utils/diffSignals.js.map +1 -0
- package/dist/utils/displayStatus.js +8 -9
- package/dist/utils/displayStatus.js.map +1 -1
- package/dist/utils/fileStaging.js +68 -22
- package/dist/utils/fileStaging.js.map +1 -1
- package/dist/utils/formatFileStatus.js +6 -0
- package/dist/utils/formatFileStatus.js.map +1 -1
- package/dist/utils/generateCommitMessage.d.ts +12 -0
- package/dist/utils/generateCommitMessage.js +178 -83
- package/dist/utils/generateCommitMessage.js.map +1 -1
- package/dist/utils/getFileChanges.d.ts +15 -1
- package/dist/utils/getFileChanges.js +59 -18
- package/dist/utils/getFileChanges.js.map +1 -1
- package/dist/utils/gitCommand.d.ts +27 -1
- package/dist/utils/gitCommand.js +53 -10
- package/dist/utils/gitCommand.js.map +1 -1
- package/dist/utils/help.d.ts +7 -0
- package/dist/utils/help.js +35 -0
- package/dist/utils/help.js.map +1 -0
- package/dist/utils/inspect.d.ts +2 -0
- package/dist/utils/inspect.js +37 -0
- package/dist/utils/inspect.js.map +1 -0
- package/dist/utils/performCommit.js +29 -34
- package/dist/utils/performCommit.js.map +1 -1
- package/dist/utils/process_interruption.js +22 -13
- package/dist/utils/process_interruption.js.map +1 -1
- package/dist/utils/push_to_remote.d.ts +14 -0
- package/dist/utils/push_to_remote.js +76 -36
- package/dist/utils/push_to_remote.js.map +1 -1
- package/dist/utils/repoRoot.d.ts +6 -0
- package/dist/utils/repoRoot.js +10 -0
- package/dist/utils/repoRoot.js.map +1 -0
- package/dist/utils/repository.d.ts +21 -0
- package/dist/utils/repository.js +60 -0
- package/dist/utils/repository.js.map +1 -0
- package/dist/utils/setup.d.ts +2 -0
- package/dist/utils/setup.js +77 -0
- package/dist/utils/setup.js.map +1 -0
- package/dist/utils/stash.d.ts +2 -0
- package/dist/utils/stash.js +64 -0
- package/dist/utils/stash.js.map +1 -0
- package/dist/utils/sync.d.ts +3 -0
- package/dist/utils/sync.js +55 -0
- package/dist/utils/sync.js.map +1 -0
- package/dist/utils/types/types.d.ts +11 -1
- package/dist/utils/ui.d.ts +15 -0
- package/dist/utils/ui.js +28 -0
- package/dist/utils/ui.js.map +1 -0
- package/dist/utils/validation.d.ts +4 -0
- package/dist/utils/validation.js +26 -0
- package/dist/utils/validation.js.map +1 -0
- package/dist/utils/workspace.d.ts +1 -0
- package/dist/utils/workspace.js +61 -0
- package/dist/utils/workspace.js.map +1 -0
- package/package.json +9 -8
- package/readme.md +40 -268
- package/dist/utils/isGitrepo.d.ts +0 -1
- package/dist/utils/isGitrepo.js +0 -6
- package/dist/utils/isGitrepo.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFileChanges.js","sourceRoot":"","sources":["../../src/utils/getFileChanges.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C
|
|
1
|
+
{"version":3,"file":"getFileChanges.js","sourceRoot":"","sources":["../../src/utils/getFileChanges.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAc;I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CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACrC,CAAC;AAED,SAAS,UAAU,CAAC,IAAc;IAChC,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAChC,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,MAAM,MAAM,GAAG,UAAU,CAAC,CAAC,MAAM,EAAE,UAAU,EAAE,eAAe,EAAE,gBAAgB,EAAE,IAAI,CAAC,CAAC,CAAC;IACzF,MAAM,QAAQ,GAAG,UAAU,CAAC,CAAC,MAAM,EAAE,eAAe,EAAE,gBAAgB,EAAE,IAAI,CAAC,CAAC,CAAC;IAE/E,6EAA6E;IAC7E,mEAAmE;IACnE,MAAM,eAAe,GAAG,UAAU,CAAC;QACjC,UAAU;QACV,UAAU;QACV,oBAAoB;QACpB,aAAa;QACb,IAAI;QACJ,IAAI;QACJ,IAAI;KACL,CAAC,CAAC;IAEH,OAAO;QACL,MAAM;QACN,QAAQ;QACR,SAAS,EAAE,eAAe,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;KAChF,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1,27 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface GitResult {
|
|
2
|
+
/** True when git exited with status 0. */
|
|
3
|
+
ok: boolean;
|
|
4
|
+
stdout: string;
|
|
5
|
+
stderr: string;
|
|
6
|
+
status: number | null;
|
|
7
|
+
/** True when the output exceeded `maxBuffer` and was therefore truncated. */
|
|
8
|
+
oversized: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface GitOptions {
|
|
11
|
+
/** Defaults to 64 MiB (Node's default of 1 MiB truncates large diffs). */
|
|
12
|
+
maxBuffer?: number;
|
|
13
|
+
cwd?: string;
|
|
14
|
+
input?: string;
|
|
15
|
+
}
|
|
16
|
+
/** 64 MiB — big enough for realistic diffs, small enough to stay a guard rail. */
|
|
17
|
+
export declare const DEFAULT_MAX_BUFFER: number;
|
|
18
|
+
/**
|
|
19
|
+
* Run git with an argv array. Never goes through a shell, so file names and
|
|
20
|
+
* commit messages containing `$`, backticks, `!`, quotes or newlines are passed
|
|
21
|
+
* through verbatim instead of being interpreted by /bin/sh.
|
|
22
|
+
*/
|
|
23
|
+
export declare function gitCommand(args: string[], options?: GitOptions): GitResult;
|
|
24
|
+
/** Convenience wrapper for the common "give me the trimmed stdout" case. */
|
|
25
|
+
export declare function gitOutput(args: string[], options?: GitOptions): string | null;
|
|
26
|
+
/** Best-effort explanation of a failed git invocation, for display to the user. */
|
|
27
|
+
export declare function gitErrorText(result: GitResult): string;
|
package/dist/utils/gitCommand.js
CHANGED
|
@@ -1,14 +1,57 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { spawnSync } from 'child_process';
|
|
2
|
+
/** 64 MiB — big enough for realistic diffs, small enough to stay a guard rail. */
|
|
3
|
+
export const DEFAULT_MAX_BUFFER = 64 * 1024 * 1024;
|
|
4
|
+
/**
|
|
5
|
+
* Run git with an argv array. Never goes through a shell, so file names and
|
|
6
|
+
* commit messages containing `$`, backticks, `!`, quotes or newlines are passed
|
|
7
|
+
* through verbatim instead of being interpreted by /bin/sh.
|
|
8
|
+
*/
|
|
9
|
+
export function gitCommand(args, options = {}) {
|
|
10
|
+
var _a, _b, _c;
|
|
11
|
+
const result = spawnSync('git', args, {
|
|
12
|
+
encoding: 'utf-8',
|
|
13
|
+
maxBuffer: (_a = options.maxBuffer) !== null && _a !== void 0 ? _a : DEFAULT_MAX_BUFFER,
|
|
14
|
+
cwd: options.cwd,
|
|
15
|
+
input: options.input
|
|
16
|
+
});
|
|
17
|
+
const stdout = (_b = result.stdout) !== null && _b !== void 0 ? _b : '';
|
|
18
|
+
const stderr = (_c = result.stderr) !== null && _c !== void 0 ? _c : '';
|
|
19
|
+
if (result.error) {
|
|
20
|
+
const code = result.error.code;
|
|
21
|
+
return {
|
|
22
|
+
ok: false,
|
|
23
|
+
stdout,
|
|
24
|
+
stderr: stderr || result.error.message,
|
|
25
|
+
status: result.status,
|
|
26
|
+
oversized: code === 'ENOBUFS'
|
|
27
|
+
};
|
|
9
28
|
}
|
|
10
|
-
|
|
11
|
-
|
|
29
|
+
return {
|
|
30
|
+
ok: result.status === 0,
|
|
31
|
+
stdout,
|
|
32
|
+
stderr,
|
|
33
|
+
status: result.status,
|
|
34
|
+
oversized: false
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/** Convenience wrapper for the common "give me the trimmed stdout" case. */
|
|
38
|
+
export function gitOutput(args, options = {}) {
|
|
39
|
+
const result = gitCommand(args, options);
|
|
40
|
+
return result.ok ? result.stdout.trim() : null;
|
|
41
|
+
}
|
|
42
|
+
/** Best-effort explanation of a failed git invocation, for display to the user. */
|
|
43
|
+
export function gitErrorText(result) {
|
|
44
|
+
var _a;
|
|
45
|
+
const text = [result.stderr, result.stdout]
|
|
46
|
+
.map(part => part.trim())
|
|
47
|
+
.filter(Boolean)
|
|
48
|
+
.join('\n');
|
|
49
|
+
if (text) {
|
|
50
|
+
return text;
|
|
51
|
+
}
|
|
52
|
+
if (result.oversized) {
|
|
53
|
+
return 'git produced more output than could be buffered';
|
|
12
54
|
}
|
|
55
|
+
return `git exited with status ${(_a = result.status) !== null && _a !== void 0 ? _a : 'unknown'}`;
|
|
13
56
|
}
|
|
14
57
|
//# sourceMappingURL=gitCommand.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitCommand.js","sourceRoot":"","sources":["../../src/utils/gitCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
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CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACzC,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACjD,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,YAAY,CAAC,MAAiB;;IAC5C,MAAM,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;SACxC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;SACxB,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,IAAI,IAAI,EAAE,CAAC;QACT,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;QACrB,OAAO,iDAAiD,CAAC;IAC3D,CAAC;IACD,OAAO,0BAA0B,MAAA,MAAM,CAAC,MAAM,mCAAI,SAAS,EAAE,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { select, isCancel } from '@clack/prompts';
|
|
11
|
+
import chalk from 'chalk';
|
|
12
|
+
import { ui } from './ui.js';
|
|
13
|
+
const ENTRIES = {
|
|
14
|
+
commit: { title: 'Commit changes', command: 'git add … && git commit -m "…"', description: 'Stage selected changes and create a commit.' },
|
|
15
|
+
sync: { title: 'Sync with remote', command: 'git fetch --prune && git pull --ff-only / git push', description: 'Fetch first, then safely bring your branch up to date or publish it.' },
|
|
16
|
+
push: { title: 'Push current branch', command: 'git push [--set-upstream <remote> <branch>]', description: 'Publish the current branch after a confirmation.' },
|
|
17
|
+
branches: { title: 'Manage branches', command: 'git branch / git switch / git switch -c <name>', description: 'List, switch, or create branches without deleting or merging them.' },
|
|
18
|
+
stash: { title: 'Save or restore work', command: 'git stash push / list / apply / pop / drop', description: 'Put work aside and restore it when you are ready.' },
|
|
19
|
+
conflicts: { title: 'Resolve an in-progress operation', command: 'git add <file> && git merge --continue', description: 'Inspect conflicts, open files in your editor, then continue or abort safely.' },
|
|
20
|
+
inspect: { title: 'Inspect repository', command: 'git status / log / remote -v', description: 'See a readable summary of repository state and recent activity.' }
|
|
21
|
+
};
|
|
22
|
+
export function helpEntry(action) { return ENTRIES[action]; }
|
|
23
|
+
export function showHelp() {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
const action = yield select({ message: 'What would you like explained?', options: Object.entries(ENTRIES).map(([value, entry]) => ({ value, label: entry.title, hint: entry.description })) });
|
|
26
|
+
if (isCancel(action))
|
|
27
|
+
return;
|
|
28
|
+
const entry = helpEntry(action);
|
|
29
|
+
if (entry) {
|
|
30
|
+
ui.title(entry.title, '?');
|
|
31
|
+
console.log(`${chalk.white(entry.description)}\n\n${chalk.dim('NATIVE GIT')} ${chalk.magenta(entry.command)}`);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=help.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.js","sourceRoot":"","sources":["../../src/utils/help.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAA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AAC,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QAC/L,IAAI,QAAQ,CAAC,MAAM,CAAC;YAAE,OAAO;QAC7B,MAAM,KAAK,GAAG,SAAS,CAAC,MAAgB,CAAC,CAAC;QAC1C,IAAI,KAAK,EAAE,CAAC;YAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YAAC,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,KAAK,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAAC,CAAC;IAC7J,CAAC;CAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { getRepositoryState, hasLocalChanges } from './repository.js';
|
|
3
|
+
import { gitOutput } from './gitCommand.js';
|
|
4
|
+
import { ui } from './ui.js';
|
|
5
|
+
export function showRepositorySummary() {
|
|
6
|
+
var _a, _b;
|
|
7
|
+
const state = getRepositoryState();
|
|
8
|
+
const fileCount = state.changes.staged.length + state.changes.unstaged.length + state.changes.untracked.length;
|
|
9
|
+
ui.title('Repository Overview', '◈');
|
|
10
|
+
ui.key('BRANCH', chalk.cyan.bold((_a = state.branch) !== null && _a !== void 0 ? _a : 'detached HEAD'));
|
|
11
|
+
ui.key('WORKING TREE', hasLocalChanges(state.changes) ? chalk.yellow(`${fileCount} changed file(s)`) : chalk.green('clean'));
|
|
12
|
+
ui.key('REMOTE', chalk.blue((_b = state.upstream) !== null && _b !== void 0 ? _b : (state.remotes[0] ? `${state.remotes[0]} (no upstream)` : 'none configured')));
|
|
13
|
+
if (state.aheadBehind)
|
|
14
|
+
ui.key('SYNC', chalk.magenta(`${state.aheadBehind.ahead} ahead · ${state.aheadBehind.behind} behind`));
|
|
15
|
+
if (state.operation)
|
|
16
|
+
ui.warning(`${state.operation} is in progress${state.conflicts.length ? ` — ${state.conflicts.length} conflict(s)` : ''}`);
|
|
17
|
+
}
|
|
18
|
+
export function inspectRepository() {
|
|
19
|
+
var _a, _b;
|
|
20
|
+
const state = getRepositoryState();
|
|
21
|
+
showRepositorySummary();
|
|
22
|
+
const recent = (_a = gitOutput(['log', '-5', '--oneline'])) !== null && _a !== void 0 ? _a : '';
|
|
23
|
+
if (recent) {
|
|
24
|
+
ui.section('Recent commits', '↳');
|
|
25
|
+
ui.commitList(recent);
|
|
26
|
+
}
|
|
27
|
+
const remotes = (_b = gitOutput(['remote', '-v'])) !== null && _b !== void 0 ? _b : '';
|
|
28
|
+
if (remotes) {
|
|
29
|
+
ui.section('Remotes', '↗');
|
|
30
|
+
ui.remoteList(remotes);
|
|
31
|
+
}
|
|
32
|
+
if (state.conflicts.length) {
|
|
33
|
+
ui.section('Conflicted files', '✕');
|
|
34
|
+
state.conflicts.forEach(file => console.log(` ${chalk.red('✕')} ${chalk.white(file)}`));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=inspect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspect.js","sourceRoot":"","sources":["../../src/utils/inspect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAE7B,MAAM,UAAU,qBAAqB;;IACnC,MAAM,KAAK,GAAG,kBAAkB,EAAE,CAAC;IACnC,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC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AM,GAAG,MAAA,SAAS,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,mCAAI,EAAE,CAAC;IAC3D,IAAI,MAAM,EAAE,CAAC;QAAC,EAAE,CAAC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC;QAAC,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAAC,CAAC;IACzE,MAAM,OAAO,GAAG,MAAA,SAAS,CAAC,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,mCAAI,EAAE,CAAC;IAClD,IAAI,OAAO,EAAE,CAAC;QAAC,EAAE,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;QAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAAC,CAAC;IACpE,IAAI,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;QAAC,EAAE,CAAC,OAAO,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAC;QAAC,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAAC,CAAC;AAChK,CAAC"}
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { confirm, spinner, cancel, isCancel } from '@clack/prompts';
|
|
11
11
|
import chalk from 'chalk';
|
|
12
|
-
import { gitCommand } from './gitCommand.js';
|
|
12
|
+
import { gitCommand, gitErrorText, gitOutput } from './gitCommand.js';
|
|
13
13
|
export function performCommit(commitMessage) {
|
|
14
14
|
return __awaiter(this, void 0, void 0, function* () {
|
|
15
15
|
// Confirm commit
|
|
@@ -23,51 +23,46 @@ export function performCommit(commitMessage) {
|
|
|
23
23
|
// Execute commit
|
|
24
24
|
const s = spinner();
|
|
25
25
|
s.start('Committing changes...');
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
cancel('Failed to commit changes. Please check your git status.');
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
// Verify commit was created
|
|
34
|
-
const lastCommit = gitCommand('log -1 --oneline');
|
|
35
|
-
if (!lastCommit) {
|
|
36
|
-
s.stop('⚠️ Commit status unclear');
|
|
37
|
-
console.log(chalk.yellow('Commit may not have been created. Please check git status manually.'));
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
s.stop('✅ Changes committed successfully!');
|
|
42
|
-
console.log(chalk.dim(`Last commit: ${lastCommit}`));
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
26
|
+
// The message is passed as a single argv entry — no shell, so `$(id)`,
|
|
27
|
+
// backticks and `!` reach git verbatim.
|
|
28
|
+
const result = gitCommand(['commit', '-m', commitMessage]);
|
|
29
|
+
if (!result.ok) {
|
|
47
30
|
s.stop('❌ Commit failed');
|
|
48
|
-
handleCommitError(
|
|
31
|
+
handleCommitError(result);
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
// Verify commit was created
|
|
35
|
+
const lastCommit = gitOutput(['log', '-1', '--oneline']);
|
|
36
|
+
if (!lastCommit) {
|
|
37
|
+
s.stop('⚠️ Commit status unclear');
|
|
38
|
+
console.log(chalk.yellow('Commit may not have been created. Please check git status manually.'));
|
|
49
39
|
return false;
|
|
50
40
|
}
|
|
41
|
+
s.stop('✅ Changes committed successfully!');
|
|
42
|
+
console.log(chalk.dim(`Last commit: ${lastCommit}`));
|
|
43
|
+
return true;
|
|
51
44
|
});
|
|
52
45
|
}
|
|
53
|
-
function
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (msg.includes('nothing to commit')) {
|
|
46
|
+
function handleCommitError(result) {
|
|
47
|
+
const details = gitErrorText(result);
|
|
48
|
+
// Always surface git's own output — pre-commit hook rejections and commitlint
|
|
49
|
+
// failures only ever explain themselves there.
|
|
50
|
+
console.log(chalk.red('\nGit reported:'));
|
|
51
|
+
console.log(chalk.dim(details));
|
|
52
|
+
if (/nothing to commit|no changes added to commit/i.test(details)) {
|
|
61
53
|
cancel('Nothing to commit - working tree clean');
|
|
62
54
|
}
|
|
63
|
-
else if (
|
|
55
|
+
else if (/Please tell me who you are/i.test(details)) {
|
|
64
56
|
cancel('Git user not configured. Run: git config --global user.email "you@example.com"');
|
|
65
57
|
}
|
|
66
|
-
else if (
|
|
58
|
+
else if (/not a git repository/i.test(details)) {
|
|
67
59
|
cancel('Not in a git repository');
|
|
68
60
|
}
|
|
61
|
+
else if (result.status === 1 && /hook|husky|commitlint/i.test(details)) {
|
|
62
|
+
cancel('A git hook rejected the commit (see output above)');
|
|
63
|
+
}
|
|
69
64
|
else {
|
|
70
|
-
cancel(
|
|
65
|
+
cancel('Failed to commit changes (see output above)');
|
|
71
66
|
}
|
|
72
67
|
}
|
|
73
68
|
//# sourceMappingURL=performCommit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"performCommit.js","sourceRoot":"","sources":["../../src/utils/performCommit.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"performCommit.js","sourceRoot":"","sources":["../../src/utils/performCommit.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,KA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C,CAAC,CAAC;QACrD,OAAO,IAAI,CAAC;IACd,CAAC;CAAA;AAED,SAAS,iBAAiB,CAAC,MAAiB;IAC1C,MAAM,OAAO,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IAErC,8EAA8E;IAC9E,+CAA+C;IAC/C,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAC1C,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;IAEhC,IAAI,+CAA+C,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QAClE,MAAM,CAAC,wCAAwC,CAAC,CAAC;IACnD,CAAC;SAAM,IAAI,6BAA6B,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACvD,MAAM,CAAC,gFAAgF,CAAC,CAAC;IAC3F,CAAC;SAAM,IAAI,uBAAuB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACjD,MAAM,CAAC,yBAAyB,CAAC,CAAC;IACpC,CAAC;SAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,wBAAwB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACzE,MAAM,CAAC,mDAAmD,CAAC,CAAC;IAC9D,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,6CAA6C,CAAC,CAAC;IACxD,CAAC;AACH,CAAC"}
|
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
import { cancel } from '@clack/prompts';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
const SHOW_CURSOR = '\u001B[?25h';
|
|
3
|
+
/** clack hides the cursor while a prompt/spinner is active; bring it back. */
|
|
4
|
+
function restoreCursor() {
|
|
5
|
+
if (process.stdout.isTTY) {
|
|
6
|
+
process.stdout.write(SHOW_CURSOR);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
function exitWith(code, message, error) {
|
|
10
|
+
restoreCursor();
|
|
11
|
+
cancel(message);
|
|
12
|
+
if (error !== undefined) {
|
|
13
13
|
console.error(error instanceof Error ? error.stack || error.message : error);
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
}
|
|
15
|
+
process.exit(code);
|
|
16
|
+
}
|
|
17
|
+
export default function start(main) {
|
|
18
|
+
// 128 + signal number, so CI wrappers do not read Ctrl+C as success.
|
|
19
|
+
process.on('SIGINT', () => exitWith(130, 'Operation cancelled by user'));
|
|
20
|
+
process.on('SIGTERM', () => exitWith(143, 'Operation terminated'));
|
|
21
|
+
process.on('unhandledRejection', (reason) => exitWith(1, 'An unexpected error occurred (unhandled rejection)', reason));
|
|
22
|
+
process.on('uncaughtException', (error) => exitWith(1, 'An unexpected error occurred (uncaught exception)', error));
|
|
23
|
+
process.on('exit', restoreCursor);
|
|
24
|
+
main().catch((error) => exitWith(1, 'An unexpected error occurred', error));
|
|
16
25
|
}
|
|
17
26
|
//# sourceMappingURL=process_interruption.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process_interruption.js","sourceRoot":"","sources":["../../src/utils/process_interruption.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,MAAM,CAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"process_interruption.js","sourceRoot":"","sources":["../../src/utils/process_interruption.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,MAAM,WAAW,GAAG,aAAa,CAAC;AAElC,8EAA8E;AAC9E,SAAS,aAAa;IACpB,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACzB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IACpC,CAAC;AACH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: string;
|
|
4
|
+
/** Upstream ref as `<remote>/<branch>`, or null when none is configured. */
|
|
5
|
+
upstream: string | null;
|
|
6
|
+
}
|
|
7
|
+
export declare function parseUpstream(upstream: string, remotes: string[]): {
|
|
8
|
+
remote: string;
|
|
9
|
+
branch: string;
|
|
10
|
+
} | null;
|
|
11
|
+
export declare function resolvePushTarget(currentBranch: string, upstream: string | null, remotes: string[]): PushTarget | null;
|
|
12
|
+
/** Always name the reviewed remote and branch; user push.default settings must not redirect it. */
|
|
13
|
+
export declare function buildPushArgs(upstream: string | null, remote: string, branch: string): string[];
|
|
1
14
|
export declare function handlePushToRemote(): Promise<void>;
|
|
15
|
+
export {};
|
|
@@ -9,54 +9,94 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { confirm, spinner, isCancel } from '@clack/prompts';
|
|
11
11
|
import chalk from 'chalk';
|
|
12
|
-
import { gitCommand } from './gitCommand.js';
|
|
12
|
+
import { gitCommand, gitErrorText, gitOutput } from './gitCommand.js';
|
|
13
|
+
const PROTECTED_BRANCHES = new Set(['main', 'master', 'production', 'release']);
|
|
14
|
+
export function parseUpstream(upstream, remotes) {
|
|
15
|
+
const remote = remotes
|
|
16
|
+
.filter(candidate => upstream.startsWith(`${candidate}/`))
|
|
17
|
+
.sort((a, b) => b.length - a.length)[0];
|
|
18
|
+
if (!remote)
|
|
19
|
+
return null;
|
|
20
|
+
const branch = upstream.slice(remote.length + 1);
|
|
21
|
+
return branch ? { remote, branch } : null;
|
|
22
|
+
}
|
|
23
|
+
export function resolvePushTarget(currentBranch, upstream, remotes) {
|
|
24
|
+
if (upstream) {
|
|
25
|
+
const target = parseUpstream(upstream, remotes);
|
|
26
|
+
return target ? { branch: target.branch, remote: target.remote, upstream } : null;
|
|
27
|
+
}
|
|
28
|
+
const remote = remotes.includes('origin') ? 'origin' : remotes[0];
|
|
29
|
+
return remote ? { branch: currentBranch, remote, upstream: null } : null;
|
|
30
|
+
}
|
|
31
|
+
/** Always name the reviewed remote and branch; user push.default settings must not redirect it. */
|
|
32
|
+
export function buildPushArgs(upstream, remote, branch) {
|
|
33
|
+
return upstream
|
|
34
|
+
? ['push', remote, `HEAD:${branch}`]
|
|
35
|
+
: ['push', '--set-upstream', remote, `HEAD:${branch}`];
|
|
36
|
+
}
|
|
13
37
|
export function handlePushToRemote() {
|
|
14
38
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
var _a;
|
|
40
|
+
const remotes = ((_a = gitOutput(['remote'])) !== null && _a !== void 0 ? _a : '').split('\n').filter(Boolean);
|
|
41
|
+
if (remotes.length === 0) {
|
|
42
|
+
console.log(chalk.yellow('⚠️ No remote repository configured. Skipping push.'));
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const branch = gitOutput(['rev-parse', '--abbrev-ref', 'HEAD']);
|
|
46
|
+
if (!branch || branch === 'HEAD') {
|
|
47
|
+
console.log(chalk.yellow('⚠️ HEAD is detached — not pushing. Create a branch first.'));
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const upstream = gitOutput(['rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{u}']);
|
|
51
|
+
const target = resolvePushTarget(branch, upstream, remotes);
|
|
52
|
+
if (!target) {
|
|
53
|
+
console.log(chalk.yellow('Your configured upstream remote no longer exists. Repair it with `git branch --unset-upstream` or configure a valid remote before pushing.'));
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (PROTECTED_BRANCHES.has(target.branch.toLowerCase())) {
|
|
57
|
+
console.log(chalk.yellow.bold(`\n⚠️ You are about to push directly to "${target.branch}".`));
|
|
58
|
+
}
|
|
59
|
+
if (!upstream) {
|
|
60
|
+
console.log(chalk.yellow(`ℹ️ "${branch}" has no upstream; it will be created as ${target.remote}/${target.branch}.`));
|
|
61
|
+
}
|
|
15
62
|
const shouldPush = yield confirm({
|
|
16
|
-
message:
|
|
63
|
+
message: upstream
|
|
64
|
+
? `Push to ${upstream}?`
|
|
65
|
+
: `Push to ${target.remote}/${target.branch} and set it as upstream?`
|
|
17
66
|
});
|
|
18
67
|
if (isCancel(shouldPush) || !shouldPush) {
|
|
19
68
|
return;
|
|
20
69
|
}
|
|
21
|
-
|
|
70
|
+
executePush(target);
|
|
22
71
|
});
|
|
23
72
|
}
|
|
24
|
-
function executePush() {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
try {
|
|
36
|
-
const pushResult = gitCommand('push');
|
|
37
|
-
if (pushResult !== null) {
|
|
38
|
-
pushSpinner.stop('🚀 Changes pushed successfully!');
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
pushSpinner.stop('❌ Push failed');
|
|
42
|
-
handlePushFailure();
|
|
43
|
-
}
|
|
73
|
+
function executePush(target) {
|
|
74
|
+
const pushSpinner = spinner();
|
|
75
|
+
pushSpinner.start(`Pushing to ${target.remote}/${target.branch}...`);
|
|
76
|
+
const args = buildPushArgs(target.upstream, target.remote, target.branch);
|
|
77
|
+
const result = gitCommand(args);
|
|
78
|
+
if (result.ok) {
|
|
79
|
+
pushSpinner.stop('🚀 Changes pushed successfully!');
|
|
80
|
+
const summary = gitErrorText(result);
|
|
81
|
+
if (summary) {
|
|
82
|
+
console.log(chalk.dim(summary));
|
|
44
83
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
});
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
pushSpinner.stop('❌ Push failed');
|
|
87
|
+
handlePushFailure(target, gitErrorText(result));
|
|
51
88
|
}
|
|
52
|
-
function handlePushFailure() {
|
|
53
|
-
console.log(chalk.red('
|
|
54
|
-
|
|
55
|
-
if (
|
|
56
|
-
console.log(chalk.
|
|
89
|
+
function handlePushFailure(target, details) {
|
|
90
|
+
console.log(chalk.red('\nGit reported:'));
|
|
91
|
+
console.log(chalk.dim(details));
|
|
92
|
+
if (/non-fast-forward|fetch first|behind its remote/i.test(details)) {
|
|
93
|
+
console.log(chalk.yellow(`Remote has commits you don't. Try: git pull --rebase ${target.remote} ${target.branch}`));
|
|
94
|
+
}
|
|
95
|
+
else if (/Authentication failed|could not read Username|Permission denied|403/i.test(details)) {
|
|
96
|
+
console.log(chalk.yellow('Authentication failed — check your credentials or SSH key.'));
|
|
57
97
|
}
|
|
58
|
-
else {
|
|
59
|
-
console.log(chalk.
|
|
98
|
+
else if (/protected branch|pre-receive hook declined/i.test(details)) {
|
|
99
|
+
console.log(chalk.yellow('The remote rejected the push (protected branch or server-side hook).'));
|
|
60
100
|
}
|
|
61
101
|
}
|
|
62
102
|
//# sourceMappingURL=push_to_remote.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"push_to_remote.js","sourceRoot":"","sources":["../../src/utils/push_to_remote.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"push_to_remote.js","sourceRoot":"","sources":["../../src/utils/push_to_remote.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEtE,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC,CAAC;AAShF,MAAM,UAAU,aAAa,CAAC,QAAg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CAAC;QACD,OAAO;IACT,CAAC;IAED,WAAW,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAClC,iBAAiB,CAAC,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;AAClD,CAAC;AAED,SAAS,iBAAiB,CAAC,MAAkB,EAAE,OAAe;IAC5D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAC1C,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;IAEhC,IAAI,iDAAiD,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACpE,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,MAAM,CAAC,wDAAwD,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC,CACvG,CAAC;IACJ,CAAC;SAAM,IAAI,sEAAsE,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QAChG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,4DAA4D,CAAC,CAAC,CAAC;IAC1F,CAAC;SAAM,IAAI,6CAA6C,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACvE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,sEAAsE,CAAC,CAAC,CAAC;IACpG,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Absolute path of the repository root, or null when it cannot be resolved.
|
|
3
|
+
* Used so staging operates on the same (repo-root-relative) set of paths that
|
|
4
|
+
* the status display shows, no matter which subdirectory the tool was run from.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getRepoRoot(): string | null;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { gitOutput } from './gitCommand.js';
|
|
2
|
+
/**
|
|
3
|
+
* Absolute path of the repository root, or null when it cannot be resolved.
|
|
4
|
+
* Used so staging operates on the same (repo-root-relative) set of paths that
|
|
5
|
+
* the status display shows, no matter which subdirectory the tool was run from.
|
|
6
|
+
*/
|
|
7
|
+
export function getRepoRoot() {
|
|
8
|
+
return gitOutput(['rev-parse', '--show-toplevel']);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=repoRoot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repoRoot.js","sourceRoot":"","sources":["../../src/utils/repoRoot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;;GAIG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO,SAAS,CAAC,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { GitChanges } from './types/types.js';
|
|
2
|
+
export type GitOperation = 'merge' | 'rebase' | 'am' | 'cherry-pick' | 'revert' | 'bisect';
|
|
3
|
+
export interface AheadBehind {
|
|
4
|
+
ahead: number;
|
|
5
|
+
behind: number;
|
|
6
|
+
}
|
|
7
|
+
export interface RepositoryState {
|
|
8
|
+
branch: string | null;
|
|
9
|
+
remotes: string[];
|
|
10
|
+
upstream: string | null;
|
|
11
|
+
aheadBehind: AheadBehind | null;
|
|
12
|
+
operation: GitOperation | null;
|
|
13
|
+
conflicts: string[];
|
|
14
|
+
changes: GitChanges;
|
|
15
|
+
}
|
|
16
|
+
export declare function parseAheadBehind(output: string): AheadBehind | null;
|
|
17
|
+
export declare function parseConflictFiles(output: string): string[];
|
|
18
|
+
export declare function detectOperation(entries: Set<string>): GitOperation | null;
|
|
19
|
+
export declare function getInProgressOperation(gitDir: string | null): GitOperation | null;
|
|
20
|
+
export declare function getRepositoryState(): RepositoryState;
|
|
21
|
+
export declare function hasLocalChanges(changes: GitChanges): boolean;
|