Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ exports.buildBranchCommits = buildBranchCommits;
exports.createOrUpdateBranch = createOrUpdateBranch;
const core = __importStar(__nccwpck_require__(7484));
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 NOTHING_TO_COMMIT = 'nothing to commit, working tree clean';
const FETCH_DEPTH_MARGIN = 10;
Expand Down Expand Up @@ -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.
// 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;
const result1 = yield git.exec(['diff', '--stat', `${branch1}..${branch1}~${depth}`], { allowAllExitCodes: true });
if (result1.exitCode !== 0) {
core.info('Failed optional check of commits diff; Skipping.');
core.debug(result1.stderr);
return false;
}
catch (error) {
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(utils.getErrorMessage(error));
core.debug(result2.stderr);
return false;
}
return result1.stdout.trim() !== result2.stdout.trim();
});
}
function splitLines(multilineString) {
Expand Down
29 changes: 18 additions & 11 deletions src/create-or-update-branch.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
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.'
Expand Down Expand Up @@ -135,19 +134,27 @@ async function commitsHaveDiff(
// 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) {
const result1 = await git.exec(
['diff', '--stat', `${branch1}..${branch1}~${depth}`],
{allowAllExitCodes: true}
)
if (result1.exitCode !== 0) {
core.info('Failed optional check of commits diff; Skipping.')
core.debug(result1.stderr)
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(utils.getErrorMessage(error))
core.debug(result2.stderr)
return false
}

return result1.stdout.trim() !== result2.stdout.trim()
}

function splitLines(multilineString: string): string[] {
Expand Down