fix: remove hack to workaround GitHub Rebase & Merge
This commit is contained in:
+2
-15
@@ -1,4 +1,3 @@
|
||||
const {matches, pick, memoize} = require('lodash');
|
||||
const gitLogParser = require('git-log-parser');
|
||||
const getStream = require('get-stream');
|
||||
const execa = require('execa');
|
||||
@@ -70,21 +69,16 @@ async function getBranches(repositoryUrl, execaOpts) {
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
||||
const getBranchCommits = memoize((branch, execaOpts) =>
|
||||
getStream.array(gitLogParser.parse({_: branch}, {cwd: execaOpts.cwd, env: {...process.env, ...execaOpts.env}}))
|
||||
);
|
||||
|
||||
/**
|
||||
* Verify if the `ref` is in the direct history of a given branch.
|
||||
*
|
||||
* @param {String} ref The reference to look for.
|
||||
* @param {String} branch The branch for which to check if the `ref` is in history.
|
||||
* @param {Boolean} findRebasedTags Weither consider in history tags associated with a commit that was rebased to another branch (i.e. GitHub Rebase and Merge feature).
|
||||
* @param {Object} [execaOpts] Options to pass to `execa`.
|
||||
*
|
||||
* @return {Boolean} `true` if the reference is in the history of the current branch, falsy otherwise.
|
||||
*/
|
||||
async function isRefInHistory(ref, branch, findRebasedTags, execaOpts) {
|
||||
async function isRefInHistory(ref, branch, execaOpts) {
|
||||
if (!(await isRefExists(branch, execaOpts))) {
|
||||
return false;
|
||||
}
|
||||
@@ -94,13 +88,6 @@ async function isRefInHistory(ref, branch, findRebasedTags, execaOpts) {
|
||||
return true;
|
||||
} catch (error) {
|
||||
if (error.exitCode === 1) {
|
||||
if (findRebasedTags) {
|
||||
const [tagCommit] = await getStream.array(
|
||||
gitLogParser.parse({_: ref, n: '1'}, {cwd: execaOpts.cwd, env: {...process.env, ...execaOpts.env}})
|
||||
);
|
||||
return (await getBranchCommits(branch, execaOpts)).some(matches(pick(tagCommit, ['message', 'author'])));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -288,7 +275,7 @@ async function verifyBranchName(branch, execaOpts) {
|
||||
async function isBranchUpToDate(repositoryUrl, branch, execaOpts) {
|
||||
const {stdout: remoteHead} = await execa('git', ['ls-remote', '--heads', repositoryUrl, branch], execaOpts);
|
||||
try {
|
||||
return await isRefInHistory(remoteHead.match(/^(\w+)?/)[1], branch, false, execaOpts);
|
||||
return await isRefInHistory(remoteHead.match(/^(\w+)?/)[1], branch, execaOpts);
|
||||
} catch (error) {
|
||||
debug(error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user