fix: handle ambiguous argument failure on diff stat
This commit is contained in:
parent
6073f5434b
commit
66468b3fc2
2 changed files with 31 additions and 10 deletions
17
dist/index.js
vendored
17
dist/index.js
vendored
|
@ -46,6 +46,7 @@ exports.buildBranchCommits = buildBranchCommits;
|
|||
exports.createOrUpdateBranch = createOrUpdateBranch;
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const uuid_1 = __nccwpck_require__(5840);
|
||||
const utils = __importStar(__nccwpck_require__(918));
|
||||
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 FETCH_DEPTH_MARGIN = 10;
|
||||
|
@ -136,9 +137,19 @@ function isEven(git, branch1, branch2) {
|
|||
// Return true if the specified number of commits on branch1 and branch2 have a diff
|
||||
function commitsHaveDiff(git, branch1, branch2, depth) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const diff1 = (yield git.exec(['diff', '--stat', `${branch1}..${branch1}~${depth}`])).stdout.trim();
|
||||
const diff2 = (yield git.exec(['diff', '--stat', `${branch2}..${branch2}~${depth}`])).stdout.trim();
|
||||
return diff1 !== diff2;
|
||||
// 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
|
||||
// very rare, anyway.
|
||||
try {
|
||||
const diff1 = (yield git.exec(['diff', '--stat', `${branch1}..${branch1}~${depth}`])).stdout.trim();
|
||||
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.debug(utils.getErrorMessage(error));
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
function splitLines(multilineString) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import * as core from '@actions/core'
|
||||
import {GitCommandManager, Commit} from './git-command-manager'
|
||||
import {v4 as uuidv4} from 'uuid'
|
||||
import * as utils from './utils'
|
||||
|
||||
const CHERRYPICK_EMPTY =
|
||||
'The previous cherry-pick is now empty, possibly due to conflict resolution.'
|
||||
|
@ -131,13 +132,22 @@ async function commitsHaveDiff(
|
|||
branch2: string,
|
||||
depth: number
|
||||
): Promise<boolean> {
|
||||
const diff1 = (
|
||||
await git.exec(['diff', '--stat', `${branch1}..${branch1}~${depth}`])
|
||||
).stdout.trim()
|
||||
const diff2 = (
|
||||
await git.exec(['diff', '--stat', `${branch2}..${branch2}~${depth}`])
|
||||
).stdout.trim()
|
||||
return diff1 !== diff2
|
||||
// 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
|
||||
// very rare, anyway.
|
||||
try {
|
||||
const diff1 = (
|
||||
await git.exec(['diff', '--stat', `${branch1}..${branch1}~${depth}`])
|
||||
).stdout.trim()
|
||||
const diff2 = (
|
||||
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.debug(utils.getErrorMessage(error))
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
function splitLines(multilineString: string): string[] {
|
||||
|
|
Loading…
Reference in a new issue