git-stack-cli 1.3.3 → 1.3.5

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
@@ -100,7 +100,8 @@ npm run build:standalone
100
100
 
101
101
  > [!IMPORTANT]
102
102
  >
103
- > **You must update the `version` in `package.json` before running `npm run release`**
103
+ > **You must update the `version` in `package.json` before running `npm run release`.
104
+ > DO NOT use `npm version` or commit the change, the release scripts handle git tags etc.**
104
105
 
105
106
  ```bash
106
107
  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}" --keep-redundant-commits`);
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();
@@ -28695,7 +28673,10 @@ function SelectCommitRangesInternal(props) {
28695
28673
  const commit_metadata_id = commit_map.get(commit.sha);
28696
28674
  const selected = commit_metadata_id !== null;
28697
28675
  let disabled;
28698
- if (group.id === props.commit_range.UNASSIGNED) {
28676
+ if (group_input) {
28677
+ disabled = true;
28678
+ }
28679
+ else if (group.id === props.commit_range.UNASSIGNED) {
28699
28680
  disabled = true;
28700
28681
  }
28701
28682
  else {
@@ -34341,7 +34322,7 @@ async function command() {
34341
34322
  .wrap(123)
34342
34323
  // disallow unknown options
34343
34324
  .strict()
34344
- .version("1.3.3" )
34325
+ .version("1.3.5" )
34345
34326
  .showHidden("show-hidden", "Show hidden options via `git stack help --show-hidden`")
34346
34327
  .help("help", "Show usage via `git stack help`").argv);
34347
34328
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "git-stack-cli",
3
- "version": "1.3.3",
3
+ "version": "1.3.5",
4
4
  "description": "",
5
5
  "author": "magus",
6
6
  "license": "MIT",
@@ -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,27 @@ 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(
115
+ `git cherry-pick "${first_commit.sha}^..${last_commit.sha}" --keep-redundant-commits`
116
+ );
146
117
  }
147
118
 
148
119
  // after all commits have been cherry-picked and amended
149
120
  // 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
121
+ // now we are locally in sync with github and on the original branch
151
122
  await cli(`git branch -f ${branch_name} ${temp_branch_name}`);
152
123
 
153
124
  restore_git();
@@ -166,7 +166,9 @@ function SelectCommitRangesInternal(props: Props) {
166
166
 
167
167
  let disabled;
168
168
 
169
- if (group.id === props.commit_range.UNASSIGNED) {
169
+ if (group_input) {
170
+ disabled = true;
171
+ } else if (group.id === props.commit_range.UNASSIGNED) {
170
172
  disabled = true;
171
173
  } else {
172
174
  disabled = Boolean(selected && commit_metadata_id !== group.id);