fix(pr): resolve unexpected behavior in create-pull-request #4197
This commit is contained in:
parent
0edc001d28
commit
77b62e2232
6
dist/index.js
vendored
6
dist/index.js
vendored
@ -285,10 +285,12 @@ function createOrUpdateBranch(git, commitMessage, base, branch, branchRemoteName
|
|||||||
//
|
//
|
||||||
// For changes on base this reset is equivalent to a rebase of the pull request branch.
|
// For changes on base this reset is equivalent to a rebase of the pull request branch.
|
||||||
const branchCommitsAhead = yield commitsAhead(git, base, branch);
|
const branchCommitsAhead = yield commitsAhead(git, base, branch);
|
||||||
if ((yield git.hasDiff([`${branch}..${tempBranch}`])) ||
|
const shouldReset = (yield git.hasDiff([`${branch}..${tempBranch}`])) ||
|
||||||
branchCommitsAhead != tempBranchCommitsAhead ||
|
branchCommitsAhead != tempBranchCommitsAhead ||
|
||||||
!(tempBranchCommitsAhead > 0) || // !isAhead
|
!(tempBranchCommitsAhead > 0) || // !isAhead
|
||||||
(yield commitsHaveDiff(git, branch, tempBranch, tempBranchCommitsAhead))) {
|
(tempBranchCommitsAhead > 0 &&
|
||||||
|
(yield commitsHaveDiff(git, branch, tempBranch, tempBranchCommitsAhead)));
|
||||||
|
if (shouldReset) {
|
||||||
core.info(`Resetting '${branch}'`);
|
core.info(`Resetting '${branch}'`);
|
||||||
// Alternatively, git switch -C branch tempBranch
|
// Alternatively, git switch -C branch tempBranch
|
||||||
yield git.checkout(branch, tempBranch);
|
yield git.checkout(branch, tempBranch);
|
||||||
|
|||||||
@ -311,12 +311,19 @@ export async function createOrUpdateBranch(
|
|||||||
//
|
//
|
||||||
// For changes on base this reset is equivalent to a rebase of the pull request branch.
|
// For changes on base this reset is equivalent to a rebase of the pull request branch.
|
||||||
const branchCommitsAhead = await commitsAhead(git, base, branch)
|
const branchCommitsAhead = await commitsAhead(git, base, branch)
|
||||||
if (
|
const shouldReset =
|
||||||
(await git.hasDiff([`${branch}..${tempBranch}`])) ||
|
(await git.hasDiff([`${branch}..${tempBranch}`])) ||
|
||||||
branchCommitsAhead != tempBranchCommitsAhead ||
|
branchCommitsAhead != tempBranchCommitsAhead ||
|
||||||
!(tempBranchCommitsAhead > 0) || // !isAhead
|
!(tempBranchCommitsAhead > 0) || // !isAhead
|
||||||
(await commitsHaveDiff(git, branch, tempBranch, tempBranchCommitsAhead))
|
(tempBranchCommitsAhead > 0 &&
|
||||||
) {
|
(await commitsHaveDiff(
|
||||||
|
git,
|
||||||
|
branch,
|
||||||
|
tempBranch,
|
||||||
|
tempBranchCommitsAhead
|
||||||
|
)))
|
||||||
|
|
||||||
|
if (shouldReset) {
|
||||||
core.info(`Resetting '${branch}'`)
|
core.info(`Resetting '${branch}'`)
|
||||||
// Alternatively, git switch -C branch tempBranch
|
// Alternatively, git switch -C branch tempBranch
|
||||||
await git.checkout(branch, tempBranch)
|
await git.checkout(branch, tempBranch)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user