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
6 changes: 4 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
const branchCommitsAhead = yield commitsAhead(git, base, branch);
if ((yield git.hasDiff([`${branch}..${tempBranch}`])) ||
const shouldReset = (yield git.hasDiff([`${branch}..${tempBranch}`])) ||
branchCommitsAhead != tempBranchCommitsAhead ||
!(tempBranchCommitsAhead > 0) || // !isAhead
(yield commitsHaveDiff(git, branch, tempBranch, tempBranchCommitsAhead))) {
(tempBranchCommitsAhead > 0 &&
(yield commitsHaveDiff(git, branch, tempBranch, tempBranchCommitsAhead)));
if (shouldReset) {
core.info(`Resetting '${branch}'`);
// Alternatively, git switch -C branch tempBranch
yield git.checkout(branch, tempBranch);
Expand Down
13 changes: 10 additions & 3 deletions src/create-or-update-branch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,19 @@ export async function createOrUpdateBranch(
//
// For changes on base this reset is equivalent to a rebase of the pull request branch.
const branchCommitsAhead = await commitsAhead(git, base, branch)
if (
const shouldReset =
(await git.hasDiff([`${branch}..${tempBranch}`])) ||
branchCommitsAhead != tempBranchCommitsAhead ||
!(tempBranchCommitsAhead > 0) || // !isAhead
(await commitsHaveDiff(git, branch, tempBranch, tempBranchCommitsAhead))
) {
(tempBranchCommitsAhead > 0 &&
(await commitsHaveDiff(
git,
branch,
tempBranch,
tempBranchCommitsAhead
)))

if (shouldReset) {
core.info(`Resetting '${branch}'`)
// Alternatively, git switch -C branch tempBranch
await git.checkout(branch, tempBranch)
Expand Down