Skip to content

Commit

Permalink
Avoid skipping push if branch name isn't "master" (#397)
Browse files Browse the repository at this point in the history
  • Loading branch information
itaisteinherz committed May 9, 2019
1 parent d4bf883 commit 15176f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"chalk": "^2.3.0",
"cosmiconfig": "^5.1.0",
"del": "^4.1.0",
"escape-string-regexp": "^2.0.0",
"execa": "^1.0.0",
"github-url-from-git": "^1.5.0",
"has-yarn": "^2.1.0",
Expand Down
7 changes: 5 additions & 2 deletions source/git-util.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';
const execa = require('execa');
const escapeStringRegexp = require('escape-string-regexp');
const version = require('./version');

exports.latestTag = () => execa.stdout('git', ['describe', '--abbrev=0', '--tags']);
Expand All @@ -20,8 +21,10 @@ exports.latestTagOrFirstCommit = async () => {
};

exports.hasUpstream = async () => {
const {stdout} = await execa('git', ['status', '--short', '--branch', '--porcelain=2']);
return /^# branch\.upstream [\w\-/]+$/m.test(stdout);
const escapedCurrentBranch = escapeStringRegexp(await exports.currentBranch());
const {stdout} = await execa('git', ['status', '--short', '--branch', '--porcelain']);

return new RegExp(String.raw`^## ${escapedCurrentBranch}\.\.\..+\/${escapedCurrentBranch}`).test(stdout);
};

exports.currentBranch = () => execa.stdout('git', ['symbolic-ref', '--short', 'HEAD']);
Expand Down

0 comments on commit 15176f4

Please sign in to comment.