Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filterMode=none, to ignore project.git #195

Merged
merged 1 commit into from
Dec 23, 2021
Merged
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
3 changes: 2 additions & 1 deletion plugin/src/main/scala/org/scalafmt/sbt/ScalafmtPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ object ScalafmtPlugin extends AutoPlugin {
private object FilterMode {
val diffDirty = "diff-dirty"
val diffRefPrefix = "diff-ref="
val none = "none"
}

private def getLogMessage(message: String): String = "scalafmt: " + message
Expand Down Expand Up @@ -198,7 +199,7 @@ object ScalafmtPlugin extends AutoPlugin {
else if (filterMode.startsWith(FilterMode.diffRefPrefix)) {
val branch = filterMode.substring(FilterMode.diffRefPrefix.length)
getFromFiles(gitOps.diff(branch), s"diff $branch")
} else if (scalafmtSession.isGitOnly)
} else if (filterMode != FilterMode.none && scalafmtSession.isGitOnly)
getFromFiles(gitOps.lsTree(), "ls-files")
else {
log.debug("considering all files (no git)")
Expand Down
1 change: 1 addition & 0 deletions plugin/src/sbt-test/scalafmt-sbt/sbt/.scalafmt18.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
version = 2.0.0
style = IntelliJ
maxColumn = 42
project.git = true
7 changes: 6 additions & 1 deletion plugin/src/sbt-test/scalafmt-sbt/sbt/test
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,15 @@ $ exec git -C p18 add "src/main/scala/TestBad2.scala"
# now commit it, no longer modified
$ exec git -C p18 commit -m 'added TestBad2.scala'
> p18/scalafmtCheck
# don't filter but fail after all errors
# filter on git but fail after all errors
> set p18/scalafmtFilter := ("")
-> p18/scalafmtCheck
$ copy-file changes/invalid.scala p18/src/main/scala/TestInvalid1.scala
$ copy-file changes/invalid.scala p18/src/main/scala/TestInvalid2.scala
# formats TestBad2 but not the TestInvalid*
> p18/scalafmt
# don't filter at all
> set p18/scalafmtFilter := ("none")
-> p18/scalafmt
# fail after all errors
> set p18/scalafmtLogOnEachError := true
Expand Down