geirolz / git4s   0.0.2

Apache License 2.0 GitHub

Functional and typesafe library to use git commands in Scala

Scala versions: 3.x

Git4s

Build Status Codacy Badge 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" % "0.0.2"

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 [WIP]

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 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
// )

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.