git-stack-cli 1.0.7 → 1.2.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.
@@ -0,0 +1,79 @@
1
+ import * as Metadata from "~/core/Metadata";
2
+
3
+ import type * as CommitMetadata from "~/core/CommitMetadata";
4
+
5
+ // https://git-revise.readthedocs.io/en/latest/man.html#interactive-mode
6
+ //
7
+ // # Interactive Revise Todos(4 commands)
8
+ // #
9
+ // # Commands:
10
+ // # p, pick <commit> = use commit
11
+ // # r, reword <commit> = use commit, but edit the commit message
12
+ // # s, squash <commit> = use commit, but meld into previous commit
13
+ // # f, fixup <commit> = like squash, but discard this commit's message
14
+ // # c, cut <commit> = interactively split commit into two smaller commits
15
+ // # i, index <commit> = leave commit changes staged, but uncommitted
16
+ // #
17
+ // # Each command block is prefixed by a '++' marker, followed by the command to
18
+ // # run, the commit hash and after a newline the complete commit message until
19
+ // # the next '++' marker or the end of the file.
20
+ // #
21
+ // # Commit messages will be reworded to match the provided message before the
22
+ // # command is performed.
23
+ // #
24
+ // # These blocks are executed from top to bottom. They can be re-ordered and
25
+ // # their commands can be changed, however the number of blocks must remain
26
+ // # identical. If present, index blocks must be at the bottom of the list,
27
+ // # i.e. they can not be followed by non-index blocks.
28
+ // #
29
+ // #
30
+ // # If you remove everything, the revising process will be aborted.
31
+
32
+ // calculate git-revise-todo from commit_range and rebase_group_index
33
+ //
34
+ // Example
35
+ // ----------------------------
36
+ // ++ pick d36d63499425
37
+ // cantaloupe color
38
+ //
39
+ // git-stack-id: E63ytp5dj
40
+ //
41
+ // ++ pick 4f98dd3e67d0
42
+ // banana sweet
43
+ //
44
+ // git-stack-id: E63ytp5dj
45
+ //
46
+ // ++ pick f143d03c723c
47
+ // apple sweet
48
+ //
49
+ export function GitReviseTodo(args: Args): string {
50
+ const entry_list = [];
51
+
52
+ const group_list = args.commit_range.group_list;
53
+
54
+ for (let i = args.rebase_group_index; i < group_list.length; i++) {
55
+ const group = group_list[i];
56
+
57
+ for (const commit of group.commits) {
58
+ // update git commit message with stack id
59
+ const message_with_id = Metadata.write(commit.full_message, group.id);
60
+
61
+ // get first 12 characters of commit sha
62
+ const sha = commit.sha.slice(0, 12);
63
+
64
+ // generate git revise entry
65
+ const entry_lines = [`++ pick ${sha}`, message_with_id];
66
+ const entry = entry_lines.join("\n");
67
+
68
+ entry_list.push(entry);
69
+ }
70
+ }
71
+
72
+ const todo = entry_list.join("\n\n");
73
+ return todo;
74
+ }
75
+
76
+ type Args = {
77
+ rebase_group_index: number;
78
+ commit_range: CommitMetadata.CommitRange;
79
+ };
@@ -3,5 +3,7 @@ declare namespace NodeJS {
3
3
  PATH: string;
4
4
  DEV?: "true" | "false";
5
5
  CLI_VERSION?: string;
6
+ GIT_STACK_STANDALONE?: "true" | "false";
7
+ GIT_SEQUENCE_EDITOR_SCRIPT?: string;
6
8
  }
7
9
  }