Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pick the higher version if there are multiple on the current commit #162

Merged
merged 1 commit into from
Sep 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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