@aaronshaf/ger
Advanced tools
Comparing version 1.2.2 to 1.2.3
{ | ||
"name": "@aaronshaf/ger", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"description": "Gerrit CLI", | ||
@@ -24,3 +24,3 @@ "main": "src/ger.ts", | ||
"@commander-js/extra-typings": "^10.0.3", | ||
"@types/node": "^18.16.0", | ||
"@types/node": "^18.16.1", | ||
"cli-table3": "^0.6.3", | ||
@@ -27,0 +27,0 @@ "eslint": "^8.39.0", |
import { execSync } from "child_process"; | ||
import { createInterface } from "readline"; | ||
import { | ||
abbreviateApproverDescription, | ||
bold, | ||
@@ -11,2 +12,3 @@ darkBrown, | ||
grey, | ||
normalizeApproverName, | ||
normalizeValue, | ||
@@ -20,3 +22,2 @@ yellow, | ||
} from "../types.d"; | ||
import { isDataView } from "util/types"; | ||
@@ -100,3 +101,5 @@ const Table = require("cli-table3"); | ||
isMerged && green("Merged"), | ||
].filter(Boolean) as string[]; | ||
] | ||
.filter(Boolean) | ||
.map((str) => `[${str}]`) as string[]; | ||
@@ -109,7 +112,8 @@ const approvals = gerritData.currentPatchSet.approvals.map((a) => { | ||
return isVerbose | ||
? `${description || a.type}: ${normalizeValue(a.value)} (${a.by.name | ||
.replace(" (Bot)", "") | ||
.replace("Service Cloud Jenkins", "Jenkins") | ||
.replace("Larry Gergich", "Gergich")})` | ||
: normalizeValue(a.value); | ||
? `${description || a.type}: ${normalizeValue( | ||
a.value | ||
)} (${normalizeApproverName(a.by.name)})` | ||
: `${abbreviateApproverDescription( | ||
description || a.type | ||
)}${normalizeValue(a.value)}`; | ||
}); | ||
@@ -121,5 +125,5 @@ | ||
table.push([ | ||
`${localBranch}\n${yellow(gerritData.url.replace("https://", ""))}`, | ||
`${bold(localBranch)}\n${localBranchDataMap[localBranch].shortHash}`, | ||
labels.join(" "), | ||
subject, | ||
`${subject}\n${yellow(gerritData.url.replace("https://", ""))}`, | ||
approvalText, | ||
@@ -137,9 +141,18 @@ ]); | ||
} else { | ||
// table.push([ | ||
// localBranch, | ||
// "", | ||
// "", | ||
// localBranchDataMap[localBranch].subject, | ||
// "", | ||
// ]); | ||
if (isVerbose) { | ||
table.push([ | ||
`${bold(localBranch)}\n${localBranchDataMap[localBranch].shortHash}`, | ||
"", | ||
localBranchDataMap[localBranch].subject, | ||
"", | ||
]); | ||
} else { | ||
table.push([ | ||
localBranch, | ||
"", | ||
"", | ||
localBranchDataMap[localBranch].subject, | ||
"", | ||
]); | ||
} | ||
} | ||
@@ -146,0 +159,0 @@ } |
export type LocalBranchData = { | ||
changeId: string | null; | ||
shortHash: string | ||
subject: string; | ||
@@ -4,0 +5,0 @@ } |
@@ -20,4 +20,6 @@ import { execSync } from "child_process"; | ||
// brown with transparent background | ||
export function darkBrown(text: string) { | ||
return `\x1b[43m\x1b[30m${text}\x1b[0m`; | ||
// return `\x1b[43m\x1b[30m${text}\x1b[0m`; | ||
return `\x1b[33m${text}\x1b[0m`; | ||
} | ||
@@ -31,3 +33,4 @@ | ||
export function yellow(text: string) { | ||
return `\x1b[33m\x1b[40m${text}\x1b[0m`; | ||
// return `\x1b[33m\x1b[40m${text}\x1b[0m`; | ||
return `\x1b[33m${text}\x1b[0m`; | ||
} | ||
@@ -83,13 +86,14 @@ | ||
return branchNames.reduce<LocalBranchDataMap>((acc, branchName) => { | ||
// Get the latest commit message | ||
const commit_message = execSync(`git log -1 --pretty=%B ${branchName}`) | ||
// Get the latest commit SHA and message | ||
const gitLogOutput = execSync(`git log -1 --pretty=format:%h%n%B ${branchName}`) | ||
.toString() | ||
.trim(); | ||
// Get first line of commit message | ||
const firstLine = commit_message.split("\n")[0]; | ||
// Split the output into commit SHA and message | ||
const [shortHash, ...commitMessageLines] = gitLogOutput.split("\n"); | ||
const localBranchData: LocalBranchData = { | ||
changeId: getChangeIdFromCommitMessage(commit_message) || null, | ||
subject: firstLine, | ||
changeId: getChangeIdFromCommitMessage(commitMessageLines.join("\n")) || null, | ||
subject: commitMessageLines[0], | ||
shortHash, | ||
}; | ||
@@ -109,2 +113,25 @@ | ||
return value; | ||
}; | ||
}; | ||
export function normalizeApproverName(name: string) { | ||
return name | ||
.replace(" (Bot)", "") | ||
.replace("Service Cloud Jenkins", "Jenkins") | ||
.replace("Larry Gergich", "Gergich"); | ||
} | ||
export function abbreviateApproverDescription(name: string) { | ||
if (name === "Lint-Review") { | ||
return `Lint `; | ||
} | ||
if (name === "Code-Review") { | ||
return `CR `; | ||
} | ||
if (name === "Product-Review") { | ||
return `PR `; | ||
} | ||
if (name === "QA-Review") { | ||
return `QA `; | ||
} | ||
return `${name} `; | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
11892
343
0