Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Tran authored and Jacob Tran committed Jun 19, 2018
1 parent 2828040 commit cc76733
Showing 1 changed file with 22 additions and 23 deletions.
45 changes: 22 additions & 23 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,35 +56,34 @@ function loadConfig () {
}
}

function getEnvIdFromBranch() {
try {
var branch = sh.exec('git status', { silent: true }).stdout;
function getEnvIdFromBranch () {
try {
var branch = sh.exec('git status', { silent: true }).stdout

if (!branch || _.includes(branch, 'fatal:')) {
return;
}
if (!branch || _.includes(branch, 'fatal:')) {
return
}

branch = branch.split('\n')[0];
branch = branch.replace(/^#?\s?On branch ((\w|-|_|\/|.)+)/, '$1');
branch = branch.split('\n')[0]
branch = branch.replace(/^#?\s?On branch ((\w|-|_|\/|.)+)/, '$1')

if (config.branchRegex) {
branch = branch.replace(new RegExp(_.trim(config.branchRegex)), '$1');
}
if (config.branchRegex) {
branch = branch.replace(new RegExp(_.trim(config.branchRegex)), '$1')
}

branch = _.trimEnd(_.truncate(branch, {
length: 13,
omission: ''
}), '-');
branch = _.trimEnd(_.truncate(branch, {
length: 13,
omission: ''
}), '-');

var hash = sh.exec('git rev-parse origin/master', { silent: true }).stdout;
hash = hash.substring(0, 5);
var hash = sh.exec('git rev-parse origin/master', { silent: true }).stdout
hash = hash.substring(0, 5)

return (branch.includes(' ')) ? hash : branch;
}
catch (e) {
console.log('ERR: ', e);
// Do nothing
}
return (branch.includes(' ')) ? hash : branch
} catch (e) {
console.log('ERR: ', e)
// Do nothing
}
}

function getEnvId (obj, env) {
Expand Down

0 comments on commit cc76733

Please sign in to comment.