Skip to content

Commit

Permalink
Merge pull request #59 from zarthross/fix-v
Browse files Browse the repository at this point in the history
Add a transformer for version tags so you can strip leading 'v's
  • Loading branch information
isomarcte authored Nov 21, 2023
2 parents 3221dd3 + 0e830b5 commit 52fee19
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ trait Keys {
).mkString(" ")
)

final val versionSchemeEnforcerPreviousVCSTagStringTransformer: SettingKey[String => String] =
settingKey[String => String](
"This setting operates only on the String representation of a VCS Tag and allows transforming that string."
)

final val versionSchemeEnforcerTagDomain: SettingKey[TagDomain] = settingKey[TagDomain](
"The domain of VCS tags to consider when looking for previous releases to use in the binary compatibility check. For example, this can be TagDomain.All to consider all tags on the repository, or TagDomain.Reachable to only consider tags which are reachable (ancestors) of the current commit. The later case can be useful when you have multiple branches which should not be considered directly related for the purposes of binary compatibility. TagDomain.All is the default as of 2.1.1.0. The behavior prior to 2.1.1.0 was equivalent to TagDomain.Reachable."
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,16 @@ object SbtVersionSchemeEnforcerPlugin extends AutoPlugin {
.flatMap(_.lastOption)
.fold(initialValue)(previousTag => Some(previousTag.value))
)
.map(versionSchemeEnforcerPreviousVCSTagStringTransformer.value)
}
},
versionSchemeEnforcerPreviousVCSTagStringTransformer := {
versionSchemeEnforcerPreviousVCSTagStringTransformer
.?
.value
.getOrElse {
_.stripPrefix("v").stripPrefix("V")
}
}
)

Expand Down
20 changes: 14 additions & 6 deletions vcs-tests/git/correct-value-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,29 +99,37 @@ rm initial.sbt

# One tag, no new commits

git tag '0.0.0.1' @
git tag -m "" '0.0.0.1' @

check_result 'Some(0.0.0.1)'

# Two tags, should only find the most recent one
# Tag transform test

add_commit

git tag '0.0.0.2' @
git tag -m "" 'v0.0.0.2-M1'

check_result 'Some(0.0.0.2-M1)'

# Two or more tags, should only find the most recent one

add_commit

git tag -m "" '0.0.0.2' @

check_result 'Some(0.0.0.2)'

# Tag filtering test

add_commit

git tag '0.0.0.3-M1'
git tag -m "" '0.0.0.3-M1'

check_result 'Some(0.0.0.3-M1)'

add_commit

git tag '0.0.0.3-M2'
git tag -m "" '0.0.0.3-M2'

check_result 'Some(0.0.0.3-M2)'

Expand All @@ -145,7 +153,7 @@ git checkout branchB

add_commit

git tag '0.0.0.4'
git tag -m "" '0.0.0.4'

check_result 'Some(0.0.0.4)'

Expand Down

0 comments on commit 52fee19

Please sign in to comment.