Functional and typesafe library to use git commands in Scala, based on cats, cats-effect and fs2.
libraryDependencies += "com.github.geirolz" %% "git4s" % "0.0.2"
general
- git help
- git init
installation
- git version
- install git [brew | choco | apt-get]
- uninstall git [brew | choco | apt-get]
- reinstall git [brew | choco | apt-get]
config
- git config --get [local | global]
- git config --unset [local | global]
- git config [local | global]
tag
- git tag
repository
- git status
- git clone
- git add
- git commit
- git push
- git pull
- git fetch
- git checkout
- git branch [create]
- git reset [to commit | to HEAD~n]
- git clean
- git diff [WIP]
You can create a Git4s instance using the apply
method.
Logging is done using the CmdLogger
type class implicitly passed to each method. You can provide your own
implementation of CmdLogger
to log the command output as you like, or use the default one provided by the library.
By default, the library uses the Noop
logger which doesn't log anything since usually these logs are useful just
for debugging purpose.
Example:
import cats.effect.IO
import git4s.Git4s
import git4s.data.GitVersion
import git4s.logging.*
given logger: CmdLogger[IO]
= CmdLogger.console[IO](LogFilter.all)
val result: IO[GitVersion] = Git4s[IO].version
// result: IO[GitVersion] = FlatMap(
// ioe = Uncancelable(
// body = cats.effect.IO$$$Lambda/0x0000000303605958@b5734aa,
// event = cats.effect.tracing.TracingEvent$StackTrace
// ),
// f = fs2.Stream$CompileOps$$Lambda/0x0000000303605d20@2d0e0e97,
// event = cats.effect.tracing.TracingEvent$StackTrace
// )
We welcome contributions from the open-source community to make Git4s even better. If you have any bug reports, feature requests, or suggestions, please submit them via GitHub issues. Pull requests are also welcome.
Before contributing, please read our Contribution Guidelines to understand the development process and coding conventions.
Please remember te following:
- Run
sbt scalafmtAll
before submitting a PR. - Run
sbt gen-doc
to update the documentation.
Git4s is released under the Apache License 2.0. Feel free to use it in your open-source or commercial projects.