git-stack-cli 2.9.9 → 2.10.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/dist/js/index.js +53 -53
- package/package.json +1 -1
- package/src/command.ts +1 -1
- package/src/commands/Fixup.tsx +43 -23
- package/src/commands/Log.tsx +1 -1
package/package.json
CHANGED
package/src/command.ts
CHANGED
package/src/commands/Fixup.tsx
CHANGED
|
@@ -3,11 +3,13 @@ import * as React from "react";
|
|
|
3
3
|
import * as Ink from "ink-cjs";
|
|
4
4
|
|
|
5
5
|
import { Await } from "~/app/Await";
|
|
6
|
+
import { Command } from "~/app/Command";
|
|
6
7
|
import { FormatText } from "~/app/FormatText";
|
|
7
8
|
import { Parens } from "~/app/Parens";
|
|
8
9
|
import { Store } from "~/app/Store";
|
|
9
10
|
import { cli } from "~/core/cli";
|
|
10
11
|
import { colors } from "~/core/colors";
|
|
12
|
+
import { is_finite_value } from "~/core/is_finite_value";
|
|
11
13
|
|
|
12
14
|
export function Fixup() {
|
|
13
15
|
return (
|
|
@@ -25,27 +27,48 @@ async function run() {
|
|
|
25
27
|
|
|
26
28
|
const relative_number = argv.commit;
|
|
27
29
|
|
|
28
|
-
if (!relative_number) {
|
|
30
|
+
if (!is_finite_value(relative_number)) {
|
|
29
31
|
actions.output(
|
|
30
|
-
<Ink.
|
|
32
|
+
<Ink.Box flexDirection="column">
|
|
33
|
+
<Ink.Text color={colors.red}>❗️ Usage: git fixup {"<relative-commit-number>"}</Ink.Text>
|
|
34
|
+
<Ink.Text color={colors.gray}>
|
|
35
|
+
Automates the process of adding staged changes to a previous commit.
|
|
36
|
+
</Ink.Text>
|
|
37
|
+
<FormatText
|
|
38
|
+
wrapper={<Ink.Text color={colors.gray} />}
|
|
39
|
+
message="You can use {git_stack_log} to get the relative commit number."
|
|
40
|
+
values={{ git_stack_log: <Command>git stack log</Command> }}
|
|
41
|
+
/>
|
|
42
|
+
<Ink.Box height={1} />
|
|
43
|
+
<FormatText
|
|
44
|
+
message=" {prompt} git stack log"
|
|
45
|
+
values={{ prompt: <Ink.Text color={colors.green}>❯</Ink.Text> }}
|
|
46
|
+
/>
|
|
47
|
+
<FormatText
|
|
48
|
+
message=" 0 * {sha} 18 hours ago noah homebrew-git-stack 2.9.9"
|
|
49
|
+
values={{ sha: <Ink.Text color={colors.green}>e329794</Ink.Text> }}
|
|
50
|
+
/>
|
|
51
|
+
<FormatText
|
|
52
|
+
message=" 1 * {sha} 18 hours ago noah 2.9.9"
|
|
53
|
+
values={{ sha: <Ink.Text color={colors.green}>c7e4065</Ink.Text> }}
|
|
54
|
+
/>
|
|
55
|
+
<FormatText
|
|
56
|
+
message=" 2 * {sha} 18 hours ago noah command: --label + github add labels"
|
|
57
|
+
values={{ sha: <Ink.Text color={colors.green}>f82ac73</Ink.Text> }}
|
|
58
|
+
/>
|
|
59
|
+
<Ink.Box height={1} />
|
|
60
|
+
<FormatText
|
|
61
|
+
wrapper={<Ink.Text color={colors.gray} />}
|
|
62
|
+
message="To target {sha} above, use {command}"
|
|
63
|
+
values={{
|
|
64
|
+
sha: <Ink.Text color={colors.green}>838e878</Ink.Text>,
|
|
65
|
+
command: <Command>git stack fixup 2</Command>,
|
|
66
|
+
}}
|
|
67
|
+
/>
|
|
68
|
+
</Ink.Box>,
|
|
31
69
|
);
|
|
70
|
+
|
|
32
71
|
actions.output("");
|
|
33
|
-
actions.output("This script automates the process of adding staged changes as a fixup commit");
|
|
34
|
-
actions.output(
|
|
35
|
-
"and the subsequent git rebase to flatten the commits based on relative commit number",
|
|
36
|
-
);
|
|
37
|
-
actions.output("You can use a `git log` like below to get the relative commit number");
|
|
38
|
-
actions.output("");
|
|
39
|
-
actions.output(" ❯ git stack log");
|
|
40
|
-
actions.output(
|
|
41
|
-
" 1\te329794d5f881cbf0fc3f26d2108cf6f3fdebabe enable drop_error_subtask test param",
|
|
42
|
-
);
|
|
43
|
-
actions.output(
|
|
44
|
-
" 2\t57f43b596e5c6b97bc47e2a591f82ccc81651156 test drop_error_subtask baseline",
|
|
45
|
-
);
|
|
46
|
-
actions.output(" 3\t838e878d483c6a2d5393063fc59baf2407225c6d ErrorSubtask test baseline");
|
|
47
|
-
actions.output("");
|
|
48
|
-
actions.output("To target `838e87` above, you would call `fixup 3`");
|
|
49
72
|
|
|
50
73
|
actions.exit(0);
|
|
51
74
|
}
|
|
@@ -64,11 +87,8 @@ async function run() {
|
|
|
64
87
|
// );
|
|
65
88
|
}
|
|
66
89
|
|
|
67
|
-
// Calculate commit SHA based on the relative commit number
|
|
68
|
-
const adjusted_number = Number(relative_number) - 1;
|
|
69
|
-
|
|
70
90
|
// get the commit SHA of the target commit
|
|
71
|
-
const commit_sha = (await cli(`git rev-parse HEAD~${
|
|
91
|
+
const commit_sha = (await cli(`git rev-parse HEAD~${relative_number}`)).stdout;
|
|
72
92
|
|
|
73
93
|
actions.output(
|
|
74
94
|
<FormatText
|
|
@@ -104,7 +124,7 @@ async function run() {
|
|
|
104
124
|
|
|
105
125
|
try {
|
|
106
126
|
// rebase target needs to account for new commit created above
|
|
107
|
-
const rebase_target = Number(relative_number) +
|
|
127
|
+
const rebase_target = Number(relative_number) + 2;
|
|
108
128
|
|
|
109
129
|
await cli(`git rebase -i --autosquash HEAD~${rebase_target}`, {
|
|
110
130
|
env: {
|
package/src/commands/Log.tsx
CHANGED
|
@@ -65,7 +65,7 @@ async function run(args: Args) {
|
|
|
65
65
|
const command = [
|
|
66
66
|
`git log --pretty=format:"${format}" -n20 --graph --color ${rest_args}`,
|
|
67
67
|
`cut -c 1-"${truncation_width}"`,
|
|
68
|
-
`nl -w3 -s' '`,
|
|
68
|
+
`nl -v0 -w3 -s' '`,
|
|
69
69
|
].join(" | ");
|
|
70
70
|
|
|
71
71
|
const result = await cli(command);
|