Skip to content

Commit 95d66d1

Browse files
committed
Use SOURCE_VERSION env variable to get Heroku build commit
Since 1st April 2015, there's a `SOURCE_VERSION` environment variable available to builds running on Heroku. For git-push builds, this is the git commit SHA-1 of the source being built: https://devcenter.heroku.com/changelog-items/630 http://stackoverflow.com/a/28718917/438886
1 parent 6201453 commit 95d66d1

File tree

3 files changed

+2
-23
lines changed

3 files changed

+2
-23
lines changed

app/controllers/Application.scala

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -110,25 +110,4 @@ object Application extends Controller {
110110
Ok(pullRequestSent(req.pr, req.user, mailType)).addingToSession(prId.slug -> toJson(updatedSettings).toString)
111111
}
112112
}
113-
114-
lazy val gitCommitId = gitCommitIdFromHerokuFile.getOrElse(app.BuildInfo.gitCommitId)
115-
116-
def gitCommitIdFromHerokuFile: Option[String] = {
117-
val existingFileOpt: Option[File] = herokuMetadataFile()
118-
119-
Logger.debug(s"Heroku dyno metadata: $existingFileOpt")
120-
121-
for {
122-
existingFile <- existingFileOpt
123-
commitId <- (Json.parse(new FileInputStream(existingFile)) \ "release" \ "commit").asOpt[String]
124-
} yield {
125-
Logger.debug(s"Heroku dyno commit id: $commitId")
126-
commitId
127-
}
128-
}
129-
130-
def herokuMetadataFile(): Option[File] = {
131-
val file = new File("/etc/heroku/dyno")
132-
if (file.exists && file.isFile) Some(file) else None
133-
}
134113
}

app/views/fragments/footer.scala.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
<p></p>
1111
</div>
1212
</footer>
13-
<!-- @Application.gitCommitId -->
13+
<!-- @app.BuildInfo.gitCommitId -->

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ lazy val root = (project in file(".")).enablePlugins(
1212
).settings(
1313
buildInfoKeys := Seq[BuildInfoKey](
1414
name,
15-
BuildInfoKey.constant("gitCommitId", Option(System.getenv("BUILD_VCS_NUMBER")) getOrElse(try {
15+
BuildInfoKey.constant("gitCommitId", Option(System.getenv("SOURCE_VERSION")) getOrElse(try {
1616
"git rev-parse HEAD".!!.trim
1717
} catch { case e: Exception => "unknown" }))
1818
),

0 commit comments

Comments
 (0)