Giter Site home page Giter Site logo

sbt-git's Introduction

sbt-git

Join the chat at https://gitter.im/sbt/sbt-git

The sbt-git plugin offers git command line features directly inside sbt as well as allowing other plugins to make use of git.

Maintenance status

This plugin is community maintained. See #182 if you'd like to help.

Installation

As of 1.0.0 this plugin requires at least Java 8. The latest version supporting Java 7 was 0.9.3, while the latest version supporting Java 6 was 0.8.5.

Latest:

Add the following to your project/plugins.sbt or ~/.sbt/1.0/plugins/plugins.sbt file:

addSbtPlugin("com.github.sbt" % "sbt-git" % "<version>")

Prior to sbt 0.13.5:

Add the following to your project/plugins.sbt or ~/.sbt/0.13/plugins/plugins.sbt file:

addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.7.1")

additionally, use one of the older README.md files: (https://github.com/sbt/sbt-git/blob/v0.7.1/README.md)

JGit

JGit is a Java interface to git that allows some git operations to be performed in the JVM without invoking an external git executable. By default, this plugin uses JGit for read-only operations such as inspecting HEAD; for write operations, it assumes a git executable is present and on the PATH and it uses that.

In certain circumstances you may want to force the use of JGit or an executable for both read-only and read-write operations; for example, if no git executable is present (e.g. you use windows and you haven't installed git or it's not on your PATH) you need to disable the console interface, or if you rely on a git feature that JGit does not support (e.g. worktrees) you need to disable the JGit interface.

The following settings will force the use of only JGit or a git executable, respectively:

  • useJGit
  • useReadableConsoleGit

These settings can be included in your project's git.sbt or in ~/.sbt/1.0/git.sbt -- for example, if no git executable is installed, either file can have the following contents:

useJGit

Or you can set the appropriate setting in the sbt prompt:

> set useReadableConsoleGit
[info] Reapplying settings...
[info] Set current project to scala-arm (in build file:...)
> session save
[info] Reapplying settings...
[info] Set current project to scala-arm (in build file:...)

Versioning with Git

You can begin to use git to control your project versions.

enablePlugins(GitVersioning)

The git plugin will now autogenerate your version using the following rules, in order:

  1. Looks at version-property setting (default to project.version), and checks the sys.props to see if this has a value. If so, use it.
  2. Otherwise, looks at the project tags. The first to match the gitTagToVersionNumberSetting is used to assign the version. The default is to look for tags that begin with v and a number, and use the number as the version. If there are multiple version tags, it will pick the highest.
  3. If no tags are found either, look at the head commit. We attach this to the git.baseVersion setting: "<base-version>.<git commit sha>"
  4. If no head commit is present either (which means this is a brand-new repository with no commits yet), we append the current timestamp to the base version: "<base-version>.<timestamp>".

The git.baseVersion setting represents the in-development (upcoming) version you're working on.

You can alter the tag-detection algorithm using the git.gitTagToVersionNumber setting. For example, if we wanted to alter the default version tag detection so it does not require a "v" at the start of tags, we could add the following setting:

git.gitTagToVersionNumber := { tag: String =>
  if(tag matches "[0-9]+\\..*") Some(tag)
  else None
}

You can turn on version detection using git describe command by adding:

git.useGitDescribe := true

This way the version is derived by passing the result of git describe to the gitTagToVersionNumber function. The describe version is built from the last tag + number of commits since tag + short hash. We recommend adopting the git describe approach.

You can enhance the git describe approach with glob pattern matching, to match only relevant tags (as per git describe --match functionality). This may be useful if, for example, your repository contains multiple types of tag.

git.gitDescribePatterns := Seq("module-name-*")

Additionally, you can also customize the version number generated by overriding one of the following keys:

  • git.formattedShaVersion - Should look up git.gitHeadCommit key and generate a version based on it.
  • git.formattedDateVersion - The version we'll use if git is unavailable on this repository, for some reason.

As an example, you can alter the default sha-based versions using the following code

git.formattedShaVersion := git.gitHeadCommit.value map { sha => s"v$sha" }

Prompts

You can use the git plugin to add the project name + the current branch to your prompt. Simply add this setting to every project:

enablePlugins(GitBranchPrompt)

Usage

In an sbt prompt, simply enter any git command. e.g.

> git status
# On branch main
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	modified:   build.sbt
#	modified:   project/plugins/project/Build.scala
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#	src/site/
no changes added to commit (use "git add" and/or "git commit -a")

Known issues

When running sbt, you will see the following warnings in console:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

To get rid of them, you can force the SLF4J no-op binder by adding libraryDependencies += "org.slf4j" % "slf4j-nop" % "1.7.21" to ~/.sbt/0.13/plugins/plugins.sbt

Running the tests

Tests for this plugin are written using sbt-scripted. Test can be executed with

sbt scripted

Licensing

This software is licensed under the BSD license.

sbt-git's People

Contributors

bchazalet avatar blaisorblade avatar dwijnand avatar eed3si9n avatar fernandomora avatar francisdb avatar gitter-badger avatar hanxue avatar harrah avatar hseeberger avatar jaceklaskowski avatar jalaziz avatar jpassaro avatar jsuereth avatar jsyeo avatar leonardehrenfried avatar lustefaniak avatar mpollmeier avatar msv avatar oliverlockwood avatar philippe-pascal-ck avatar pvlugter avatar raboof avatar scala-steward avatar scalawilliam avatar sethtisue avatar softprops avatar szeiger avatar tototoshi avatar xuwei-k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sbt-git's Issues

Trying to set version from git tag

I am trying to set the project version from git using sbt-git and my settings are as follows...

lazy val special = project.in(file("."))
.settings(commonSettings: _*)
.enablePlugins(GitVersioning, GitBranchPrompt)
.settings(
git.gitTagToVersionNumber := { tag: String =>
Some("special_tag")
}
)

The output of 'git tag' is 'v0.9.9' so you would think that my version would be set to "special_tag" but it's not, it gets set to the last SHA1 postpended with "SNAPSHOT". It's as if sbt-git is not paying attention to the existing tags at all. I can verify this by running 'sbt -jvm-debug' and setting a breakpoint at line 118 in SbtGit.scala:

118: gitCurrentTags := gitReader.value.withGit(_.currentTags),

If I put a watch on gitReader.value and step into this function, I can clearly see a "not implemented" exception being thrown. Is this a known issue? The documentation on the readme seems to imply that this is supposed to work. Any insight?

Cross build for 2.9.1-1

Hey Josh -

Any plans to cross-build against 2.9.1-1. We're on that version of Scala due to some Java interop issues with 2.9.1 I built the Git plugin internally and we can use that, but I didn't know if it might be useful to others to have an official binary. Thanks!

Git versioning is broken

Setting git.baseVersion seems just ignored on SBT 0.12.0/0.13.0:

$ cat version.sbt
git.baseVersion := "0.1"

versionWithGit
$ sbt
[info] Loading global plugins from /Users/pgiarrusso/.sbt/0.13/plugins
[info] Loading project definition from /Users/pgiarrusso/Movies/subtitle-fixer/project
[info] Set current project to subtitle-fixer (in build file:/Users/pgiarrusso/Movies/subtitle-fixer/)
> version
[info] 1.0-0cbac39bc67f401c58ccd4bc85617e019793c184

What seems to take effect is the setting of the version to 1.0 in sbt-git's code:

baseVersion in ThisBuild := "1.0",

version

The versionning with git does not work if sbt base directory does not contain the .git directory.

I have a repo with the following folders:

my-project
|-- code
       |-- build.sbt
       |-- src
|-- .git

See the results of the following commands:

[bloomberg-update-service] $ show version
[info] 1.0.3-20140812T140719

[bloomberg-update-service] $ show gitCurrentBranch
[info]

[bloomberg-update-service] $ show gitHeadCommit
[info] None

Note that git console works even if I force the use of JGit, i.e. JGit can find that the .git folder is one folder up.

[bloomberg-update-service] $  set useJGit
[bloomberg-update-service] $ git status
[info] # On branch master
...

Doesn't work on scala/scala

Gives me this error:

[info] Loading project definition from /home/dcs/github/scala/project/plugins/project
[info] Loading project definition from /home/dcs/github/scala/project/plugins
[info] Compiling 7 Scala sources to /home/dcs/github/scala/project/target/scala_2.9.1/classes...
[error] /home/dcs/github/scala/project/Release.scala:110: value split is not a member of Unit
[error]      git("--no-pager", "log", "--pretty=oneline", mergeBase +"..HEAD")(baseDirectory, s.log) split "[\r\n]+" size
[error]                                                                                              ^
[error] /home/dcs/github/scala/project/Release.scala:112: value substring is not a member of Unit
[error]     "rdev-%d-%s-g%s" format (commits, date, sha.substring(0,7))
[error]                                                 ^
[error] two errors found

Please add tab-completion

Git has nice tab completion support (e.g. on git checkout [branchname], half-entering the branch name).

This won't be easy, tab completion seems to be configured by bash scripts (/usr/lib/git-core/git-sh-prompt in ubuntu).

How do I access the head commit?

This is a usage issue, and ideally will add a section to the README. How do I access the HEAD commit hash? I tried git.gitHeadCommit but that prints out sbt.Scoped$$anon$1@1db4b415. I'm a Scala n00b which is likely half of the problem, but a concrete example would help.

Could not find or load main class org.eclipse.jgit.pgm.Main

Hi there,

Here is one I have:

optimus(sbt2)> git status
Error: Could not find or load main class org.eclipse.jgit.pgm.Main
[info]
java.lang.RuntimeException: Nonzero exit code (1) running JGit.
    at scala.sys.package$.error(package.scala:27)
    at scala.Predef$.error(Predef.scala:142)
    at com.typesafe.sbt.git.JGitRunner$.forkJGitMain(JGitRunner.scala:69)
    at com.typesafe.sbt.git.JGitRunner$.apply(JGitRunner.scala:16)
    at com.typesafe.sbt.SbtGit$GitCommand$$anonfun$1.apply(SbtGit.scala:49)
    at com.typesafe.sbt.SbtGit$GitCommand$$anonfun$1.apply(SbtGit.scala:45)
    at com.typesafe.sbt.SbtGit$GitCommand$$anonfun$3.apply(SbtGit.scala:56)
    at com.typesafe.sbt.SbtGit$GitCommand$$anonfun$3.apply(SbtGit.scala:54)
    at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:59)
    at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:59)
    at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:61)
    at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:61)
    at sbt.Command$.process(Command.scala:93)
    at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:98)
    at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:98)
    at sbt.State$$anon$1.process(State.scala:184)
    at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:98)
    at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:98)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
    at sbt.MainLoop$.next(MainLoop.scala:98)
    at sbt.MainLoop$.run(MainLoop.scala:91)
    at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:70)
    at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:65)
    at sbt.Using.apply(Using.scala:24)
    at sbt.MainLoop$.runWithNewLog(MainLoop.scala:65)
    at sbt.MainLoop$.runAndClearLast(MainLoop.scala:48)
    at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:32)
    at sbt.MainLoop$.runLogged(MainLoop.scala:24)
    at sbt.StandardMain$.runManaged(Main.scala:53)
    at sbt.xMain.run(Main.scala:28)
    at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
    at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
    at xsbt.boot.Launch$.run(Launch.scala:109)
    at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
    at xsbt.boot.Launch$.launch(Launch.scala:117)
    at xsbt.boot.Launch$.apply(Launch.scala:18)
    at xsbt.boot.Boot$.runImpl(Boot.scala:41)
    at xsbt.boot.Boot$.main(Boot.scala:17)
    at xsbt.boot.Boot.main(Boot.scala)
[error] Nonzero exit code (1) running JGit.
[error] Use 'last' for the full log.
optimus(sbt2)>

git.sbt at the root of the project that contains:

useJGit

plugins.sbt that contains:

addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.8.5")

build.sbt that contains:

enablePlugins(GitBranchPrompt)

Cheers

Inconsistent versionning after intermediary commit

With a git base version at 0.1in a new repository with one commit
I expect the version to be 0.1-xxxxxxxxxx where xxxxxxxxxx is the sha1 of the commit

If I tag the commit v1.0.0,
I expect the version to be 1.0.0

If I add a file without committing,
I expect the version to be 1.0.0-SNAPSHOT

If I commit the newly added file (and get the new sha1 yyyyyyyy)
I expect the version to be 1.0.0-yyyyyyyy or 1.0.0-yyyyyyy-SNAPSHOT

This fails and reverts back to 0.1-yyyyyyyy

Following is an sbt-test test case for the issue , it fails on line 25 with a version which has reverted to 0.1-yyyyyyyy instead of 1.0.0-yyyyyyyy or 1.0.0-yyyyyyyy-SNAPSHOT or maybe 1.0.0-SNAPSHOT

git init
git config user.email "[email protected]"
git config user.name "Tester"
git add README.md
git commit -m "test"
$ copy-file changes/build.sbt build.sbt
reload
inspect version
checkVersionStartsWith 0.1
git add build.sbt
git commit -m"v1.0.0"
git tag v1.0.0
reload
inspect version
checkVersion 1.0.0
$ copy-file changes/change1.txt change1.txt
git add change1.txt
reload
inspect version
checkVersionStartsWith 1.0.0
checkSnapshotVersion
git commit -m"v1.0.1"
reload
inspect version
checkVersionStartsWith 1.0.0

doesn't work with global install

when I put the plugin in my ~/.sbt/plugins/plugins.sbt file and I put useJGit in ~/.sbt/user.sbt
I get the following error:

[error] AttributeKey ID collisions detected for: 'git-runner' (sbt.Task[com.jsuereth.git.GitRunner], sbt.Task[com.jsuereth.git.GitRunner], sbt.Task[com.jsuereth.git.GitRunner])

It is being used in a project that has many references to other projects on the filesystem, I have no idea what that error means or how I should start resolving it.

Unresolved jgit dependency

Following the directions on the README and launching sbt (0.11.1), I get the following error:

[error] {file:/Users/peter/.sbt/plugins/}default-577483/*:update: sbt.ResolveException: unresolved dependency: org.eclipse.jgit#org.eclipse.jgit.pgm;1.1.0.201109151100-r: not found

Wrong version when using git describe?

When I have git.useGitDescribe set to true I noticed the following:

  1. I tag HEAD to 'v0.8.0' and 'sbt version' returns '0.8.0'
  2. I commit something and 'sbt version' returns something like 'v0.8.0-1-gbeea47d'

Shouldn't this be '0.8.0-1-gbeea47d'?

Null branch name

This is also happening to my colleagues. I always get null as branch name.

I have added showCurrentGitBranch in the build.sbt file and when I execute sbt I get:

myproject(null)> %

What could it be the cause?

single git command executed once per subproject

in a project with multiple (aggregated) subprojects, every git command gets executed once per subproject, but in the same directory. the output lines of those multiple excecutions of the same command get interleaved. i'd expect the command to be run just once in the parent project.

plugin incorrectly injects its dependencies into current project (should be in metaproject only...)

error com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK plugin.properties
[error] File 1: C:\Users\pfnguyen.ivy2\cache\org.eclipse.jgit\org.eclipse.jgit\jars\org.eclipse.jgit-2.2.0.201212191850-r.jar
[error] File 2: C:\Users\pfnguyen.ivy2\cache\org.eclipse.jgit\org.eclipse.jgit\jars\org.eclipse.jgit-2.2.0.201212191850-r.jar
[error] Total time: 17 s, completed May 2, 2014 7:00:42 AM
sbt> show dependency-classpath
[info] ...elided..., Attributed(C:\Users\pfnguyen.ivy2\cache\scala_2.9.2\sbt_0.12\com.typesafe.sbt\sbt-git\jars\sbt-git-0.6.2.jar), Attributed(C:\Users\pfnguyen.ivy2\cache\org.eclipse.jgit\org.eclipse.jgit.pgm\jars\org.eclipse.jgit.pgm-2.2.0.201212191850-r.jar), Attributed(C:\Users\pfnguyen.ivy2\cache\args4j\args4j\jars\args4j-2.0.12.jar), Attributed(C:\Users\pfnguyen.ivy2\cache\org.apache.commons\commons-compress\jars\commons-compress-1.3.jar), Attributed(C:\Users\pfnguyen.ivy2\cache\org.eclipse.jgit\org.eclipse.jgit\jars\org.eclipse.jgit-2.2.0.201212191850-r.jar), Attributed(C:\Users\pfnguyen.ivy2\cache\com.jcraft\jsch\jars\jsch-0.1.44-1.jar), Attributed(C:\Users\pfnguyen.ivy2\cache\org.eclipse.jgit\org.eclipse.jgit.iplog\jars\org.eclipse.jgit.iplog-2.2.0.201212191850-r.jar), Attributed(C:\Users\pfnguyen.ivy2\cache\org.eclipse.jgit\org.eclipse.jgit.ui\jars\org.eclipse.jgit.ui-2.2.0.201212191850-r.jar) ...
[success] Total time: 0 s, completed May 2, 2014 7:01:02 AM

JGit depends on SLF4J

Warnings are printed:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

Should we write a SLF4J backend for sbt?

Generates incorrect version after modifying code starting from a tag

This example is motivated by sbt/sbt-eclipse#262

Steps to re-create:

  1. Create a tag in git (in this case 4.0.0-RC1)

    From master:
    
    ~/t/sbteclipse (master=) sbt-0.13
    [info] Loading global plugins from /home/jim/.sbt/0.13/plugins
    [info] Loading project definition from /home/jim/typesafe/sbteclipse/project
    [info] Set current project to sbteclipse (in build file:/home/jim/typesafe/sbteclipse/)
    > git status
    [info] On branch master
    [info] Your branch is up-to-date with 'origin/master'.
    [info] nothing to commit, working directory clean
    > show version
    [info] sbteclipse-core/*:version
    [info]     4.0.0-RC1
    [info] sbteclipse-plugin/*:version
    [info]     4.0.0-RC1
    [info] sbteclipse/*:version
    [info]     4.0.0-RC1
    
  2. Now, make a simple whitespace change

    ~/t/sbteclipse (master :zap:=) sbt-0.13
    [info] Loading global plugins from /home/jim/.sbt/0.13/plugins
    [info] Loading project definition from /home/jim/typesafe/sbteclipse/project
    [info] Compiling 1 Scala source to /home/jim/typesafe/sbteclipse/project/target/scala-2.10/sbt-0.13/classes...
    [info] Set current project to sbteclipse (in build file:/home/jim/typesafe/sbteclipse/)
    > git status
    [info] On branch master
    [info] Your branch is up-to-date with 'origin/master'.
    [info] Changes not staged for commit:
    [info]   (use "git add <file>..." to update what will be committed)
    [info]   (use "git checkout -- <file>..." to discard changes in working directory)
    [info] 
    [info]     modified:   project/Build.scala
    [info] 
    [info] no changes added to commit (use "git add" and/or "git commit -a")
    > show version
    [info] sbteclipse-core/*:version
    [info]     4.0.0-RC1                       <<< This *should* now be something like 4.0.0-<SHA>-SNAPSHOT
    [info] sbteclipse-plugin/*:version
    [info]     4.0.0-RC1                       <<< This *should* now be something like 4.0.0-<SHA>-SNAPSHOT
    [info] sbteclipse/*:version
    [info]     4.0.0-RC1                       <<< This *should* now be something like 4.0.0-<SHA>-SNAPSHOT
    
  3. Now, check-in that change on another branch

    ~/t/sbteclipse (git-testing :zap:) sbt-0.13
    [info] Loading global plugins from /home/jim/.sbt/0.13/plugins
    [info] Loading project definition from /home/jim/typesafe/sbteclipse/project
    [info] Set current project to sbteclipse (in build file:/home/jim/typesafe/sbteclipse/)
    > git status
    [info] On branch git-testing
    [info] nothing to commit, working directory clean
    > show version
    [info] sbteclipse-core/*:version
    [info]     4.0.0-6e43f3b8c01c5fbe198d370169b597d0fef4490f
    [info] sbteclipse-plugin/*:version
    [info]     4.0.0-6e43f3b8c01c5fbe198d370169b597d0fef4490f
    [info] sbteclipse/*:version
    [info]     4.0.0-6e43f3b8c01c5fbe198d370169b597d0fef4490f
    
  4. Now make a simple change to any source without checking it in

    ~/t/sbteclipse (git-testing :zap:) sbt-0.13
    [info] Loading global plugins from /home/jim/.sbt/0.13/plugins
    [info] Loading project definition from /home/jim/typesafe/sbteclipse/project
    [info] Compiling 1 Scala source to /home/jim/typesafe/sbteclipse/project/target/scala-2.10/sbt-0.13/classes...
    [info] Set current project to sbteclipse (in build file:/home/jim/typesafe/sbteclipse/)
    > git status
    [info] On branch git-testing
    [info] Changes not staged for commit:
    [info]   (use "git add <file>..." to update what will be committed)
    [info]   (use "git checkout -- <file>..." to discard changes in working directory)
    [info] 
    [info]     modified:   project/Build.scala
    [info] 
    [info] no changes added to commit (use "git add" and/or "git commit -a")
    > show version
    [info] sbteclipse-core/*:version
    [info]     4.0.0-6e43f3b8c01c5fbe198d370169b597d0fef4490f-SNAPSHOT
    [info] sbteclipse-plugin/*:version
    [info]     4.0.0-6e43f3b8c01c5fbe198d370169b597d0fef4490f-SNAPSHOT
    [info] sbteclipse/*:version
    [info]     4.0.0-6e43f3b8c01c5fbe198d370169b597d0fef4490f-SNAPSHOT
    

Default version-property override should not be 'project.version'

The default version-property override should not be 'project.version', as many build systems provide that property out of the box and out of the control of the user.

If you do not specify your own override in your project sbt file you can end up in a nasty situation where sbt-git insists on version-property='project.version' overriding all other versioning strategies, and your build system insisting on providing project.version=48 etc.

I suggest version-property should be an Option. It's an override so by definition it's optional. If it is not specified, the override strategy should be ignored entirely.

@jakobgrunig
@charleskubicek

Git is not an acronym

The project title on github calls it GIT, suggesting that it's an acronym. Should probably just be "git" or "Git".

Can't commit no more :(

> git commit -m "gulp html test"
[error] Expected whitespace character
[error] Expected non-double-quote-space character
[error] git commit -m "gulp html test"
[error]

duplicated output

It's duplicated output from git:

I've ~/.sbt/0.13/plugins/plugins.sbt
resolvers ++= Seq(
"Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/",
"jgit-repo" at "http://download.eclipse.org/jgit/maven")
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.4.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.6.2")

ant output from example git command:

$ sbt
Loading /usr/share/sbt/bin/sbt-launch-lib.bash
[info] Loading global plugins from /home/mateusz/.sbt/0.13/plugins
[info] Loading project definition from /home/mateusz/workspaces/scala-workspaces/moje_projekciki/PDFGen/project
[info] Set current project to hello (in build file:/home/mateusz/workspaces/scala-workspaces/moje_projekciki/PDFGen/)

git
[info] usage: git [--version] [--help] [-C ] [-c name=value]
[info] [--exec-path[=]] [--html-path] [--man-path] [--info-path]
[info] [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
[info] [--git-dir=] [--work-tree=] [--namespace=]
[info] []
[info]
[info] The most commonly used git commands are:
[info] add Add file contents to the index
[info] bisect Find by binary search the change that introduced a bug
[info] branch List, create, or delete branches
[info] checkout Checkout a branch or paths to the working tree
[info] clone Clone a repository into a new directory
[info] commit Record changes to the repository
[info] diff Show changes between commits, commit and working tree, etc
[info] fetch Download objects and refs from another repository
[info] grep Print lines matching a pattern
[info] init Create an empty Git repository or reinitialize an existing one
[info] log Show commit logs
[info] merge Join two or more development histories together
[info] mv Move or rename a file, a directory, or a symlink
[info] pull Fetch from and integrate with another repository or a local branch
[info] push Update remote refs along with associated objects
[info] rebase Forward-port local commits to the updated upstream head
[info] reset Reset current HEAD to the specified state
[info] rm Remove files from the working tree and from the index
[info] show Show various types of objects
[info] status Show the working tree status
[info] tag Create, list, delete or verify a tag object signed with GPG
[info]
[info] 'git help -a' and 'git help -g' lists available subcommands and some
[info] concept guides. See 'git help ' or 'git help '
[info] to read about a specific subcommand or concept.
usage: git [--version] [--help] [-C ] [-c name=value]
[--exec-path[=]] [--html-path] [--man-path] [--info-path]
[-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
[--git-dir=] [--work-tree=] [--namespace=]
[]
The most commonly used git commands are:
add Add file contents to the index
bisect Find by binary search the change that introduced a bug
branch List, create, or delete branches
checkout Checkout a branch or paths to the working tree
clone Clone a repository into a new directory
commit Record changes to the repository
diff Show changes between commits, commit and working tree, etc
fetch Download objects and refs from another repository
grep Print lines matching a pattern
init Create an empty Git repository or reinitialize an existing one
log Show commit logs
merge Join two or more development histories together
mv Move or rename a file, a directory, or a symlink
pull Fetch from and integrate with another repository or a local branch
push Update remote refs along with associated objects
rebase Forward-port local commits to the updated upstream head
reset Reset current HEAD to the specified state
rm Remove files from the working tree and from the index
show Show various types of objects
status Show the working tree status
tag Create, list, delete or verify a tag object signed with GPG
'git help -a' and 'git help -g' lists available subcommands and some
concept guides. See 'git help ' or 'git help '
to read about a specific subcommand or concept.

Migrate to use auto-plugin feature

I'd love getting rid of the build.sbt configuration step whatsoever by migrating the plugin to use auto-plugin feature available since sbt 0.13.5.

Quoting the official documentation of sbt:

sbt 0.13.5 intoduces auto plugin with improved dependency management among the plugins and explicitly scoped auto importing. Going forward, our recommendation is to migrate to the auto plugins.

The last sentence makes the migration highly welcome.

Is colour support possible?

I've been really impressed by the colouring added to sbt-revolver recently. It would be nice if I could have my git colouring from within sbt.

jgit-repo no longer available

The maven repo linked from the project description no longer seems to work:

resolvers += "jgit-repo" at "http://download.eclipse.org/jgit/maven"

can't compile the project because of failing dispatch dependency

[error] /Users/bchazalet/development/code/sbt-git/project/bintray.scala:33: not found: value dispatch
[error] import dispatch.classic._
[error] ^
[error] /Users/bchazalet/development/code/sbt-git/project/bintray.scala:35: not found: value Http
[error] Http(url(uri).POST.as(u,p).>|)
[error] ^
[error] two errors found
error Compilation failed

Uncommited suffix should be attached when using git describe

Using git describe when there are uncommited changes uncommittedSuffix is not attached on version.

Example:

git init
git commit -m "First commit"
git tag v1.0
reload
version
1.0
touch README.md
reload
version
1.0-SNAPSHOT (Uncommited README.md)
git add README.md
git commit "Second commit with README.md"
reload
version
v1.0-1-gc136ac1
touch README2.md
reload
version
v1.0-1-gc136ac1 (Uncommited README2.md)

Wouldn't it make sense to return v1.0-1-gc136ac1-SNAPSHOT?

Make git.baseVersion optional?

Hello,

At my company, we are running continuous deployment, and as such, deploy on each commit. Since this is the case, we use the git commit SHA as the actual version itself. This plugin is perfect for that, but it prepends a 1.0- to the git commit sha. You can override it by specifying git.baseVersion := "XYZ", but it's impossible to have nothing at all.

Obviously I'm being finicky here, but it's driving my OCD brain crazy! It would be great if there was a way to exclude the base version.

Support setting isSnapshot

If there is no current tag for the build, then sbt-git should set isSnapshot to true, or at least provide an option to do that, so that builds that publish nightlies to a snapshot repository still work.

not working on project with multiple git repos

considering a sbt multi project Root (project created using repo):

root/
     build.sbt
     a/
         .git/
          some_a_file
     b/
         .git/
         some_b_file

Since, gitReader is defined under ThisBuild. All the projects share the same gitReader , which's baseDirectory is root/. And it can not find the valid git repo for project a, neither for b.

The same for a project constructed with multiple sub project using git submodule add <sub_project_repo_url> sub_project_name

Git versioning with tags

I am trying to understand the rules used by sbt-git to build a version. If I make a tag at the present commit "v5.0.0" then sbt version shows the version to be 5.0.0. If I then make a new commit, sbt version shows the version to be 1.0-77c7b821e9450c17c9e1c43861cbca3e5feddd46. Shouldn't it be 5.0.0-77c7b821e9450c17c9e1c43861cbca3e5feddd46? Where is the 1.0 coming from?

Different status results for console git and JGit

Hello, In some cases console command git status and call porcelain.status.call.hasUncommittedChanges (with JGit 3.7 used in sbt-git) returns different results.
I observed it on renaming files (changing character registry in mac os x case insensitive hfs+) and when using symlinks.
These cases influence -SNAPSHOT suffix and I think git status is more correct.
I'd suppose to use your ConsoleGitRunner for implementing hasUncommittedChanges method in GitReadonlyInterface (running git status --porcelain command)

An example release workflow using GitVersioning would be helpful in docs.

Trying to figure out how to use GitVersioning during my git-flow-structured release process. Having an outline of example release process using GitVersioning would be helpful in bridging that gap.

In my specific case, trying to reconcile deriving version numbers from branch names vs. tag names, and if the publishing the release happens before or after the the release branch is merged onto master.

problems with spaces in commit message

Hi,

when I commit with
git commit -a -m "space in the message"
I get
[error] fatal: Paths with -a does not make sense.
[error] Nonzero exit value: 128
[error] Use 'last' for the full log.

PS: you publish 0.5-SNAPHOST

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.