From 1728ed955bd8fb9175bf490b3dddcfb85ccd18f3 Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 8 Apr 2024 08:51:13 +0200 Subject: [PATCH] fix: refs #6130 code remove console.log --- .husky/addReferenceTag.js | 40 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/.husky/addReferenceTag.js b/.husky/addReferenceTag.js index ce4134e1a..399c69301 100644 --- a/.husky/addReferenceTag.js +++ b/.husky/addReferenceTag.js @@ -1,26 +1,6 @@ -const fs = require('fs'); +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); + } + } +} +