diff options
author | Chris Rebert <code@rebertia.com> | 2015-04-24 08:15:33 +0300 |
---|---|---|
committer | Chris Rebert <code@rebertia.com> | 2015-04-24 08:20:18 +0300 |
commit | 31055e4bbb665001fa4f096a1e496aac2b17c134 (patch) | |
tree | ac02b2a11bae36ed745fea7de55bd7036fbe33db | |
parent | dc952d4fc4c3001373fb6d070c104092abae3f06 (diff) |
add savage.set-commit-status setting
-rw-r--r-- | README.md | 5 | ||||
-rw-r--r-- | src/main/resources/application.conf | 1 | ||||
-rw-r--r-- | src/main/scala/com/getbootstrap/savage/server/CommitStatusSetter.scala | 10 | ||||
-rw-r--r-- | src/main/scala/com/getbootstrap/savage/server/Settings.scala | 1 |
4 files changed, 12 insertions, 5 deletions
@@ -40,7 +40,8 @@ Using Savage involves two GitHub repos (which can both be the same repo, althoug * The *main repo* * This repo is the one receiving pull requests * Savage needs its GitHub web hook set up for this repo - * Savage does NOT need to be a Collaborator on this repo + * If you want Savage to set commit statuses on pull requests (see the `set-commit-status` setting), it must be a Collaborator on this repo. + * Otherwise, Savage does NOT need to be a Collaborator on this repo * The *test repo* * The repo that Savage will push test branches to * Travis CI should be set up for this repo @@ -66,6 +67,8 @@ savage { // Suppress Spray's logging of malformed HTTP requests/headers? // (Enable this to avoid floods in your log output when your Savage instance gets weird requests from crackers.) squelch-invalid-http-logging = true + // Set statuses on commits (like Travis does)? Requires push access to the github-repo-to-watch + set-commit-status = true // Full name of GitHub repo to watch for new pull requests github-repo-to-watch = "twbs/bootstrap" // Full name of GitHub repo to push test branches to diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf index 9a77049..1dcd1bd 100644 --- a/src/main/resources/application.conf +++ b/src/main/resources/application.conf @@ -24,6 +24,7 @@ spray.can { savage { default-port = 6060 squelch-invalid-http-logging = true + set-commit-status = true github-repo-to-watch = "twbs/bootstrap" github-test-repo = "twbs-savage/bootstrap" ignore-branches-from-watched-repo = true diff --git a/src/main/scala/com/getbootstrap/savage/server/CommitStatusSetter.scala b/src/main/scala/com/getbootstrap/savage/server/CommitStatusSetter.scala index 011d0da..9e2c2f5 100644 --- a/src/main/scala/com/getbootstrap/savage/server/CommitStatusSetter.scala +++ b/src/main/scala/com/getbootstrap/savage/server/CommitStatusSetter.scala @@ -16,11 +16,13 @@ class CommitStatusSetter extends GitHubActorWithLogging { override def receive = { case commitStatus@StatusForCommit(commit, status) => { - tryToSetCommitStatus(commitStatus) match { - case Success(createdCommitStatus) => { - log.info(s"Successfully created commit status with state ${status.name} for ${commit}") + if (settings.SetCommitStatus) { + tryToSetCommitStatus(commitStatus) match { + case Success(createdCommitStatus) => { + log.info(s"Successfully created commit status with state ${status.name} for ${commit}") + } + case Failure(exc) => log.error(exc, s"Error setting ${commitStatus}") } - case Failure(exc) => log.error(exc, s"Error setting ${commitStatus}") } } } diff --git a/src/main/scala/com/getbootstrap/savage/server/Settings.scala b/src/main/scala/com/getbootstrap/savage/server/Settings.scala index f2fc9c3..17f28d0 100644 --- a/src/main/scala/com/getbootstrap/savage/server/Settings.scala +++ b/src/main/scala/com/getbootstrap/savage/server/Settings.scala @@ -26,6 +26,7 @@ class SettingsImpl(config: Config) extends Extension { val BranchPrefix: String = config.getString("savage.branch-prefix") val IgnoreBranchesFromMainRepo: Boolean = config.getBoolean("savage.ignore-branches-from-watched-repo") val TrustedOrganizations: Set[String] = config.getStringList("savage.trusted-orgs").asScala.toSet + val SetCommitStatus: Boolean = config.getBoolean("savage.set-commit-status") } object Settings extends ExtensionId[SettingsImpl] with ExtensionIdProvider { override def lookup() = Settings |