我一直試圖找到一種方法,以確保版本反映了當前的git指數並沒有找到一種方法,這樣做呢,比如:如何更新版本以反映git的索引更改?
lazy val root = (project in file(".")).enablePlugins(GitPlugin)
root.settings(
isSnapshot in ThisBuild <<= git.gitUncommittedChanges in ThisBuild,
version in ThisBuild <<= (git.gitDescribedVersion in ThisBuild, isSnapshot in ThisBuild) { (described, isSnapshot) =>
described.map(tag => if (isSnapshot) s"$tag-SNAPSHOT" else tag).get
},
shellPrompt := { state => {
val (describe, snapshot) = GitKeys.gitReader.value.withGit(git => (git.describedVersion.get, git.hasUncommittedChanges))
val newVersion = s"$describe${if (snapshot) "-SNAPSHOT" else ""}"
if (newVersion != version.value) {
s"${scala.Console.RED}*** Version out of date ($newVersion vs ${version.value}), reload.\n${scala.Console.RESET}> "
} else "> "
}}
)
雖然這將警告用戶,如果版本不再反映Git中的內容並請求重新加載,如果版本會在此更改中自動更新,則會很不錯...
這可能嗎?
你使用什麼版本的sbt?你可能想在0.13.8中使用'enablePlugins(GitPlugin)'和其他好東西。 –