Fix issue with rebase format and message type
This commit is contained in:
parent
41032cd5ac
commit
134cd0e3e3
@ -8,11 +8,20 @@ const exec = promisify(childProcess.exec);
|
||||
const readFile = promisify(fs.readFile);
|
||||
const writeFile = promisify(fs.writeFile);
|
||||
|
||||
const [, , commitMsg, comitSrc, sha1] = process.argv;
|
||||
const [, , message, mode] = process.argv;
|
||||
|
||||
async function main() {
|
||||
const file = await readFile(commitMsg, { encoding: "utf8" });
|
||||
const result = await exec("git symbolic-ref --short HEAD");
|
||||
const file = await readFile(message, { encoding: "utf8" });
|
||||
let result;
|
||||
try {
|
||||
result = await exec("git rev-parse --abbrev-ref HEAD");
|
||||
} catch (err) {
|
||||
return
|
||||
}
|
||||
|
||||
if (message.match(/^#/)) {
|
||||
return
|
||||
}
|
||||
|
||||
const tags = result.stdout
|
||||
.split("\n")
|
||||
@ -27,8 +36,12 @@ async function main() {
|
||||
if (tags.find(tag => file.includes(tag))) {
|
||||
return;
|
||||
}
|
||||
const newFile = "\n\n# " + tags.join(" ") + "\n" + file;
|
||||
await writeFile(commitMsg, newFile);
|
||||
|
||||
const newFile = mode === 'message'
|
||||
? file + '\n\n' + tags.join(" ")
|
||||
: `\n\n# ` + tags.join(" ") + "\n" + file;
|
||||
|
||||
await writeFile(message, newFile);
|
||||
}
|
||||
|
||||
main().catch(err => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user