Skip to content

Commit

Permalink
Merge pull request #162 from mpollmeier/master
Browse files Browse the repository at this point in the history
Pick the higher version if there are multiple on the current commit
  • Loading branch information
dwijnand authored Sep 13, 2018
2 parents 16587db + a9153c9 commit f8caf93
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ You can begin to use git to control your project versions.
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.
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>".

Expand Down
3 changes: 2 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ enablePlugins(GitVersioning, SbtPlugin)
git.baseVersion := "1.0"

libraryDependencies ++= Seq(
"org.eclipse.jgit" % "org.eclipse.jgit" % "4.9.0.201710071750-r"
"org.eclipse.jgit" % "org.eclipse.jgit" % "4.9.0.201710071750-r",
"com.michaelpollmeier" % "versionsort" % "1.0.0"
)

scriptedLaunchOpts += s"-Dproject.version=${version.value}"
2 changes: 1 addition & 1 deletion src/main/scala/com/typesafe/sbt/SbtGit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ object SbtGit {
version <- releaseTagVersion(tag)
} yield version + suffix
// NOTE - Selecting the last tag or the first tag should be an option.
releaseVersions.reverse.headOption
releaseVersions.sortWith { versionsort.VersionHelper.compare(_, _) > 0 }.headOption
}
def overrideVersion(versionProperty: String) = Option(sys.props(versionProperty))

Expand Down

0 comments on commit f8caf93

Please # to comment.