diff --git a/internal/git/git.go b/internal/git/git.go index 136a828..d1db11b 100644 --- a/internal/git/git.go +++ b/internal/git/git.go @@ -233,7 +233,7 @@ func (r *Repository) hasChangesWithRemote(ctx context.Context, mainBranchRef, lo return false, nil } - remoteDiff, err := commitOnRemotePRBranch.PatchContext(ctx, currentRemotePRMergeBase) + remoteDiff, err := currentRemotePRMergeBase.PatchContext(ctx, commitOnRemotePRBranch) if err != nil { return false, err } @@ -248,7 +248,7 @@ func (r *Repository) hasChangesWithRemote(ctx context.Context, mainBranchRef, lo return false, err } - return remoteDiff.String() == localDiff.String(), nil + return remoteDiff.String() != localDiff.String(), nil } func (r *Repository) commitFromRef(refName plumbing.ReferenceName) (*object.Commit, error) { diff --git a/internal/git/git_test.go b/internal/git/git_test.go index 3d05538..bf300df 100644 --- a/internal/git/git_test.go +++ b/internal/git/git_test.go @@ -147,15 +147,17 @@ func TestRepository_HasChangesWithRemote(t *testing.T) { OnBranch(mainBranchRef), AsNewBranch(remotePRBranchRef), WithFile("VERSION", "v1.1.0"), + WithFile("CHANGELOG.md", "Foo"), ), WithCommit( - "chore: release v1.2.0", + "chore: release v1.1.0", OnBranch(mainBranchRef), AsNewBranch(localPRBranchRef), - WithFile("VERSION", "v1.2.0"), + WithFile("VERSION", "v1.1.0"), + WithFile("CHANGELOG.md", "FooBar"), ), ), - want: false, + want: true, wantErr: assert.NoError, }, }