-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #141 from bjaglin/jgit
prevent failure on sbt init when JGit finds a .git with no commit
- Loading branch information
Showing
2 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/test/scala/scalafix/internal/sbt/JGitCompletionsSuite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package scalafix.internal.sbt | ||
|
||
import org.eclipse.jgit.api.{Git => JGit} | ||
import org.scalatest.funsuite.AnyFunSuite | ||
|
||
class JGitCompletionsSuite extends AnyFunSuite { | ||
|
||
test("directory with no .git") { | ||
val fs = new Fs() | ||
val jgit = new JGitCompletion(fs.workingDirectory) | ||
assert(jgit.last20Commits == Nil) | ||
} | ||
|
||
test("directory with empty .git") { | ||
val fs = new Fs() | ||
fs.mkdir(".git") | ||
val jgit = new JGitCompletion(fs.workingDirectory) | ||
assert(jgit.last20Commits == Nil) | ||
} | ||
|
||
test("directory with no commits") { | ||
val fs = new Fs() | ||
JGit.init().setDirectory(fs.workingDirectory.toFile).call() // git init | ||
val jgit = new JGitCompletion(fs.workingDirectory) | ||
assert(jgit.last20Commits == Nil) | ||
} | ||
|
||
} |