-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from dwijnand/1.1.0
Prepare for 1.1.0 release
- Loading branch information
Showing
9 changed files
with
98 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
- Initial implementation. | ||
- Sets `version in ThisBuild` and `isSnapshot in ThisBuild` automatically according to these rules: | ||
|
||
``` | ||
| Case | version | isSnapshot | | ||
| -------------------------------------------------------------------- | ------------------------------ | ---------- | | ||
| when on tag v1.0.0, w/o local changes | 1.0.0 | false | | ||
| when on tag v1.0.0 with local changes | 1.0.0+20140707-1030 | true | | ||
| when on tag v1.0.0 +3 commits, on commit 1234abcd, w/o local changes | 1.0.0+3-1234abcd | false | | ||
| when on tag v1.0.0 +3 commits, on commit 1234abcd with local changes | 1.0.0+3-1234abcd+20140707-1030 | true | | ||
| when there are no tags, on commit 1234abcd, w/o local changes | 1234abcd | true | | ||
| when there are no tags, on commit 1234abcd with local changes | 1234abcd+20140707-1030 | true | | ||
| when there are no commits, or the project isn't a git repo | HEAD+20140707-1030 | true | | ||
``` | ||
- Includes a `dynver` task that returns the version of your project, from git | ||
- Includes a `dynverCheckVersion` task that checks if version and dynver match | ||
- Includes a `dynverAssertVersion` task that asserts if version and dynver match |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
### Improvements | ||
|
||
- Allows matching lightweight (aka non-annotated) tags (eg. `git tag` without the `-a`). [#14][]/[#15][] by [@2m][] | ||
- Reduced the number of `git` calls to 1. [#11][] by [@dwijnand][] | ||
- Adds MiMa to verify binary compatibility, included in PR validation. [#6][]/[#8][] by [@dwijnand][] | ||
|
||
### Bug Fixes | ||
|
||
- Fixes a bug where major-only version tags weren't matched (eg. "v2"). [#7][]/[#15][] by [@2m][] | ||
|
||
[#6]: https://github.com/dwijnand/sbt-dynver/issues/6 | ||
[#7]: https://github.com/dwijnand/sbt-dynver/issues/7 | ||
[#8]: https://github.com/dwijnand/sbt-dynver/pull/8 | ||
[#11]: https://github.com/dwijnand/sbt-dynver/pull/11 | ||
[#14]: https://github.com/dwijnand/sbt-dynver/issues/14 | ||
[#15]: https://github.com/dwijnand/sbt-dynver/pull/15 | ||
|
||
[@dwijnand]: https://github.com/dwijnand | ||
[@2m]: https://github.com/2m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[sbt-dynver]: https://github.com/dwijnand/sbt-dynver | ||
[sbt]: http://www.scala-sbt.org/ | ||
|
||
[sbt-dynver][] is an [sbt][] plugin to dynamically set your version from git. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
sbt.version=0.13.13-RC1 | ||
sbt.version=0.13.13 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package sbtdynver | ||
|
||
import org.scalacheck._, Prop._ | ||
|
||
import RepoStates._ | ||
|
||
object GH7 extends Properties("GH6") { | ||
property("A tag of v2 is matched") = onTag("v2").version() ?= "2" | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package sbtdynver | ||
|
||
import java.nio.file._, StandardOpenOption._ | ||
import java.util._ | ||
|
||
import scala.collection.JavaConverters._ | ||
|
||
import org.eclipse.jgit.api._ | ||
|
||
object RepoStates { | ||
def notAGitRepo() = State() | ||
def noCommits() = notAGitRepo().init() | ||
def onCommit() = noCommits().commit() | ||
def onCommitDirty() = onCommit().dirty() | ||
def onTag(n: String = "v1.0.0") = onCommit().tag(n) | ||
def onTagDirty() = onTag().dirty() | ||
def onTagAndCommit() = onTag().commit() | ||
def onTagAndCommitDirty() = onTagAndCommit().dirty() | ||
|
||
final case class State() { | ||
val dir = doto(Files.createTempDirectory(s"dynver-test-").toFile)(_.deleteOnExit()) | ||
val date = new GregorianCalendar(2016, 8, 17).getTime | ||
val dynver = DynVer(Some(dir)) | ||
|
||
var git: Git = _ | ||
var sha: String = "undefined" | ||
|
||
def init() = andThis(git = Git.init().setDirectory(dir).call()) | ||
def dirty() = andThis(Files.write(dir.toPath.resolve("f.txt"), Seq("1").asJava, CREATE, APPEND)) | ||
def tag(n: String) = andThis(git.tag().setName(n).call()) | ||
|
||
def commit() = andThis { | ||
dirty() | ||
git.add().addFilepattern(".").call() | ||
sha = git.commit().setMessage("1").call().abbreviate(8).name() | ||
} | ||
|
||
def version() = dynver.version(date).replaceAllLiterally(sha, "1234abcd") | ||
def isSnapshot() = dynver.isSnapshot() | ||
|
||
private def doalso[A, U](x: A)(xs: U*) = x | ||
private def doto[A, U](x: A)(f: A => U) = doalso(x)(f(x)) | ||
private def andThis[U](x: U) = this | ||
} | ||
} |