Repository URL to install this package:
|
Version:
0.0.1 ▾
|
const open = require('open');
const currentBranch = require('current-git-branch');
const chalk = require('chalk');
const { JIRA_KEYS } = require('./constants');
module.exports = () => {
const branch = currentBranch();
const jiraKeys = Object.keys(JIRA_KEYS);
if (branch) {
const branchParts = branch.split('-');
const branchKey = branchParts[0];
const ticketNumber = branchParts.length > 1 ? branchParts[1] : null;
if (jiraKeys.indexOf(branchKey) > -1) {
// We have found a branch name that begins with a JIRA KEY
if (ticketNumber && !Number.isNaN(ticketNumber)) {
const url = `https://doodleag.atlassian.net/browse/${branchKey}-${ticketNumber}`;
console.log(`${chalk.cyan('Opening url')} ${url}`);
open(url);
} else {
console.log(`${chalk.magenta('Your branch naming does not meet the pattern of')} XXX-000`);
}
} else {
console.log(`${chalk.magenta('Could not find a recognized JIRA pattern with')} XXX-000`);
}
} else {
console.log('No branch was found.');
}
};