Skip to content

A small library (like https://github.com/sbt/sbt-buildinfo) to obtain git informations (hash, commit time, author,...) but at compile time.

License

Notifications You must be signed in to change notification settings

dgouyette/git-info

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

git-info

Build Status

A small library (like https://github.com/sbt/sbt-buildinfo) to obtain git informations (hash, commit time, author,...) but at compile time.

This help to illustrate how macros work

Install as dependency

build.sbt :

works for scala 2.12 and 2.13

resolvers += Resolver.bintrayRepo("dgouyette", "maven")

libraryDependencies ++= Seq(
  "org.cestpasdur" %% "git-info" % "0.2.2",
)

Usage (in a playframework webapp)

class VersionController extends Controller {


  def index = Action {
    Ok(
      Json.obj(
        "lastCommit" -> Json.obj(
          "branch" -> GitInfo.currentBranch(),
          "message" -> GitInfo.lastRevCommitMessage(),
          "author" -> GitInfo.lastRevCommitAuthor(),
          "hash" -> GitInfo.lastRevCommitName(),
          "date" -> GitInfo.lastRevCommitTime()
        ))
    )
  }

}

That will display :

{
  "lastCommit": {
    "branch": "master",
    "message": "add git-info to display last commit info",
    "author": "Damien GOUYETTE <[email protected]> 1469442718 +0200",
    "hash": "6024dcc98bd563b0ab78c7a663c52ebadbbaf456",
    "date": "Mon Jul 25 12:32:15 CEST 2016"
  }
}

About

A small library (like https://github.com/sbt/sbt-buildinfo) to obtain git informations (hash, commit time, author,...) but at compile time.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published