geirolz / git4s   0.0.1

Apache License 2.0 GitHub

Functional and typesafe library to use git commands in Scala

Scala versions: 3.x

Git4s

Build Status codecov Codacy Badge Sonatype Nexus (Releases) Scala Steward badge Mergify Status GitHub license

Functional and typesafe library to use git commands in Scala, based on cats, cats-effect and fs2.

libraryDependencies += "com.github.geirolz" %% "git4s" % "<version>"

Features

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

Usage

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 com.geirolz.git4s.Git4s
 import com.geirolz.git4s.data.GitVersion
 import com.geirolz.git4s.log.*

 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/0x000000700352d088@4df981e1,
//     event = cats.effect.tracing.TracingEvent$StackTrace
//   ),
//   f = fs2.Stream$CompileOps$$Lambda/0x0000007003544a78@56e4502c,
//   event = cats.effect.tracing.TracingEvent$StackTrace
// )

Contributing

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.

License

Git4s is released under the Apache License 2.0. Feel free to use it in your open-source or commercial projects.