fix(diff): handle ambiguous revision in diff --stat command
This commit is contained in:
parent
0edc001d28
commit
f9b11b729c
18
dist/index.js
vendored
18
dist/index.js
vendored
@ -56,7 +56,6 @@ exports.buildBranchCommits = buildBranchCommits;
|
|||||||
exports.createOrUpdateBranch = createOrUpdateBranch;
|
exports.createOrUpdateBranch = createOrUpdateBranch;
|
||||||
const core = __importStar(__nccwpck_require__(7484));
|
const core = __importStar(__nccwpck_require__(7484));
|
||||||
const uuid_1 = __nccwpck_require__(2048);
|
const uuid_1 = __nccwpck_require__(2048);
|
||||||
const utils = __importStar(__nccwpck_require__(9277));
|
|
||||||
const CHERRYPICK_EMPTY = 'The previous cherry-pick is now empty, possibly due to conflict resolution.';
|
const CHERRYPICK_EMPTY = 'The previous cherry-pick is now empty, possibly due to conflict resolution.';
|
||||||
const NOTHING_TO_COMMIT = 'nothing to commit, working tree clean';
|
const NOTHING_TO_COMMIT = 'nothing to commit, working tree clean';
|
||||||
const FETCH_DEPTH_MARGIN = 10;
|
const FETCH_DEPTH_MARGIN = 10;
|
||||||
@ -150,16 +149,19 @@ function commitsHaveDiff(git, branch1, branch2, depth) {
|
|||||||
// Some action use cases lead to the depth being a very large number and the diff fails.
|
// Some action use cases lead to the depth being a very large number and the diff fails.
|
||||||
// I've made this check optional for now because it was a fix for an edge case that is
|
// I've made this check optional for now because it was a fix for an edge case that is
|
||||||
// very rare, anyway.
|
// very rare, anyway.
|
||||||
try {
|
const result1 = yield git.exec(['diff', '--stat', `${branch1}..${branch1}~${depth}`], { allowAllExitCodes: true });
|
||||||
const diff1 = (yield git.exec(['diff', '--stat', `${branch1}..${branch1}~${depth}`])).stdout.trim();
|
if (result1.exitCode !== 0) {
|
||||||
const diff2 = (yield git.exec(['diff', '--stat', `${branch2}..${branch2}~${depth}`])).stdout.trim();
|
|
||||||
return diff1 !== diff2;
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
core.info('Failed optional check of commits diff; Skipping.');
|
core.info('Failed optional check of commits diff; Skipping.');
|
||||||
core.debug(utils.getErrorMessage(error));
|
core.debug(result1.stderr);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
const result2 = yield git.exec(['diff', '--stat', `${branch2}..${branch2}~${depth}`], { allowAllExitCodes: true });
|
||||||
|
if (result2.exitCode !== 0) {
|
||||||
|
core.info('Failed optional check of commits diff; Skipping.');
|
||||||
|
core.debug(result2.stderr);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return result1.stdout.trim() !== result2.stdout.trim();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function splitLines(multilineString) {
|
function splitLines(multilineString) {
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import {GitCommandManager, Commit} from './git-command-manager'
|
import {GitCommandManager, Commit} from './git-command-manager'
|
||||||
import {v4 as uuidv4} from 'uuid'
|
import {v4 as uuidv4} from 'uuid'
|
||||||
import * as utils from './utils'
|
|
||||||
|
|
||||||
const CHERRYPICK_EMPTY =
|
const CHERRYPICK_EMPTY =
|
||||||
'The previous cherry-pick is now empty, possibly due to conflict resolution.'
|
'The previous cherry-pick is now empty, possibly due to conflict resolution.'
|
||||||
@ -135,19 +134,27 @@ async function commitsHaveDiff(
|
|||||||
// Some action use cases lead to the depth being a very large number and the diff fails.
|
// Some action use cases lead to the depth being a very large number and the diff fails.
|
||||||
// I've made this check optional for now because it was a fix for an edge case that is
|
// I've made this check optional for now because it was a fix for an edge case that is
|
||||||
// very rare, anyway.
|
// very rare, anyway.
|
||||||
try {
|
const result1 = await git.exec(
|
||||||
const diff1 = (
|
['diff', '--stat', `${branch1}..${branch1}~${depth}`],
|
||||||
await git.exec(['diff', '--stat', `${branch1}..${branch1}~${depth}`])
|
{allowAllExitCodes: true}
|
||||||
).stdout.trim()
|
)
|
||||||
const diff2 = (
|
if (result1.exitCode !== 0) {
|
||||||
await git.exec(['diff', '--stat', `${branch2}..${branch2}~${depth}`])
|
|
||||||
).stdout.trim()
|
|
||||||
return diff1 !== diff2
|
|
||||||
} catch (error) {
|
|
||||||
core.info('Failed optional check of commits diff; Skipping.')
|
core.info('Failed optional check of commits diff; Skipping.')
|
||||||
core.debug(utils.getErrorMessage(error))
|
core.debug(result1.stderr)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const result2 = await git.exec(
|
||||||
|
['diff', '--stat', `${branch2}..${branch2}~${depth}`],
|
||||||
|
{allowAllExitCodes: true}
|
||||||
|
)
|
||||||
|
if (result2.exitCode !== 0) {
|
||||||
|
core.info('Failed optional check of commits diff; Skipping.')
|
||||||
|
core.debug(result2.stderr)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return result1.stdout.trim() !== result2.stdout.trim()
|
||||||
}
|
}
|
||||||
|
|
||||||
function splitLines(multilineString: string): string[] {
|
function splitLines(multilineString: string): string[] {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user