git-stack-cli 0.8.6 → 0.8.7

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.
@@ -49,7 +49,7 @@ async function run() {
49
49
  if (merged_pr) {
50
50
  if (actions.isDebug()) {
51
51
  actions.output(React.createElement(FormatText, { wrapper: React.createElement(Ink.Text, { color: colors.yellow, wrap: "truncate-end" }), message: "Dropping {commit_message} {pr_status}", values: {
52
- commit_message: React.createElement(Brackets, null, commit.message),
52
+ commit_message: React.createElement(Brackets, null, commit.subject_line),
53
53
  pr_status: React.createElement(Parens, null, "MERGED"),
54
54
  } }));
55
55
  }
@@ -58,7 +58,7 @@ async function run() {
58
58
  // cherry-pick and amend commits one by one
59
59
  if (actions.isDebug()) {
60
60
  actions.output(React.createElement(FormatText, { wrapper: React.createElement(Ink.Text, { color: colors.yellow, wrap: "truncate-end" }), message: "Picking {commit_message}", values: {
61
- commit_message: React.createElement(Brackets, null, commit.message),
61
+ commit_message: React.createElement(Brackets, null, commit.subject_line),
62
62
  } }));
63
63
  }
64
64
  // ensure clean base to avoid conflicts when applying patch
@@ -71,10 +71,10 @@ async function run() {
71
71
  await cli(`git add --all`);
72
72
  let new_message;
73
73
  if (commit.branch_id) {
74
- new_message = await Metadata.write(commit.message, commit.branch_id);
74
+ new_message = await Metadata.write(commit.full_message, commit.branch_id);
75
75
  }
76
76
  else {
77
- new_message = commit.message;
77
+ new_message = commit.full_message;
78
78
  }
79
79
  const git_commit_comand = [`git commit -m "${new_message}"`];
80
80
  if (argv.verify === false) {
@@ -88,7 +88,7 @@ async function run() {
88
88
  } }));
89
89
  }
90
90
  // missing PR, clear branch id from commit
91
- const new_message = await Metadata.remove(commit.message);
91
+ const new_message = await Metadata.remove(commit.full_message);
92
92
  await cli(`git commit --amend -m "${new_message}"`);
93
93
  }
94
94
  }
@@ -76,7 +76,7 @@ async function run(props) {
76
76
  await cli(`rm ${PATCH_FILE}`);
77
77
  // add all changes to stage
78
78
  await cli(`git add --all`);
79
- const new_message = await Metadata.write(commit.message, group.id);
79
+ const new_message = await Metadata.write(commit.full_message, group.id);
80
80
  const git_commit_comand = [`git commit -m "${new_message}"`];
81
81
  if (argv.verify === false) {
82
82
  git_commit_comand.push("--no-verify");
@@ -116,7 +116,7 @@ function SelectCommitRangesInternal(props) {
116
116
  disabled = Boolean(selected && commit_metadata_id !== group.id);
117
117
  }
118
118
  return {
119
- label: commit.message,
119
+ label: commit.subject_line,
120
120
  value: commit,
121
121
  selected,
122
122
  disabled,
@@ -138,17 +138,17 @@ async function get_commit_list() {
138
138
  return commit_metadata_list;
139
139
  }
140
140
  export async function commit(sha) {
141
- const raw_message = (await cli(`git show -s --format=%B ${sha}`)).stdout;
142
- const branch_id = await Metadata.read(raw_message);
143
- const message = display_message(raw_message);
141
+ const full_message = (await cli(`git show -s --format=%B ${sha}`)).stdout;
142
+ const branch_id = await Metadata.read(full_message);
143
+ const subject_line = get_subject_line(full_message);
144
144
  return {
145
145
  sha,
146
- message,
147
- raw_message,
146
+ full_message,
147
+ subject_line,
148
148
  branch_id,
149
149
  };
150
150
  }
151
- function display_message(message) {
151
+ function get_subject_line(message) {
152
152
  const line_list = lines(message);
153
153
  const first_line = line_list[0];
154
154
  return Metadata.remove(first_line);
@@ -1,17 +1,17 @@
1
1
  import { invariant } from "../core/invariant.js";
2
2
  import { safe_quote } from "../core/safe_quote.js";
3
- export function write(message, branch_id) {
3
+ export function write(message, stack_id) {
4
4
  let result = message;
5
5
  // escape double-quote for cli
6
6
  result = safe_quote(result);
7
7
  // remove any previous metadata lines
8
8
  result = remove(result);
9
- const line_list = [result, "", TEMPLATE.branch_id(branch_id)];
9
+ const line_list = [result, "", TEMPLATE.stack_id(stack_id)];
10
10
  const new_message = line_list.join("\n");
11
11
  return new_message;
12
12
  }
13
13
  export function read(message) {
14
- const match = message.match(RE.branch_id);
14
+ const match = message.match(RE.stack_id);
15
15
  if (!match?.groups) {
16
16
  return null;
17
17
  }
@@ -22,15 +22,15 @@ export function read(message) {
22
22
  export function remove(message) {
23
23
  let result = message;
24
24
  // remove metadata
25
- result = result.replace(new RegExp(RE.branch_id, "g"), "");
25
+ result = result.replace(new RegExp(RE.stack_id, "gmi"), "");
26
26
  result = result.trimEnd();
27
27
  return result;
28
28
  }
29
29
  const TEMPLATE = {
30
- branch_id(id) {
30
+ stack_id(id) {
31
31
  return `git-stack-id: ${id}`;
32
32
  },
33
33
  };
34
34
  const RE = {
35
- branch_id: new RegExp(TEMPLATE.branch_id("(?<id>[a-z0-9-+=]+)"), "i"),
35
+ stack_id: new RegExp(TEMPLATE.stack_id("(?<id>[a-z0-9-+=]+)"), "i"),
36
36
  };
@@ -0,0 +1,34 @@
1
+ import { test, expect } from "bun:test";
2
+ import * as Metadata from "./Metadata.js";
3
+ test("read handles bulleted lists", () => {
4
+ const body = [
5
+ "[feat] implement various features",
6
+ "",
7
+ "- keyboard modality escape key",
8
+ "- centralize settings",
9
+ "- move logic inside if branch",
10
+ "",
11
+ "git-stack-id: DdKIFyufW",
12
+ ].join("\n");
13
+ expect(Metadata.read(body)).toEqual("DdKIFyufW");
14
+ });
15
+ test("write handles bulleted lists", () => {
16
+ const body = [
17
+ "[feat] implement various features",
18
+ "",
19
+ "- keyboard modality escape key",
20
+ "- centralize settings",
21
+ "- move logic inside if branch",
22
+ "",
23
+ "git-stack-id: DdKIFyufW",
24
+ ].join("\n");
25
+ expect(Metadata.write(body, "abcd1234")).toEqual([
26
+ "[feat] implement various features",
27
+ "",
28
+ "- keyboard modality escape key",
29
+ "- centralize settings",
30
+ "- move logic inside if branch",
31
+ "",
32
+ "git-stack-id: abcd1234",
33
+ ].join("\n"));
34
+ });
@@ -60,8 +60,7 @@ export function parse(body) {
60
60
  const row_match = row.match(RE.row);
61
61
  const parsed_row = row_match?.groups;
62
62
  if (!parsed_row) {
63
- // eslint-disable-next-line no-console
64
- console.error(`parse row [${row}]`);
63
+ // skip invalid row
65
64
  continue;
66
65
  }
67
66
  result.set(parsed_row.pr_url, parsed_row);
@@ -10,7 +10,35 @@ test("blank", () => {
10
10
  });
11
11
  test("no prs does not modify body", () => {
12
12
  const args = {
13
- body: `## Problem\n\nDescription of the problem\n\n## Solution\n\nSolved problem by doing x, y, z.`,
13
+ body: [
14
+ "## Problem,",
15
+ "",
16
+ ",Description of the problem,",
17
+ "",
18
+ ",## Solution,",
19
+ "",
20
+ ",Solved problem by doing x, y, z.",
21
+ ].join("\n"),
22
+ pr_url_list: [],
23
+ selected_url: "",
24
+ };
25
+ const output = StackSummaryTable.write(args);
26
+ expect(output).toBe(args.body);
27
+ });
28
+ test("handles bulleted lists", () => {
29
+ const body = [
30
+ "## Problem",
31
+ "",
32
+ "Description of the problem",
33
+ "",
34
+ "## Solution",
35
+ "",
36
+ "- keyboard modality escape key",
37
+ "- centralize settings",
38
+ "- move logic inside if branch",
39
+ ].join("\n");
40
+ const args = {
41
+ body,
14
42
  pr_url_list: [],
15
43
  selected_url: "",
16
44
  };
@@ -19,7 +47,15 @@ test("no prs does not modify body", () => {
19
47
  });
20
48
  test("builds list of prs with selected emoji", () => {
21
49
  const args = {
22
- body: "## Problem\n\nDescription of the problem\n\n## Solution\n\nSolved problem by doing x, y, z.",
50
+ body: [
51
+ "## Problem,",
52
+ "",
53
+ ",Description of the problem,",
54
+ "",
55
+ ",## Solution,",
56
+ "",
57
+ ",Solved problem by doing x, y, z.",
58
+ ].join("\n"),
23
59
  pr_url_list: [
24
60
  "https://github.com/magus/git-multi-diff-playground/pull/43",
25
61
  "https://github.com/magus/git-multi-diff-playground/pull/47",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "git-stack-cli",
3
- "version": "0.8.6",
3
+ "version": "0.8.7",
4
4
  "description": "",
5
5
  "author": "magus",
6
6
  "license": "MIT",
@@ -19,9 +19,9 @@
19
19
  "scripts": {
20
20
  "build": "tsc",
21
21
  "dev": "tsc --watch",
22
- "lint:check": "eslint .",
22
+ "lint:check": "eslint . --cache",
23
23
  "lint": "npm run lint:check -- --fix",
24
- "prettier:check": "prettier ./src --check",
24
+ "prettier:check": "prettier ./src --check --cache",
25
25
  "prettier": "npm run prettier:check -- --write",
26
26
  "test": "bun test src",
27
27
  "test:watch": "npm run test -- --watch",