@aaronshaf/ger 1.2.9 → 1.2.11

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
@@ -23,6 +23,6 @@ ger branch
23
23
  # list branches with expanded gerrit info
24
24
  ger branch -v
25
25
 
26
- # prompt to delete already-merged branches
26
+ # prompt to delete branches of submitted or abandoned changes
27
27
  ger branch -d
28
28
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aaronshaf/ger",
3
- "version": "1.2.9",
3
+ "version": "1.2.11",
4
4
  "description": "Gerrit CLI",
5
5
  "main": "src/ger.ts",
6
6
  "bin": {
@@ -39,7 +39,9 @@ export function branch({
39
39
  const changeId = localBranchDataMap[name].changeId;
40
40
  if (changeId) {
41
41
  const gerritData = gerritOutputByChangeId[changeId];
42
- return gerritData?.status === "MERGED";
42
+ return (
43
+ gerritData?.status === "MERGED" || gerritData?.status === "ABANDONED"
44
+ );
43
45
  }
44
46
  return false;
45
47
  });
@@ -100,19 +102,21 @@ function output(
100
102
  .filter(Boolean)
101
103
  .map((str) => `[${str}]`) as string[];
102
104
 
103
- const approvals = (gerritData.currentPatchSet.approvals || []).map((a) => {
104
- let description = a.description;
105
- if (a.type === "SUBM" && !description) {
106
- description = "Submitted";
105
+ const approvals = (gerritData.currentPatchSet.approvals || []).map(
106
+ (a) => {
107
+ let description = a.description;
108
+ if (a.type === "SUBM" && !description) {
109
+ description = "Submitted";
110
+ }
111
+ return isVerbose
112
+ ? `${description || a.type}: ${normalizeValue(
113
+ a.value
114
+ )} (${normalizeApproverName(a.by.name)})`
115
+ : `${abbreviateApproverDescription(
116
+ description || a.type
117
+ )}${normalizeValue(a.value)}`;
107
118
  }
108
- return isVerbose
109
- ? `${description || a.type}: ${normalizeValue(
110
- a.value
111
- )} (${normalizeApproverName(a.by.name)})`
112
- : `${abbreviateApproverDescription(
113
- description || a.type
114
- )}${normalizeValue(a.value)}`;
115
- });
119
+ );
116
120
 
117
121
  const approvalText = approvals.join(isVerbose ? "\n" : ", ");
118
122
 
@@ -122,8 +126,10 @@ function output(
122
126
 
123
127
  if (isVerbose) {
124
128
  table.push([
125
- `${bold(localBranch)}${topicText}\n${localBranchDataMap[localBranch].shortHash}`,
126
- `${labels.join(" ")}`,
129
+ `${bold(localBranch)}${topicText}\n${
130
+ localBranchDataMap[localBranch].shortHash
131
+ }`,
132
+ `${labels.join("\n")}`,
127
133
  `${subject}\n${yellow(gerritData.url.replace("https://", ""))}`,
128
134
  approvalText,
129
135
  ]);
@@ -163,11 +169,21 @@ async function promptForMergedBranchDeletion(mergedBranches: string[]) {
163
169
  input: process.stdin,
164
170
  output: process.stdout,
165
171
  });
172
+
173
+ if (mergedBranches.length > 0) {
174
+ console.log('')
175
+ console.log(
176
+ `The following ${bold(String(mergedBranches.length))} local branches are merged or abandoned:`
177
+ );
178
+ for (const mergedLocalBranch of mergedBranches) {
179
+ console.log(` ${bold(mergedLocalBranch)}`);
180
+ }
181
+ }
166
182
 
167
183
  for (const mergedLocalBranch of mergedBranches) {
168
184
  const answer: string = await new Promise((resolve) => {
169
185
  readline.question(
170
- `Delete merged local branch ${bold(mergedLocalBranch)}? (y/n) `,
186
+ `Delete local branch ${bold(mergedLocalBranch)}? (y/n) `,
171
187
  resolve
172
188
  );
173
189
  });
package/src/utils.ts CHANGED
@@ -13,7 +13,7 @@ export function bold(text: string) {
13
13
  }
14
14
 
15
15
  export function grey(text: string) {
16
- return `\x1b[37m\x1b[40m${text}\x1b[0m`;
16
+ return `\x1b[90m${text}\x1b[0m`;
17
17
  }
18
18
 
19
19
  export function darkBrown(text: string) {