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

Git: only push released tag #91

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
9 changes: 7 additions & 2 deletions src/main/scala/Vcs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,12 @@ class Git(val baseDir: File) extends Vcs with GitLike {
cmd("push", trackingRemote, "%s:%s" format (localBranch, trackingBranch))
}

private def pushTags = cmd("push", "--tags", trackingRemote)
private def pushTags = {
val lastTag = (cmd("for-each-ref", "--count=1", "--sort=-taggerdate", "--format", "%(tag)", "refs/tags") !!).
linesIterator.next()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels a bit fragile - we know what the tag was because we tagged it, so we should use that. It will require a change to the signature of pushChanges, to take the tag (maybe an option of the tag), and it'll also require storing the tag in the state.

cmd("push", trackingRemote, lastTag)
}

}

object Subversion extends VcsCompanion {
Expand Down Expand Up @@ -214,4 +219,4 @@ class Subversion(val baseDir: File) extends Vcs {

private[sbtrelease] object Try {
def apply[A](f: => A): Option[A] = scala.util.control.Exception.allCatch.opt(f)
}
}