This is a nano-library for Scala
"com.github.arturopala" %% "gitignore" % "@VERSION@"
//> using "com.github.arturopala::gitignore:@VERSION@"
Cross-compiles to Scala versions @SUPPORTED_SCALA_VERSIONS@,
and ScalaJS version @SCALA_JS_VERSION@
, and ScalaNative version @SCALA_NATIVE_VERSION@
.
The .gitignore has became de-facto standard filter format for project's files and folders.
This nano-library provides Scala implementation of the .gitignore
compliant filter, ready to embed in different tools without having to run git
command.
https://arturopala.github.io/gitignore/latest/api/com/github/arturopala/gitignore/GitIgnore.html
https://scastie.scala-lang.org/arturopala/D8GzZ1LwTIuNr4wBOzcMUg/11
Option 1 - parse existing .gitignore
file content
import com.github.arturopala.gitignore._
val gitignore = GitIgnore
.parse("""
|#*.json
|*.txt
|*.pdf
|!ok.*
|bar.json
|target
|""".stripMargin)
gitignore.isIgnored("foo.txt")
gitignore.isIgnored("bar.txt")
gitignore.isIgnored("ok.txt")
gitignore.isIgnored("foo.pdf")
gitignore.isIgnored("bar.pdf")
gitignore.isIgnored("ok.pdf")
gitignore.isIgnored("foo.json")
gitignore.isIgnored("bar.json")
gitignore.isIgnored("ok.json")
gitignore.isIgnored("target/")
gitignore.isIgnored("target.json")
gitignore.isAllowed("foo.txt")
gitignore.isAllowed("bar.txt")
gitignore.isAllowed("ok.txt")
gitignore.isAllowed("foo.pdf")
gitignore.isAllowed("bar.pdf")
gitignore.isAllowed("ok.pdf")
gitignore.isAllowed("foo.json")
gitignore.isAllowed("bar.json")
gitignore.isAllowed("ok.json")
gitignore.isAllowed("target/")
gitignore.isAllowed("target.json")
Option 2 - pass list of rules to the constructor
import com.github.arturopala.gitignore._
val gitignore = GitIgnore(Seq(
"*.txt",
"*.pdf",
"!ok.*",
"bar.json ",
"target"))
gitignore.isIgnored("foo.txt")
gitignore.isIgnored("bar.txt")
gitignore.isIgnored("ok.txt")
gitignore.isIgnored("foo.pdf")
gitignore.isIgnored("bar.pdf")
gitignore.isIgnored("ok.pdf")
gitignore.isIgnored("foo.json")
gitignore.isIgnored("bar.json")
gitignore.isIgnored("ok.json")
gitignore.isIgnored("target/")
gitignore.isIgnored("target.json")
gitignore.isAllowed("foo.txt")
gitignore.isAllowed("bar.txt")
gitignore.isAllowed("ok.txt")
gitignore.isAllowed("foo.pdf")
gitignore.isAllowed("bar.pdf")
gitignore.isAllowed("ok.pdf")
gitignore.isAllowed("foo.json")
gitignore.isAllowed("bar.json")
gitignore.isAllowed("ok.json")
gitignore.isAllowed("target/")
gitignore.isAllowed("target.json")
Compile
sbt compile
Compile for all Scala versions
sbt +compile
Test
sbt rootJVM/test
sbt rootJS/test
sbt rootNative/test
Test with all Scala versions
sbt +test
sbt +rootJVM/test
Generate README and docs
sbt docs/mdoc
Apply scalafixes
sbt rootJMV/scalafixAll
- Build: runs on every push or pull request
- Release: manual release of artefacts to Sonatype and Maven Central, for a setup follow https://github.com/olafurpg/sbt-ci-release/blob/main/readme.md
- Site: manual update of README and push of API docs to Github Pages