Last active
April 24, 2017 11:22
-
-
Save sebald/6f9cc8be436e73ecc121777fb12d8ffc to your computer and use it in GitHub Desktop.
Revisions
-
sebald revised this gist
Apr 24, 2017 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ const { exec } = require('child_process'); const { readFile, writeFile } = require('fs'); const { EOL } = require('os'); const CURRENT_BRANCH_JIRA_ISSUE_EXP = /[a-zA-Z]+[-][0-9]+/; const messageFile = process.argv[2]; /** @@ -14,12 +14,12 @@ if(!/COMMIT_EDITMSG/i.test(messageFile)) { return process.exit(0); } exec('git rev-parse --abbrev-ref HEAD', (err, stdout) => { // Command will fail if there are no commits yet. if (err) { return process.exit(0); } // Extract Jira issue number from current branch. const issue = (CURRENT_BRANCH_JIRA_ISSUE_EXP.exec(stdout)||[])[0]; // Could not find an issue number. if (!issue) { return process.exit(0); } -
sebald revised this gist
Jan 27, 2017 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,7 +19,7 @@ exec('git branch', (err, stdout) => { if (err) { return process.exit(0); } // Extract Jira issue number from current branch. const issue = (CURRENT_BRANCH_JIRA_ISSUE_EXP.exec(stdout)||[])[1]; // Could not find an issue number. if (!issue) { return process.exit(0); } @@ -29,7 +29,7 @@ exec('git branch', (err, stdout) => { if (err) { return process.exit(0) }; // Append issue number to file content and write back. writeFile(messageFile, `${data}${EOL}${EOL}Issue: ${issue.toUpperCase()}`, () => { process.exit(0); }); }); -
sebald created this gist
Jan 26, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ #!/usr/bin/env node const { exec } = require('child_process'); const { readFile, writeFile } = require('fs'); const { EOL } = require('os'); const CURRENT_BRANCH_JIRA_ISSUE_EXP = /\*[^/]*\/([a-zA-Z]+([-][0-9]+)+)/; const messageFile = process.argv[2]; /** * We need the message file to append. * If we can not find it -> abort. */ if(!/COMMIT_EDITMSG/i.test(messageFile)) { return process.exit(0); } exec('git branch', (err, stdout) => { // Command will fail if there are no commits yet. if (err) { return process.exit(0); } // Extract Jira issue number from current branch. const issue = (CURRENT_BRANCH_JIRA_ISSUE_EXP.exec(stdout)||[])[1].toUpperCase(); // Could not find an issue number. if (!issue) { return process.exit(0); } // Read commit message file readFile(messageFile, (err, data) => { if (err) { return process.exit(0) }; // Append issue number to file content and write back. writeFile(messageFile, `${data}${EOL}${EOL}Issue: ${issue}`, () => { process.exit(0); }); }); });