git-stack-cli 1.4.0 → 1.5.1

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.
@@ -27835,7 +27835,9 @@ function table(args) {
27835
27835
  old_stack.delete(pr_url);
27836
27836
  }
27837
27837
  // add remaining old stack pr urls to the front of stack pr url list
27838
- for (const pr_url of old_stack.keys()) {
27838
+ const old_pr_list = Array.from(old_stack.keys());
27839
+ old_pr_list.reverse();
27840
+ for (const pr_url of old_pr_list) {
27839
27841
  stack_pr_url_list.unshift(pr_url);
27840
27842
  }
27841
27843
  const stack_list = [];
@@ -27859,8 +27861,6 @@ function table(args) {
27859
27861
  if (!stack_list.length) {
27860
27862
  return "";
27861
27863
  }
27862
- // reverse order of pr list to match the order of git stack
27863
- stack_list.reverse();
27864
27864
  return TEMPLATE.stack_table(["", ...stack_list, "", ""].join("\n"));
27865
27865
  }
27866
27866
  function parse(body) {
@@ -27878,6 +27878,9 @@ function parse(body) {
27878
27878
  // skip invalid row
27879
27879
  continue;
27880
27880
  }
27881
+ if (!RE.pr_url.test(parsed_row.pr_url)) {
27882
+ continue;
27883
+ }
27881
27884
  result.set(parsed_row.pr_url, parsed_row);
27882
27885
  }
27883
27886
  return result;
@@ -27898,6 +27901,7 @@ const RE = {
27898
27901
  num: "(?<num>\\d+)",
27899
27902
  pr_url: "(?<pr_url>.+)",
27900
27903
  })),
27904
+ pr_url: /^https:\/\/.*$/,
27901
27905
  };
27902
27906
 
27903
27907
  function ManualRebase() {
@@ -34418,7 +34422,7 @@ async function command() {
34418
34422
  .wrap(123)
34419
34423
  // disallow unknown options
34420
34424
  .strict()
34421
- .version("1.4.0" )
34425
+ .version("1.5.1" )
34422
34426
  .showHidden("show-hidden", "Show hidden options via `git stack help --show-hidden`")
34423
34427
  .help("help", "Show usage via `git stack help`").argv);
34424
34428
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "git-stack-cli",
3
- "version": "1.4.0",
3
+ "version": "1.5.1",
4
4
  "description": "",
5
5
  "author": "magus",
6
6
  "license": "MIT",
@@ -80,8 +80,8 @@ test("builds list of prs with selected emoji", () => {
80
80
  ...args.body.split("\n"),
81
81
  "",
82
82
  "#### git stack",
83
- "- ⏳ `2` https://github.com/magus/git-multi-diff-playground/pull/47",
84
83
  "- 👉 `1` https://github.com/magus/git-multi-diff-playground/pull/43",
84
+ "- ⏳ `2` https://github.com/magus/git-multi-diff-playground/pull/47",
85
85
  ]);
86
86
  });
87
87
 
@@ -123,9 +123,9 @@ test("persists removed pr urls from previous stack table", () => {
123
123
  "Summary of problem",
124
124
  "",
125
125
  "#### git stack",
126
- "- 👉 `3` https://github.com/magus/git-multi-diff-playground/pull/47",
127
- "- ⏳ `2` https://github.com/magus/git-multi-diff-playground/pull/44",
128
126
  "- ⏳ `1` https://github.com/magus/git-multi-diff-playground/pull/43",
127
+ "- ⏳ `2` https://github.com/magus/git-multi-diff-playground/pull/44",
128
+ "- 👉 `3` https://github.com/magus/git-multi-diff-playground/pull/47",
129
129
  ].join("\n"),
130
130
 
131
131
  pr_url_list: [
@@ -143,11 +143,49 @@ test("persists removed pr urls from previous stack table", () => {
143
143
  "Summary of problem",
144
144
  "",
145
145
  "#### git stack",
146
- "- `5` https://github.com/magus/git-multi-diff-playground/pull/61",
147
- "- ⏳ `4` https://github.com/magus/git-multi-diff-playground/pull/54",
148
- "- 👉 `3` https://github.com/magus/git-multi-diff-playground/pull/47",
146
+ "- `1` https://github.com/magus/git-multi-diff-playground/pull/43",
149
147
  "- ✅ `2` https://github.com/magus/git-multi-diff-playground/pull/44",
148
+ "- 👉 `3` https://github.com/magus/git-multi-diff-playground/pull/47",
149
+ "- ⏳ `4` https://github.com/magus/git-multi-diff-playground/pull/54",
150
+ "- ⏳ `5` https://github.com/magus/git-multi-diff-playground/pull/61",
151
+ ]);
152
+
153
+ // run again on the output to make sure it doesn't change
154
+ const rerun_output = StackSummaryTable.write({ ...args, body: output });
155
+
156
+ expect(rerun_output).toBe(output);
157
+ });
158
+
159
+ test("persist only valid urls, removed broken branch ids from interrupted sync", () => {
160
+ const args = {
161
+ body: [
162
+ "Summary of problem",
163
+ "",
164
+ "#### git stack",
165
+ "- ✅ `1` https://github.com/magus/git-multi-diff-playground/pull/43",
166
+ "- ✅ `2` gs-P4EBkJm+q",
167
+ "- 👉 `3` https://github.com/magus/git-multi-diff-playground/pull/47",
168
+ ].join("\n"),
169
+
170
+ pr_url_list: [
171
+ "https://github.com/magus/git-multi-diff-playground/pull/47",
172
+ "https://github.com/magus/git-multi-diff-playground/pull/54",
173
+ "https://github.com/magus/git-multi-diff-playground/pull/61",
174
+ ],
175
+
176
+ selected_url: "https://github.com/magus/git-multi-diff-playground/pull/47",
177
+ };
178
+
179
+ const output = StackSummaryTable.write(args);
180
+
181
+ expect(output.split("\n")).toEqual([
182
+ "Summary of problem",
183
+ "",
184
+ "#### git stack",
150
185
  "- ✅ `1` https://github.com/magus/git-multi-diff-playground/pull/43",
186
+ "- 👉 `2` https://github.com/magus/git-multi-diff-playground/pull/47",
187
+ "- ⏳ `3` https://github.com/magus/git-multi-diff-playground/pull/54",
188
+ "- ⏳ `4` https://github.com/magus/git-multi-diff-playground/pull/61",
151
189
  ]);
152
190
 
153
191
  // run again on the output to make sure it doesn't change
@@ -32,7 +32,9 @@ export function table(args: WriteArgs) {
32
32
  }
33
33
 
34
34
  // add remaining old stack pr urls to the front of stack pr url list
35
- for (const pr_url of old_stack.keys()) {
35
+ const old_pr_list = Array.from(old_stack.keys());
36
+ old_pr_list.reverse();
37
+ for (const pr_url of old_pr_list) {
36
38
  stack_pr_url_list.unshift(pr_url);
37
39
  }
38
40
 
@@ -62,9 +64,6 @@ export function table(args: WriteArgs) {
62
64
  return "";
63
65
  }
64
66
 
65
- // reverse order of pr list to match the order of git stack
66
- stack_list.reverse();
67
-
68
67
  return TEMPLATE.stack_table(["", ...stack_list, "", ""].join("\n"));
69
68
  }
70
69
 
@@ -89,6 +88,10 @@ export function parse(body: string): Map<string, StackTableRow> {
89
88
  continue;
90
89
  }
91
90
 
91
+ if (!RE.pr_url.test(parsed_row.pr_url)) {
92
+ continue;
93
+ }
94
+
92
95
  result.set(parsed_row.pr_url, parsed_row);
93
96
  }
94
97
 
@@ -118,6 +121,8 @@ const RE = {
118
121
  pr_url: "(?<pr_url>.+)",
119
122
  })
120
123
  ),
124
+
125
+ pr_url: /^https:\/\/.*$/,
121
126
  };
122
127
 
123
128
  type StackTableRow = {