git-stack-cli 1.3.2 → 1.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/README.md CHANGED
@@ -101,6 +101,10 @@ npm run build:standalone
101
101
  > [!IMPORTANT]
102
102
  >
103
103
  > **You must update the `version` in `package.json` before running `npm run release`**
104
+ >
105
+ > ```bash
106
+ > npm version patch
107
+ > ```
104
108
 
105
109
  ```bash
106
110
  npm run release
@@ -27544,7 +27544,6 @@ function LocalMergeRebase() {
27544
27544
  async function run$3() {
27545
27545
  const state = Store.getState();
27546
27546
  const actions = state.actions;
27547
- const argv = state.argv;
27548
27547
  const branch_name = state.branch_name;
27549
27548
  const commit_range = state.commit_range;
27550
27549
  const master_branch = state.master_branch;
@@ -27567,6 +27566,7 @@ async function run$3() {
27567
27566
  const rebase_merge_base = master_sha;
27568
27567
  // create temporary branch based on merge base
27569
27568
  await cli(`git checkout -b ${temp_branch_name} ${rebase_merge_base}`);
27569
+ const picked_commit_list = [];
27570
27570
  for (let i = 0; i < commit_range.commit_list.length; i++) {
27571
27571
  const commit = commit_range.commit_list[i];
27572
27572
  const commit_pr = commit_range.pr_lookup[commit.branch_id || ""];
@@ -27581,47 +27581,25 @@ async function run$3() {
27581
27581
  }
27582
27582
  continue;
27583
27583
  }
27584
- // cherry-pick and amend commits one by one
27585
27584
  if (actions.isDebug()) {
27586
27585
  actions.output(reactExports.createElement(FormatText, { wrapper: reactExports.createElement(Text, { color: colors.yellow, wrap: "truncate-end" }), message: "Picking {commit_message}", values: {
27587
27586
  commit_message: reactExports.createElement(Brackets, null, commit.subject_line),
27588
27587
  } }));
27589
27588
  }
27589
+ picked_commit_list.push(commit);
27590
+ }
27591
+ if (picked_commit_list.length > 0) {
27592
+ const first_commit = picked_commit_list.at(0);
27593
+ const last_commit = picked_commit_list.at(-1);
27594
+ invariant(first_commit, "first_commit must exist");
27595
+ invariant(last_commit, "last_commit must exist");
27590
27596
  // ensure clean base to avoid conflicts when applying patch
27591
27597
  await cli(`git clean -fd`);
27592
- // create, apply and cleanup patch
27593
- await cli(`git format-patch -1 ${commit.sha} --stdout > ${PATCH_FILE$1}`);
27594
- await cli(`git apply ${PATCH_FILE$1}`);
27595
- await cli(`rm ${PATCH_FILE$1}`);
27596
- // add all changes to stage
27597
- await cli(`git add --all`);
27598
- let new_message;
27599
- if (commit.branch_id) {
27600
- const metadata = { id: commit.branch_id };
27601
- new_message = write$1(commit.full_message, metadata);
27602
- }
27603
- else {
27604
- new_message = commit.full_message;
27605
- }
27606
- const git_commit_comand = [`git commit -m "${new_message}"`];
27607
- if (argv.verify === false) {
27608
- git_commit_comand.push("--no-verify");
27609
- }
27610
- await cli(git_commit_comand);
27611
- if (commit.branch_id && !commit_pr) {
27612
- if (actions.isDebug()) {
27613
- actions.output(reactExports.createElement(FormatText, { wrapper: reactExports.createElement(Text, { color: colors.yellow, wrap: "truncate-end" }), message: "Cleaning up unused group {group}", values: {
27614
- group: reactExports.createElement(Brackets, null, commit.branch_id),
27615
- } }));
27616
- }
27617
- // missing PR, clear branch id from commit
27618
- const new_message = await remove(commit.full_message);
27619
- await cli(`git commit --amend -m "${new_message}"`);
27620
- }
27598
+ await cli(`git cherry-pick "${first_commit.sha}^..${last_commit.sha}"`);
27621
27599
  }
27622
27600
  // after all commits have been cherry-picked and amended
27623
27601
  // move the branch pointer to the newly created temporary branch
27624
- // now we are in locally in sync with github and on the original branch
27602
+ // now we are locally in sync with github and on the original branch
27625
27603
  await cli(`git branch -f ${branch_name} ${temp_branch_name}`);
27626
27604
  restore_git();
27627
27605
  const next_commit_range = await range();
@@ -27960,6 +27938,12 @@ echo "$GIT_REVISE_TODO" > "$git_revise_todo_path"
27960
27938
  `git`,
27961
27939
  `revise --edit -i ${rebase_merge_base}`,
27962
27940
  ]);
27941
+ // early return since we do not need to sync
27942
+ if (!argv.sync) {
27943
+ return;
27944
+ }
27945
+ // in order to sync we walk from rebase_group_index to HEAD
27946
+ // checking out each group and syncing to github
27963
27947
  // start from HEAD and work backward to rebase_group_index
27964
27948
  const push_group_list = [];
27965
27949
  let lookback_index = 0;
@@ -34335,7 +34319,7 @@ async function command() {
34335
34319
  .wrap(123)
34336
34320
  // disallow unknown options
34337
34321
  .strict()
34338
- .version("1.3.2" )
34322
+ .version("1.3.4" )
34339
34323
  .showHidden("show-hidden", "Show hidden options via `git stack help --show-hidden`")
34340
34324
  .help("help", "Show usage via `git stack help`").argv);
34341
34325
  }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "git-stack-cli",
3
- "version": "1.3.2",
3
+ "version": "1.3.4",
4
4
  "description": "",
5
5
  "author": "magus",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "https://github.com/magus/git-stack-cli.git"
9
+ "url": "git+https://github.com/magus/git-stack-cli.git"
10
10
  },
11
11
  "type": "module",
12
12
  "bin": {
@@ -10,7 +10,6 @@ import { FormatText } from "~/app/FormatText";
10
10
  import { Parens } from "~/app/Parens";
11
11
  import { Store } from "~/app/Store";
12
12
  import * as CommitMetadata from "~/core/CommitMetadata";
13
- import * as Metadata from "~/core/Metadata";
14
13
  import { cli } from "~/core/cli";
15
14
  import { colors } from "~/core/colors";
16
15
  import { invariant } from "~/core/invariant";
@@ -28,7 +27,6 @@ export function LocalMergeRebase() {
28
27
  async function run() {
29
28
  const state = Store.getState();
30
29
  const actions = state.actions;
31
- const argv = state.argv;
32
30
  const branch_name = state.branch_name;
33
31
  const commit_range = state.commit_range;
34
32
  const master_branch = state.master_branch;
@@ -62,6 +60,8 @@ async function run() {
62
60
  // create temporary branch based on merge base
63
61
  await cli(`git checkout -b ${temp_branch_name} ${rebase_merge_base}`);
64
62
 
63
+ const picked_commit_list = [];
64
+
65
65
  for (let i = 0; i < commit_range.commit_list.length; i++) {
66
66
  const commit = commit_range.commit_list[i];
67
67
  const commit_pr = commit_range.pr_lookup[commit.branch_id || ""];
@@ -86,7 +86,6 @@ async function run() {
86
86
  continue;
87
87
  }
88
88
 
89
- // cherry-pick and amend commits one by one
90
89
  if (actions.isDebug()) {
91
90
  actions.output(
92
91
  <FormatText
@@ -99,55 +98,25 @@ async function run() {
99
98
  );
100
99
  }
101
100
 
102
- // ensure clean base to avoid conflicts when applying patch
103
- await cli(`git clean -fd`);
104
-
105
- // create, apply and cleanup patch
106
- await cli(`git format-patch -1 ${commit.sha} --stdout > ${PATCH_FILE}`);
107
- await cli(`git apply ${PATCH_FILE}`);
108
- await cli(`rm ${PATCH_FILE}`);
109
-
110
- // add all changes to stage
111
- await cli(`git add --all`);
112
-
113
- let new_message;
114
- if (commit.branch_id) {
115
- const metadata = { id: commit.branch_id };
116
- new_message = Metadata.write(commit.full_message, metadata);
117
- } else {
118
- new_message = commit.full_message;
119
- }
101
+ picked_commit_list.push(commit);
102
+ }
120
103
 
121
- const git_commit_comand = [`git commit -m "${new_message}"`];
104
+ if (picked_commit_list.length > 0) {
105
+ const first_commit = picked_commit_list.at(0);
106
+ const last_commit = picked_commit_list.at(-1);
122
107
 
123
- if (argv.verify === false) {
124
- git_commit_comand.push("--no-verify");
125
- }
108
+ invariant(first_commit, "first_commit must exist");
109
+ invariant(last_commit, "last_commit must exist");
126
110
 
127
- await cli(git_commit_comand);
128
-
129
- if (commit.branch_id && !commit_pr) {
130
- if (actions.isDebug()) {
131
- actions.output(
132
- <FormatText
133
- wrapper={<Ink.Text color={colors.yellow} wrap="truncate-end" />}
134
- message="Cleaning up unused group {group}"
135
- values={{
136
- group: <Brackets>{commit.branch_id}</Brackets>,
137
- }}
138
- />
139
- );
140
- }
111
+ // ensure clean base to avoid conflicts when applying patch
112
+ await cli(`git clean -fd`);
141
113
 
142
- // missing PR, clear branch id from commit
143
- const new_message = await Metadata.remove(commit.full_message);
144
- await cli(`git commit --amend -m "${new_message}"`);
145
- }
114
+ await cli(`git cherry-pick "${first_commit.sha}^..${last_commit.sha}"`);
146
115
  }
147
116
 
148
117
  // after all commits have been cherry-picked and amended
149
118
  // move the branch pointer to the newly created temporary branch
150
- // now we are in locally in sync with github and on the original branch
119
+ // now we are locally in sync with github and on the original branch
151
120
  await cli(`git branch -f ${branch_name} ${temp_branch_name}`);
152
121
 
153
122
  restore_git();
@@ -155,6 +155,14 @@ async function run() {
155
155
  `revise --edit -i ${rebase_merge_base}`,
156
156
  ]);
157
157
 
158
+ // early return since we do not need to sync
159
+ if (!argv.sync) {
160
+ return;
161
+ }
162
+
163
+ // in order to sync we walk from rebase_group_index to HEAD
164
+ // checking out each group and syncing to github
165
+
158
166
  // start from HEAD and work backward to rebase_group_index
159
167
  const push_group_list = [];
160
168
  let lookback_index = 0;