Skip to content

Commit

Permalink
Merge pull request #16 from dwijnand/1.1.0
Browse files Browse the repository at this point in the history
Prepare for 1.1.0 release
  • Loading branch information
dwijnand authored Nov 19, 2016
2 parents 3655d01 + 899eb0a commit 4036bf2
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ jdk: oraclejdk8
scala: 2.10.6
script: project/travis.sh

# Build only PRs and pushes to master - http://stackoverflow.com/a/31882307/463761
# Build only master and version tags - http://stackoverflow.com/a/31882307/463761
branches:
only:
- master
Expand Down
17 changes: 17 additions & 0 deletions notes/1.0.0.markdown
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
19 changes: 19 additions & 0 deletions notes/1.1.0.markdown
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
4 changes: 4 additions & 0 deletions notes/about.markdown
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.
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.13-RC1
sbt.version=0.13.13
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import java.nio.file._, StandardOpenOption._
import java.util.{ Properties => _, _ }

import scala.collection.JavaConverters._
package sbtdynver

import org.scalacheck._, Prop._
import org.eclipse.jgit.api._
import sbtdynver._

import RepoStates._

object VersionSpec extends Properties("VersionSpec") {
Expand All @@ -29,40 +25,3 @@ object IsSnapshotSpec extends Properties("IsSnapshotSpec") {
property("on tag v1.0.0 and 1 commit, w/o local changes") = onTagAndCommit().isSnapshot() ?= false
property("on tag v1.0.0 and 1 commit with local changes") = onTagAndCommitDirty().isSnapshot() ?= true
}

object RepoStates {
def notAGitRepo() = State()
def noCommits() = notAGitRepo().init()
def onCommit() = noCommits().commit()
def onCommitDirty() = onCommit().dirty()
def onTag() = onCommit().tag()
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() = andThis(git.tag().setName("v1.0.0").setAnnotated(true).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
}
}
9 changes: 9 additions & 0 deletions src/test/scala/sbtdynver/GH7.scala
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.
45 changes: 45 additions & 0 deletions src/test/scala/sbtdynver/RepoStates.scala
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
}
}

0 comments on commit 4036bf2

Please sign in to comment.