7253-devToTest_2418 #2350

Merged
alexm merged 320 commits from 7253-devToTest_2418 into test 2024-04-23 08:02:46 +00:00
1 changed files with 19 additions and 21 deletions
Showing only changes of commit 1728ed955b - Show all commits

View File

@ -1,26 +1,6 @@
const fs = require('fs');
const path = require('path');
const branchName = getCurrentBranchName();
if (branchName) {
const msgPath = `.git/COMMIT_EDITMSG`;
const msg = fs.readFileSync(msgPath, 'utf-8');
const referenceTag = `refs #${branchName.match(/^\d+/)}`;
console.log('referenceTag: ', referenceTag);
console.log(msg);
if (!msg.includes(referenceTag)) {
const splitedMsg = msg.split(':');
if (splitedMsg.length > 1) {
const finalMsg = splitedMsg[0] + ': ' + referenceTag + splitedMsg.slice(1).join(':');
console.log('finalMsg: ', finalMsg);
fs.writeFileSync(msgPath, finalMsg);
}
}
}
function getCurrentBranchName(p = process.cwd()) {
if (!fs.existsSync(p)) return false;
@ -32,3 +12,21 @@ function getCurrentBranchName(p = process.cwd()) {
const headContent = fs.readFileSync(gitHeadPath, 'utf-8');
return headContent.trim().split('/')[2];
}
const branchName = getCurrentBranchName();
if (branchName) {
const msgPath = `.git/COMMIT_EDITMSG`;
const msg = fs.readFileSync(msgPath, 'utf-8');
const referenceTag = `refs #${branchName.match(/^\d+/)}`;
if (!msg.includes(referenceTag)) {
const splitedMsg = msg.split(':');
if (splitedMsg.length > 1) {
const finalMsg = splitedMsg[0] + ': ' + referenceTag + splitedMsg.slice(1).join(':');
fs.writeFileSync(msgPath, finalMsg);
}
}
}