Skip to content

Commit

Permalink
Auto-increment if tagname is not explicitly specified to 'quickgo exe…
Browse files Browse the repository at this point in the history
…c git tag'
  • Loading branch information
Nigel2392 committed May 9, 2024
1 parent 706b285 commit f1123cd
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions commands/git.js
Original file line number Diff line number Diff line change
@@ -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}'`);
Expand Down

0 comments on commit f1123cd

Please sign in to comment.