@zjex/git-workflow 0.3.3 → 0.3.4
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/dist/index.js +21 -14
- package/package.json +1 -1
- package/src/commands/commit.ts +11 -1
- package/src/commands/tag.ts +14 -12
package/dist/index.js
CHANGED
|
@@ -669,13 +669,14 @@ async function listTags(prefix) {
|
|
|
669
669
|
return;
|
|
670
670
|
}
|
|
671
671
|
if (prefix) {
|
|
672
|
-
console.log(
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
if (tags.length >
|
|
676
|
-
console.log(colors.
|
|
677
|
-
\u5171 ${tags.length} \u4E2A\uFF0C\u4EC5\u663E\u793A\u6700\u65B0 20 \u4E2A`));
|
|
672
|
+
console.log(
|
|
673
|
+
colors.green(`\u4EE5 '${prefix}' \u5F00\u5934\u7684 tags (\u5171 ${tags.length} \u4E2A):`)
|
|
674
|
+
);
|
|
675
|
+
if (tags.length > 5) {
|
|
676
|
+
console.log(colors.dim(" ..."));
|
|
678
677
|
}
|
|
678
|
+
const displayTags = tags.slice(-5);
|
|
679
|
+
displayTags.forEach((tag) => console.log(` ${tag}`));
|
|
679
680
|
return;
|
|
680
681
|
}
|
|
681
682
|
const grouped = /* @__PURE__ */ new Map();
|
|
@@ -687,13 +688,12 @@ async function listTags(prefix) {
|
|
|
687
688
|
grouped.get(prefix2).push(tag);
|
|
688
689
|
});
|
|
689
690
|
if (grouped.size === 1) {
|
|
690
|
-
console.log(colors.green(
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
if (tags.length > 20) {
|
|
694
|
-
console.log(colors.yellow(`
|
|
695
|
-
\u5171 ${tags.length} \u4E2A\uFF0C\u4EC5\u663E\u793A\u6700\u65B0 20 \u4E2A`));
|
|
691
|
+
console.log(colors.green(`\u6240\u6709 tags (\u5171 ${tags.length} \u4E2A):`));
|
|
692
|
+
if (tags.length > 5) {
|
|
693
|
+
console.log(colors.dim(" ..."));
|
|
696
694
|
}
|
|
695
|
+
const displayTags = tags.slice(-5);
|
|
696
|
+
displayTags.forEach((tag) => console.log(` ${tag}`));
|
|
697
697
|
return;
|
|
698
698
|
}
|
|
699
699
|
console.log(colors.green("\u6240\u6709 tags (\u6309\u524D\u7F00\u5206\u7EC4):"));
|
|
@@ -2320,7 +2320,14 @@ async function commit() {
|
|
|
2320
2320
|
}
|
|
2321
2321
|
const spinner = ora4("\u6B63\u5728\u63D0\u4EA4...").start();
|
|
2322
2322
|
try {
|
|
2323
|
-
|
|
2323
|
+
let finalStatus = parseGitStatus();
|
|
2324
|
+
if (finalStatus.staged.length === 0 && finalStatus.unstaged.length > 0) {
|
|
2325
|
+
const autoStage = config2.autoStage ?? true;
|
|
2326
|
+
if (autoStage) {
|
|
2327
|
+
execSync5("git add -A", { stdio: "pipe" });
|
|
2328
|
+
finalStatus = parseGitStatus();
|
|
2329
|
+
}
|
|
2330
|
+
}
|
|
2324
2331
|
if (finalStatus.staged.length === 0) {
|
|
2325
2332
|
spinner.fail("\u6CA1\u6709\u6682\u5B58\u7684\u6587\u4EF6\u53EF\u4EE5\u63D0\u4EA4");
|
|
2326
2333
|
console.log("");
|
|
@@ -2909,7 +2916,7 @@ process.on("SIGTERM", () => {
|
|
|
2909
2916
|
console.log("");
|
|
2910
2917
|
process.exit(0);
|
|
2911
2918
|
});
|
|
2912
|
-
var version = true ? "0.3.
|
|
2919
|
+
var version = true ? "0.3.4" : "0.0.0-dev";
|
|
2913
2920
|
async function mainMenu() {
|
|
2914
2921
|
console.log(
|
|
2915
2922
|
colors.green(`
|
package/package.json
CHANGED
package/src/commands/commit.ts
CHANGED
|
@@ -265,7 +265,17 @@ export async function commit(): Promise<void> {
|
|
|
265
265
|
|
|
266
266
|
try {
|
|
267
267
|
// 提交前再次检查是否有暂存的文件
|
|
268
|
-
|
|
268
|
+
let finalStatus = parseGitStatus();
|
|
269
|
+
|
|
270
|
+
// 如果暂存区为空,但有未暂存的更改,且开启了自动暂存,则重新暂存
|
|
271
|
+
if (finalStatus.staged.length === 0 && finalStatus.unstaged.length > 0) {
|
|
272
|
+
const autoStage = config.autoStage ?? true;
|
|
273
|
+
if (autoStage) {
|
|
274
|
+
execSync("git add -A", { stdio: "pipe" });
|
|
275
|
+
finalStatus = parseGitStatus();
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
269
279
|
if (finalStatus.staged.length === 0) {
|
|
270
280
|
spinner.fail("没有暂存的文件可以提交");
|
|
271
281
|
console.log("");
|
package/src/commands/tag.ts
CHANGED
|
@@ -32,14 +32,16 @@ export async function listTags(prefix?: string): Promise<void> {
|
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
//
|
|
35
|
+
// 5. 如果指定了前缀,直接显示单列(最多 5 个)
|
|
36
36
|
if (prefix) {
|
|
37
|
-
console.log(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (tags.length >
|
|
41
|
-
console.log(colors.
|
|
37
|
+
console.log(
|
|
38
|
+
colors.green(`以 '${prefix}' 开头的 tags (共 ${tags.length} 个):`)
|
|
39
|
+
);
|
|
40
|
+
if (tags.length > 5) {
|
|
41
|
+
console.log(colors.dim(" ..."));
|
|
42
42
|
}
|
|
43
|
+
const displayTags = tags.slice(-5);
|
|
44
|
+
displayTags.forEach((tag) => console.log(` ${tag}`));
|
|
43
45
|
return;
|
|
44
46
|
}
|
|
45
47
|
|
|
@@ -55,14 +57,14 @@ export async function listTags(prefix?: string): Promise<void> {
|
|
|
55
57
|
grouped.get(prefix)!.push(tag);
|
|
56
58
|
});
|
|
57
59
|
|
|
58
|
-
//
|
|
60
|
+
// 7. 如果只有一个前缀,使用单列显示(最多 5 个)
|
|
59
61
|
if (grouped.size === 1) {
|
|
60
|
-
console.log(colors.green(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (tags.length > 20) {
|
|
64
|
-
console.log(colors.yellow(`\n共 ${tags.length} 个,仅显示最新 20 个`));
|
|
62
|
+
console.log(colors.green(`所有 tags (共 ${tags.length} 个):`));
|
|
63
|
+
if (tags.length > 5) {
|
|
64
|
+
console.log(colors.dim(" ..."));
|
|
65
65
|
}
|
|
66
|
+
const displayTags = tags.slice(-5);
|
|
67
|
+
displayTags.forEach((tag) => console.log(` ${tag}`));
|
|
66
68
|
return;
|
|
67
69
|
}
|
|
68
70
|
|