From f1123cd002af3e9de56c68f41b99a7a9206b5a58 Mon Sep 17 00:00:00 2001 From: Nigel van Keulen Date: Thu, 9 May 2024 02:46:11 +0200 Subject: [PATCH] Auto-increment if tagname is not explicitly specified to 'quickgo exec git tag' --- commands/git.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/commands/git.js b/commands/git.js index 91326f8..7987c47 100644 --- a/commands/git.js +++ b/commands/git.js @@ -1,10 +1,22 @@ function main() { os.exec(`git add .`); - //let tagName = quickgo.environ.tag; - //if (!tagName) { - // tagName = os.exec("git tag --sort=committerdate | tail -1"); - //} + if (quickgo.environ.tag === true) { + let tagName = os.exec("git tag --sort=committerdate | tail -1"); + let regex = `(?:(\d+)\.)?(?:(\d+)\.)?(?:(\d+)\.\d+)` + let match = tagName.match(regex); + if (!match) { + return Result(1, `Could not find a valid tag to increment!`); + } + + let major = parseInt(match[1]); + let minor = parseInt(match[2]); + let patch = parseInt(match[3]); + patch++; + let newTag = `${major}.${minor}.${patch}`; + console.info(`Incrementing tag from ${tagName} to ${newTag}`); + quickgo.environ.tag = newTag; + } if (quickgo.environ.m) { console.info(`Committing changes with message: '${quickgo.environ.m}'`);