Repository: scala-steward-org/scala-steward (scala)

Issue:
Broken Scala version upgrade when using sbt-github-actions
The first commit to update the Scala version only modifies `ci.yml`, but not `build.sbt`. The second commit to regenerate `ci.yml` then undoes the change.

See NthPortal/extra-predef#73 for example.

Pull request:
Closes: #2154

Patch:
diff --git a/modules/core/src/main/scala/org/scalasteward/core/git/FileGitAlg.scala b/modules/core/src/main/scala/org/scalasteward/core/git/FileGitAlg.scala
index 32fc59dd18..98e57cb5a3 100644
--- a/modules/core/src/main/scala/org/scalasteward/core/git/FileGitAlg.scala
+++ b/modules/core/src/main/scala/org/scalasteward/core/git/FileGitAlg.scala
@@ -37,6 +37,9 @@ final class FileGitAlg[F[_]](config: GitCfg)(implicit
   override def branchExists(repo: File, branch: Branch): F[Boolean] =
     git("branch", "--list", "--no-color", "--all", branch.name)(repo).map(_.mkString.trim.nonEmpty)
 
+  override def branchesDiffer(repo: File, b1: Branch, b2: Branch): F[Boolean] =
+    git("diff", "--name-only", b1.name, b2.name)(repo).map(_.nonEmpty)
+
   override def checkoutBranch(repo: File, branch: Branch): F[Unit] =
     git("checkout", branch.name)(repo).void
 
diff --git a/modules/core/src/main/scala/org/scalasteward/core/git/GenGitAlg.scala b/modules/core/src/main/scala/org/scalasteward/core/git/GenGitAlg.scala
index 9aa0744f45..3a61c1e648 100644
--- a/modules/core/src/main/scala/org/scalasteward/core/git/GenGitAlg.scala
+++ b/modules/core/src/main/scala/org/scalasteward/core/git/GenGitAlg.scala
@@ -28,6 +28,8 @@ trait GenGitAlg[F[_], Repo] {
 
   def branchExists(repo: Repo, branch: Branch): F[Boolean]
 
+  def branchesDiffer(repo: Repo, b1: Branch, b2: Branch): F[Boolean]
+
   def checkoutBranch(repo: Repo, branch: Branch): F[Unit]
 
   def clone(repo: Repo, url: Uri): F[Unit]
@@ -88,6 +90,9 @@ trait GenGitAlg[F[_], Repo] {
       override def branchExists(repo: A, branch: Branch): F[Boolean] =
         f(repo).flatMap(self.branchExists(_, branch))
 
+      override def branchesDiffer(repo: A, b1: Branch, b2: Branch): F[Boolean] =
+        f(repo).flatMap(self.branchesDiffer(_, b1, b2))
+
       override def checkoutBranch(repo: A, branch: Branch): F[Unit] =
         f(repo).flatMap(self.checkoutBranch(_, branch))
 
diff --git a/modules/core/src/main/scala/org/scalasteward/core/nurture/NurtureAlg.scala b/modules/core/src/main/scala/org/scalasteward/core/nurture/NurtureAlg.scala
index 9974843f9e..ed9733dd75 100644
--- a/modules/core/src/main/scala/org/scalasteward/core/nurture/NurtureAlg.scala
+++ b/modules/core/src/main/scala/org/scalasteward/core/nurture/NurtureAlg.scala
@@ -156,7 +156,11 @@ final class NurtureAlg[F[_]](config: VCSCfg)(implicit
       editAlg.applyUpdate(data.repoData, data.update, createBranch).flatMap { edits =>
         val editCommits = edits.flatMap(_.maybeCommit)
         if (editCommits.isEmpty) logger.warn("No commits created").as(Ignored)
-        else pushCommits(data, editCommits) >> createPullRequest(data, edits)
+        else
+          gitAlg.branchesDiffer(data.repo, data.baseBranch, data.updateBranch).flatMap {
+            case true  => pushCommits(data, editCommits) >> createPullRequest(data, edits)
+            case false => logger.warn("No diff between base and update branch").as(Ignored)
+          }
       }
     }
 


Test patch:
diff --git a/modules/core/src/test/scala/org/scalasteward/core/git/FileGitAlgTest.scala b/modules/core/src/test/scala/org/scalasteward/core/git/FileGitAlgTest.scala
index c054670b8e..a23d1623a2 100644
--- a/modules/core/src/test/scala/org/scalasteward/core/git/FileGitAlgTest.scala
+++ b/modules/core/src/test/scala/org/scalasteward/core/git/FileGitAlgTest.scala
@@ -38,6 +38,25 @@ class FileGitAlgTest extends CatsEffectSuite {
     } yield ()
   }
 
+  test("branchesDiffer") {
+    val repo = rootDir / "branchesDiffer"
+    val (foo, bar) = (Branch("foo"), Branch("bar"))
+    for {
+      _ <- ioAuxGitAlg.createRepo(repo)
+      _ <- ioGitAlg.createBranch(repo, foo)
+      _ <- ioGitAlg.createBranch(repo, bar)
+      b1 <- ioGitAlg.branchesDiffer(repo, bar, foo)
+      _ <- ioFileAlg.writeFile(repo / "test.txt", "hello")
+      _ <- ioAuxGitAlg.git("add", "test.txt")(repo)
+      _ <- ioGitAlg.commitAll(repo, CommitMsg("Add test.txt"))
+      b2 <- ioGitAlg.branchesDiffer(repo, foo, bar)
+      _ <- ioAuxGitAlg.git("rm", "test.txt")(repo)
+      _ <- ioGitAlg.commitAll(repo, CommitMsg("Remove test.txt"))
+      b3 <- ioGitAlg.branchesDiffer(repo, foo, bar)
+      _ = assertEquals((b1, b2, b3), (false, true, false))
+    } yield ()
+  }
+
   test("cloneExists") {
     val repo = rootDir / "cloneExists"
     for {