7299_testToMaster #2411

Merged
alexm merged 342 commits from 7299_testToMaster into master 2024-05-07 05:30:42 +00:00
1 changed files with 9 additions and 11 deletions
Showing only changes of commit 021280c53c - Show all commits

View File

@ -3,17 +3,14 @@
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
async function getCurrentBranchName(p = process.cwd()) { function getCurrentBranchName(p = process.cwd()) {
while (p !== path.parse(p).root) { const gitHeadPath = `${p}/.git/HEAD`;
const gitHeadPath = path.join(p, '.git', 'HEAD');
try { return fs.existsSync(p) ?
const headContent = await fs.readFile(gitHeadPath, 'utf-8'); fs.existsSync(gitHeadPath) ?
return headContent.trim().split('/')[2]; fs.readFileSync(gitHeadPath, 'utf-8').trim().split('/')[2] :
} catch (err) { getCurrentBranchName(path.resolve(p, '..')) :
p = path.resolve(p, '..'); false
}
}
return false;
} }
const branchName = getCurrentBranchName(); const branchName = getCurrentBranchName();
if (branchName) { if (branchName) {
@ -29,6 +26,7 @@ if (branchName) {
if (splitedMsg.length > 1) { if (splitedMsg.length > 1) {
const finalMsg = splitedMsg[0] + splitedMsg.slice(1).join(':'); const finalMsg = splitedMsg[0] + splitedMsg.slice(1).join(':');
console.log('finalMsg: ', finalMsg);
fs.writeFileSync(msgPath, finalMsg); fs.writeFileSync(msgPath, finalMsg);
} }
} }