git-it-done 1.0.3 → 1.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/LICENSE +21 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/checkGitStatus.js +39 -22
- package/dist/utils/checkGitStatus.js.map +1 -1
- 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/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/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.js +52 -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/types/types.d.ts +11 -1
- package/package.json +8 -7
- package/readme.md +5 -5
- package/dist/utils/isGitrepo.d.ts +0 -1
- package/dist/utils/isGitrepo.js +0 -6
- package/dist/utils/isGitrepo.js.map +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sid.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.js
CHANGED
|
@@ -20,6 +20,7 @@ import { handlePushToRemote } from './utils/push_to_remote.js';
|
|
|
20
20
|
import start from './utils/process_interruption.js';
|
|
21
21
|
function main() {
|
|
22
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
var _a;
|
|
23
24
|
console.clear();
|
|
24
25
|
intro(chalk.bgBlue(' Auto Commit Tool '));
|
|
25
26
|
// 1. Validate git repository and configuration
|
|
@@ -28,6 +29,7 @@ function main() {
|
|
|
28
29
|
cancel(gitStatus.reason);
|
|
29
30
|
process.exit(1);
|
|
30
31
|
}
|
|
32
|
+
(_a = gitStatus.warnings) === null || _a === void 0 ? void 0 : _a.forEach(warning => console.log(chalk.yellow.bold(`\n⚠️ ${warning}`)));
|
|
31
33
|
// 2. Get current repository changes
|
|
32
34
|
const changes = getChanges();
|
|
33
35
|
const allFiles = [...changes.staged, ...changes.unstaged, ...changes.untracked];
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;AAEA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,MAAM,iCAAiC,CAAC;AAEpD,SAAe,IAAI
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;AAEA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EA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AK,CAAC,KAAK,CAAC,MAAM,CAAC,+CAA+C,CAAC,CAAC,CAAC;YACrE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,oCAAoC;QACpC,MAAM,aAAa,GAAG,MAAM,mBAAmB,CAAC,aAAa,CAAC,CAAC;QAE/D,wBAAwB;QACxB,MAAM,aAAa,GAAG,MAAM,aAAa,CAAC,aAAa,CAAC,CAAC;QAEzD,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,2BAA2B;QAC3B,MAAM,kBAAkB,EAAE,CAAC;QAE3B,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC;IACrC,CAAC;CAAA;AAED,KAAK,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -1,34 +1,51 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { existsSync } from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { gitCommand, gitOutput } from './gitCommand.js';
|
|
4
|
+
/** In-progress operations we refuse to commit into. */
|
|
5
|
+
const IN_PROGRESS = [
|
|
6
|
+
{ entry: 'MERGE_HEAD', reason: 'A merge is in progress' },
|
|
7
|
+
{ entry: 'REBASE_HEAD', reason: 'A rebase is in progress' },
|
|
8
|
+
{ entry: 'rebase-merge', reason: 'A rebase is in progress' },
|
|
9
|
+
{ entry: 'rebase-apply', reason: 'A rebase or `git am` is in progress' },
|
|
10
|
+
{ entry: 'CHERRY_PICK_HEAD', reason: 'A cherry-pick is in progress' },
|
|
11
|
+
{ entry: 'REVERT_HEAD', reason: 'A revert is in progress' },
|
|
12
|
+
{ entry: 'BISECT_LOG', reason: 'A bisect session is in progress' }
|
|
13
|
+
];
|
|
4
14
|
export function checkGitStatus() {
|
|
15
|
+
var _a;
|
|
16
|
+
const warnings = [];
|
|
5
17
|
// Step 1: Check if Git is installed
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
catch (_a) {
|
|
10
|
-
return {
|
|
11
|
-
valid: false,
|
|
12
|
-
reason: 'Git is not installed or not in PATH',
|
|
13
|
-
};
|
|
18
|
+
if (!gitCommand(['--version']).ok) {
|
|
19
|
+
return { valid: false, reason: 'Git is not installed or not in PATH' };
|
|
14
20
|
}
|
|
15
21
|
// Step 2: Check if inside a Git repository
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
const gitDir = gitOutput(['rev-parse', '--absolute-git-dir']);
|
|
23
|
+
if (!gitDir) {
|
|
24
|
+
return { valid: false, reason: 'Not in a Git repository' };
|
|
25
|
+
}
|
|
26
|
+
// Step 3: Refuse to commit into a half-finished merge/rebase/cherry-pick
|
|
27
|
+
for (const { entry, reason } of IN_PROGRESS) {
|
|
28
|
+
if (existsSync(path.join(gitDir, entry))) {
|
|
29
|
+
return {
|
|
30
|
+
valid: false,
|
|
31
|
+
reason: `${reason}. Finish or abort it first (e.g. \`git merge --abort\`, \`git rebase --abort\`).`
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// Step 4: Warn loudly about a detached HEAD (commits there are easy to lose)
|
|
36
|
+
if (!gitCommand(['symbolic-ref', '--quiet', 'HEAD']).ok) {
|
|
37
|
+
const head = (_a = gitOutput(['rev-parse', '--short', 'HEAD'])) !== null && _a !== void 0 ? _a : 'unknown';
|
|
38
|
+
warnings.push(`HEAD is detached at ${head} — commits made here are not on any branch and can be lost. Run \`git switch -c <branch>\` first.`);
|
|
21
39
|
}
|
|
22
|
-
// Step
|
|
23
|
-
const userName =
|
|
24
|
-
const userEmail =
|
|
40
|
+
// Step 5: Check if Git user config is set
|
|
41
|
+
const userName = gitOutput(['config', 'user.name']);
|
|
42
|
+
const userEmail = gitOutput(['config', 'user.email']);
|
|
25
43
|
if (!userName || !userEmail) {
|
|
26
44
|
return {
|
|
27
45
|
valid: false,
|
|
28
|
-
reason: `Git user not configured. Run:\n git config --global user.name "Your Name"\n git config --global user.email "you@example.com"
|
|
46
|
+
reason: `Git user not configured. Run:\n git config --global user.name "Your Name"\n git config --global user.email "you@example.com"`
|
|
29
47
|
};
|
|
30
48
|
}
|
|
31
|
-
|
|
32
|
-
return { valid: true };
|
|
49
|
+
return warnings.length > 0 ? { valid: true, warnings } : { valid: true };
|
|
33
50
|
}
|
|
34
51
|
//# sourceMappingURL=checkGitStatus.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkGitStatus.js","sourceRoot":"","sources":["../../src/utils/checkGitStatus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"checkGitStatus.js","sourceRoot":"","sources":["../../src/utils/checkGitStatus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGxD,uDAAuD;AACvD,MAAM,WAAW,GAA6C;IAC5D,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,wBAAwB,EAAE;IACzD,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,yBAAyB,EAAE;IAC3D,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,yBAAyB,EAAE;IAC5D,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,qCAAqC,EAAE;IACxE,EAAE,KAAK,EAAE,kBAAkB,EAAE,MAAM,EAAE,8BAA8B,EAAE;IACrE,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,yBAAyB,EAAE;IAC3D,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,iCAAiC,EAAE;CACnE,CAAC;AAEF,MAAM,UAAU,cAAc;;IAC5B,MAAM,QAAQ,G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E,CAAC;QAC5B,OAAO;YACL,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE,gIAAgI;SACzI,CAAC;IACJ,CAAC;IAED,OAAO,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface DiffSignals {
|
|
2
|
+
/** An added comment explicitly states the change fixes something. */
|
|
3
|
+
fixIntent: boolean;
|
|
4
|
+
/** An added comment explicitly states the change restructures code. */
|
|
5
|
+
refactorIntent: boolean;
|
|
6
|
+
/** More declarations were added than removed — likely new API surface. */
|
|
7
|
+
newApi: boolean;
|
|
8
|
+
/** Conditional logic was both removed and added — weak "behaviour fix" hint. */
|
|
9
|
+
conditionalChurn: boolean;
|
|
10
|
+
/** The diff was too large to read; callers should say so rather than guess. */
|
|
11
|
+
oversized: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare const EMPTY_SIGNALS: DiffSignals;
|
|
14
|
+
/**
|
|
15
|
+
* Derive intent hints from a unified diff, looking only at ADDED lines (`+`,
|
|
16
|
+
* excluding the `+++` file header) and REMOVED lines (`-`, excluding `---`).
|
|
17
|
+
* Scanning the raw diff text — headers, context lines and all — is what made
|
|
18
|
+
* every commit come out as "fix: resolve issues and bugs".
|
|
19
|
+
*/
|
|
20
|
+
export declare function analyzeDiff(diff: string): DiffSignals;
|
|
21
|
+
/** Read and analyse the staged diff. Returns null when git itself failed. */
|
|
22
|
+
export declare function readStagedDiffSignals(): DiffSignals | null;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { gitCommand } from './gitCommand.js';
|
|
2
|
+
export const EMPTY_SIGNALS = {
|
|
3
|
+
fixIntent: false,
|
|
4
|
+
refactorIntent: false,
|
|
5
|
+
newApi: false,
|
|
6
|
+
conditionalChurn: false,
|
|
7
|
+
oversized: false
|
|
8
|
+
};
|
|
9
|
+
const COMMENT = /^\s*(\/\/+|\/\*+|\*|#+|--|<!--|"""|''')/;
|
|
10
|
+
/**
|
|
11
|
+
* Deliberately narrow: it matches someone *stating* they fixed something, not
|
|
12
|
+
* the mere presence of the substring "error" (which `catch (error)` supplies in
|
|
13
|
+
* almost every real diff).
|
|
14
|
+
*/
|
|
15
|
+
const FIX_INTENT = /\b(bug\s?fix|hot\s?fix|work\s?around|regression|fix(e[sd])?\s+(a|an|the|this|issue|bug|crash|error|regression|typo|#\d+)|(fix|fixes|fixed|resolve|resolves|resolved|close|closes|closed)\s+#\d+)\b/i;
|
|
16
|
+
const REFACTOR_INTENT = /\b(refactor(ed|ing)?|restructur(e|ed|ing)|clean\s?up|simplif(y|ied|ies)|dedupe|deduplicat(e|ed)|extract(ed)?\s+(in)?to)\b/i;
|
|
17
|
+
const DECLARATION = /^\s*(export\s+(default\s+)?)?(public\s+|private\s+|protected\s+|static\s+|abstract\s+)*(async\s+)?(function|class|interface|enum|type\s+\w+\s*=|struct|trait|impl|def|func|fn)\b/;
|
|
18
|
+
const CONDITIONAL = /(^|[^\w.])(if|elif|else\s+if|switch|while|unless)\s*[({:]|\?\?|\?\./;
|
|
19
|
+
function isComment(line) {
|
|
20
|
+
return COMMENT.test(line);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Derive intent hints from a unified diff, looking only at ADDED lines (`+`,
|
|
24
|
+
* excluding the `+++` file header) and REMOVED lines (`-`, excluding `---`).
|
|
25
|
+
* Scanning the raw diff text — headers, context lines and all — is what made
|
|
26
|
+
* every commit come out as "fix: resolve issues and bugs".
|
|
27
|
+
*/
|
|
28
|
+
export function analyzeDiff(diff) {
|
|
29
|
+
const signals = Object.assign({}, EMPTY_SIGNALS);
|
|
30
|
+
let addedDeclarations = 0;
|
|
31
|
+
let removedDeclarations = 0;
|
|
32
|
+
let addedConditionals = 0;
|
|
33
|
+
let removedConditionals = 0;
|
|
34
|
+
for (const line of diff.split('\n')) {
|
|
35
|
+
const added = line.startsWith('+') && !line.startsWith('+++');
|
|
36
|
+
const removed = line.startsWith('-') && !line.startsWith('---');
|
|
37
|
+
if (!added && !removed)
|
|
38
|
+
continue;
|
|
39
|
+
const content = line.slice(1);
|
|
40
|
+
if (isComment(content)) {
|
|
41
|
+
if (added && FIX_INTENT.test(content))
|
|
42
|
+
signals.fixIntent = true;
|
|
43
|
+
if (added && REFACTOR_INTENT.test(content))
|
|
44
|
+
signals.refactorIntent = true;
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (DECLARATION.test(content)) {
|
|
48
|
+
if (added)
|
|
49
|
+
addedDeclarations++;
|
|
50
|
+
else
|
|
51
|
+
removedDeclarations++;
|
|
52
|
+
}
|
|
53
|
+
if (CONDITIONAL.test(content)) {
|
|
54
|
+
if (added)
|
|
55
|
+
addedConditionals++;
|
|
56
|
+
else
|
|
57
|
+
removedConditionals++;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
signals.newApi = addedDeclarations > removedDeclarations;
|
|
61
|
+
signals.conditionalChurn = removedConditionals > 0 && addedConditionals > 0;
|
|
62
|
+
return signals;
|
|
63
|
+
}
|
|
64
|
+
/** Read and analyse the staged diff. Returns null when git itself failed. */
|
|
65
|
+
export function readStagedDiffSignals() {
|
|
66
|
+
const result = gitCommand(['diff', '--cached', '--no-color', '--no-ext-diff']);
|
|
67
|
+
if (result.oversized) {
|
|
68
|
+
return Object.assign(Object.assign({}, EMPTY_SIGNALS), { oversized: true });
|
|
69
|
+
}
|
|
70
|
+
if (!result.ok) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
return analyzeDiff(result.stdout);
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=diffSignals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diffSignals.js","sourceRoot":"","sources":["../../src/utils/diffSignals.ts"],"names":[],"mappings":"AAAA,OAAO,EA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select, multiselect, spinner, cancel, isCancel } from '@clack/prompts';
|
|
11
11
|
import chalk from 'chalk';
|
|
12
|
-
import { gitCommand } from './gitCommand.js';
|
|
12
|
+
import { gitCommand, gitErrorText } from './gitCommand.js';
|
|
13
13
|
import { getChanges } from './getFileChanges.js';
|
|
14
|
+
import { getRepoRoot } from './repoRoot.js';
|
|
14
15
|
import { formatFileStatus } from './formatFileStatus.js';
|
|
15
16
|
export function handleFileStaging(changes) {
|
|
16
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
-
let
|
|
18
|
-
//
|
|
19
|
-
if (
|
|
20
|
-
|
|
18
|
+
let current = changes;
|
|
19
|
+
// Never silently adopt a pre-existing index — show it and ask.
|
|
20
|
+
if (current.staged.length > 0) {
|
|
21
|
+
const decision = yield confirmExistingIndex(current.staged);
|
|
22
|
+
if (decision === 'keep') {
|
|
23
|
+
return current.staged;
|
|
24
|
+
}
|
|
25
|
+
resetIndex();
|
|
26
|
+
current = getChanges();
|
|
27
|
+
if (current.unstaged.length === 0 && current.untracked.length === 0) {
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
21
30
|
}
|
|
22
|
-
// Handle unstaged files
|
|
23
31
|
const stageOption = yield select({
|
|
24
32
|
message: 'No files are staged. What would you like to do?',
|
|
25
33
|
options: [
|
|
@@ -33,21 +41,59 @@ export function handleFileStaging(changes) {
|
|
|
33
41
|
process.exit(0);
|
|
34
42
|
}
|
|
35
43
|
if (stageOption === 'all') {
|
|
36
|
-
|
|
44
|
+
return yield stageAllFiles();
|
|
37
45
|
}
|
|
38
|
-
|
|
39
|
-
|
|
46
|
+
if (stageOption === 'select') {
|
|
47
|
+
return yield stageSelectedFiles(current);
|
|
48
|
+
}
|
|
49
|
+
return current.staged;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function confirmExistingIndex(staged) {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
console.log(chalk.bold('\n📦 Already staged (from a previous session or manual `git add`):'));
|
|
55
|
+
staged.forEach(({ status, file, from }) => console.log(` ${formatFileStatus(status)} ${from ? `${from} → ${file}` : file}`));
|
|
56
|
+
const decision = yield select({
|
|
57
|
+
message: `${staged.length} file(s) are already staged. What would you like to do?`,
|
|
58
|
+
options: [
|
|
59
|
+
{ value: 'keep', label: 'Commit these staged files' },
|
|
60
|
+
{ value: 'reset', label: 'Unstage everything and choose again' },
|
|
61
|
+
{ value: 'cancel', label: 'Cancel' }
|
|
62
|
+
]
|
|
63
|
+
});
|
|
64
|
+
if (isCancel(decision) || decision === 'cancel') {
|
|
65
|
+
cancel('Operation cancelled');
|
|
66
|
+
process.exit(0);
|
|
40
67
|
}
|
|
41
|
-
return
|
|
68
|
+
return decision;
|
|
42
69
|
});
|
|
43
70
|
}
|
|
71
|
+
function resetIndex() {
|
|
72
|
+
const s = spinner();
|
|
73
|
+
s.start('Unstaging files...');
|
|
74
|
+
let result = gitCommand(['reset', '--quiet', '--', ':/']);
|
|
75
|
+
// An unborn branch has no HEAD to reset against; drop the paths from the index.
|
|
76
|
+
if (!result.ok) {
|
|
77
|
+
result = gitCommand(['rm', '--cached', '-r', '-f', '--quiet', '--', ':/']);
|
|
78
|
+
}
|
|
79
|
+
if (!result.ok) {
|
|
80
|
+
s.stop('❌ Failed to unstage files');
|
|
81
|
+
console.log(chalk.red(gitErrorText(result)));
|
|
82
|
+
cancel('Failed to unstage files');
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
s.stop('Index cleared');
|
|
86
|
+
}
|
|
44
87
|
function stageAllFiles() {
|
|
45
88
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46
89
|
const s = spinner();
|
|
47
90
|
s.start('Staging all files...');
|
|
48
|
-
|
|
49
|
-
|
|
91
|
+
// `:/` makes this repo-root-relative, so the staged set matches the status
|
|
92
|
+
// display even when the tool is run from a subdirectory.
|
|
93
|
+
const result = gitCommand(['add', '-A', '--', ':/']);
|
|
94
|
+
if (!result.ok) {
|
|
50
95
|
s.stop('❌ Failed to stage files');
|
|
96
|
+
console.log(chalk.red(gitErrorText(result)));
|
|
51
97
|
cancel('Failed to stage files');
|
|
52
98
|
process.exit(1);
|
|
53
99
|
}
|
|
@@ -60,9 +106,9 @@ function stageSelectedFiles(changes) {
|
|
|
60
106
|
const unstaged = [...changes.unstaged, ...changes.untracked];
|
|
61
107
|
const selectedFiles = yield multiselect({
|
|
62
108
|
message: 'Select files to stage:',
|
|
63
|
-
options: unstaged.map(({ status, file }) => ({
|
|
109
|
+
options: unstaged.map(({ status, file, from }) => ({
|
|
64
110
|
value: file,
|
|
65
|
-
label: `${formatFileStatus(status)} ${file}`
|
|
111
|
+
label: `${formatFileStatus(status)} ${from ? `${from} → ${file}` : file}`
|
|
66
112
|
})),
|
|
67
113
|
required: true
|
|
68
114
|
});
|
|
@@ -70,18 +116,18 @@ function stageSelectedFiles(changes) {
|
|
|
70
116
|
cancel('Operation cancelled');
|
|
71
117
|
process.exit(0);
|
|
72
118
|
}
|
|
119
|
+
const files = selectedFiles;
|
|
73
120
|
const s = spinner();
|
|
74
121
|
s.start('Staging selected files...');
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
122
|
+
// Paths are repo-root-relative, so run from the repo root; `--literal-pathspecs`
|
|
123
|
+
// stops names containing `*`, `[` or a leading `:` being read as pathspec magic.
|
|
124
|
+
const repoRoot = getRepoRoot();
|
|
125
|
+
const result = gitCommand(['--literal-pathspecs', 'add', '--', ...files], {
|
|
126
|
+
cwd: repoRoot !== null && repoRoot !== void 0 ? repoRoot : undefined
|
|
81
127
|
});
|
|
82
|
-
if (
|
|
128
|
+
if (!result.ok) {
|
|
83
129
|
s.stop('❌ Some files failed to stage');
|
|
84
|
-
console.log(chalk.
|
|
130
|
+
console.log(chalk.red(gitErrorText(result)));
|
|
85
131
|
}
|
|
86
132
|
else {
|
|
87
133
|
s.stop('Files staged');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileStaging.js","sourceRoot":"","sources":["../../src/utils/fileStaging.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"fileStaging.js","sourceRoot":"","sources":["../../src/utils/fileStaging.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGzD,MAAM,UAAgB,iBAAiB,CAAC,OAAmB;;QACzD,IAAI,OAAO,GAAG,OAAO,CAAC;QAEtB,+DAA+D;QAC/D,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9B,MAAM,QAAQ,GAAG,MAAM,oBAAoB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAE5D,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;gBACxB,OAAO,OAAO,CAAC,MAAM,CAAC;YACxB,CAAC;YAED,UAAU,EAAE,CAAC;YACb,OAAO,GAAG,UAAU,EAAE,CAAC;YAEvB,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;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a,CAAC,EAAE,CAAC;YAC5B,MAAM,CAAC,qBAAqB,CAAC,CAAC;YAC9B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,MAAM,KAAK,GAAG,aAAyB,CAAC;QACxC,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;QACpB,CAAC,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;QAErC,iFAAiF;QACjF,iFAAiF;QACjF,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;QAC/B,MAAM,MAAM,GAAG,UAAU,CAAC,CAAC,qBAAqB,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,EAAE;YACxE,GAAG,EAAE,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,SAAS;SAC3B,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;YACf,CAAC,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;YACvC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAC/C,CAAC;aAAM,CAAC;YACN,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACzB,CAAC;QAED,OAAO,UAAU,EAAE,CAAC,MAAM,CAAC;IAC7B,CAAC;CAAA"}
|
|
@@ -9,6 +9,12 @@ export function formatFileStatus(status) {
|
|
|
9
9
|
return chalk.red('- deleted');
|
|
10
10
|
case 'R':
|
|
11
11
|
return chalk.blue('→ renamed');
|
|
12
|
+
case 'C':
|
|
13
|
+
return chalk.blue('⧉ copied');
|
|
14
|
+
case 'T':
|
|
15
|
+
return chalk.magenta('± typechange');
|
|
16
|
+
case 'U':
|
|
17
|
+
return chalk.red('! unmerged');
|
|
12
18
|
case '??':
|
|
13
19
|
return chalk.cyan('? untracked');
|
|
14
20
|
default:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatFileStatus.js","sourceRoot":"","sources":["../../src/utils/formatFileStatus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC7C,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,GAAG;YACN,OAAO,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAChC,KAAK,GAAG;YACN,OAAO,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QACpC,KAAK,GAAG;YACN,OAAO,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAChC,KAAK,GAAG;YACN,OAAO,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACjC,KAAK,IAAI;YACP,OAAO,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACnC;YACE,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC"}
|
|
1
|
+
{"version":3,"file":"formatFileStatus.js","sourceRoot":"","sources":["../../src/utils/formatFileStatus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC7C,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,GAAG;YACN,OAAO,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAChC,KAAK,GAAG;YACN,OAAO,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QACpC,KAAK,GAAG;YACN,OAAO,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAChC,KAAK,GAAG;YACN,OAAO,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACjC,KAAK,GAAG;YACN,OAAO,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAChC,KAAK,GAAG;YACN,OAAO,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QACvC,KAAK,GAAG;YACN,OAAO,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QACjC,KAAK,IAAI;YACP,OAAO,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACnC;YACE,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC"}
|
|
@@ -1,2 +1,14 @@
|
|
|
1
|
+
import { DiffSignals } from './diffSignals.js';
|
|
1
2
|
import { FileChange } from './types/types.js';
|
|
3
|
+
export type FileCategory = 'deps' | 'test' | 'docs' | 'config' | 'style' | 'source';
|
|
4
|
+
export declare function categorizeFile(file: string): FileCategory;
|
|
5
|
+
/** The category the majority of the changed files belong to. */
|
|
6
|
+
export declare function dominantCategory(files: FileChange[]): FileCategory;
|
|
7
|
+
/**
|
|
8
|
+
* Most common directory across the changed files. `packages/x/...` and
|
|
9
|
+
* `apps/x/...` resolve to `x` so a monorepo commit is not scoped `packages`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function deriveScope(files: FileChange[]): string;
|
|
12
|
+
/** Pure, testable core: no git access, all inputs explicit. */
|
|
13
|
+
export declare function buildCommitMessage(files: FileChange[], signals?: DiffSignals | null): string;
|
|
2
14
|
export declare function generateCommitMessage(files: FileChange[]): string;
|