From 6878b60b3b43fe4157cd8e6713caf1a1844e3939 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Thu, 21 May 2015 13:14:15 -0300 Subject: [PATCH] Add support for string replacing MEAD_SCM_USERNAME in push URL. --- src/tito/exception.py | 9 ++++++++- src/tito/release/distgit.py | 16 +++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/tito/exception.py b/src/tito/exception.py index fcb756f..9b44162 100644 --- a/src/tito/exception.py +++ b/src/tito/exception.py @@ -27,7 +27,7 @@ class TitoException(Exception): self.message = message def __str__(self): - return "TitoException: %s" % self.message + return "%s" % self.message class RunCommandException(Exception): @@ -37,3 +37,10 @@ class RunCommandException(Exception): self.command = command self.status = status self.output = output + + +class ConfigException(TitoException): + """ + Exception thrown when the user has specified invalid configuration. + """ + pass diff --git a/src/tito/release/distgit.py b/src/tito/release/distgit.py index dfbd096..5f89804 100644 --- a/src/tito/release/distgit.py +++ b/src/tito/release/distgit.py @@ -22,7 +22,9 @@ from tito.compat import getoutput, getstatusoutput, write from tito.release import Releaser from tito.release.main import PROTECTED_BUILD_SYS_FILES from tito.buildparser import BuildTargetParser -from tito.exception import RunCommandException +from tito.exception import RunCommandException, ConfigException + +MEAD_SCM_USERNAME = 'MEAD_SCM_USERNAME' class FedoraGitReleaser(Releaser): @@ -426,6 +428,18 @@ class DistGitMeadReleaser(DistGitReleaser): else: self.push_url = self.mead_scm + # If the push URL contains MEAD_SCM_URL, we require the user to set this + # in ~/.titorc before they can run this releaser. This allows us to + # use push URLs that require username auth, but still check a generic + # URL into source control: + if MEAD_SCM_USERNAME in self.push_url: + debug("Push URL contains %s, checking for value in ~/.titorc" % + MEAD_SCM_USERNAME) + if MEAD_SCM_USERNAME not in user_config: + raise ConfigException('Must specify MEAD_SCM_USERNAME in ~/.titorc') + self.push_url = self.push_url.replace(MEAD_SCM_USERNAME, + user_config[MEAD_SCM_USERNAME]) + def _sync_mead_scm(self): cmd = "git push %s %s" % (self.push_url, self.builder.build_tag) if self.dry_run: