From dd176494c93d580605053025b5a5872a8d78b856 Mon Sep 17 00:00:00 2001 From: abdullahzen Date: Tue, 15 Dec 2020 03:28:44 -0500 Subject: [PATCH 1/5] Replaced commit count with a parameter test_version to override the default version of 0 with any build number from the cli --- src/tito/builder/main.py | 11 ++++++----- src/tito/cli.py | 7 +++++++ src/tito/release/main.py | 2 ++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/tito/builder/main.py b/src/tito/builder/main.py index 3e4ec7d1..9cb64ff1 100644 --- a/src/tito/builder/main.py +++ b/src/tito/builder/main.py @@ -91,6 +91,7 @@ def __init__(self, name=None, build_dir=None, # releasers in their config sections. if args and 'test' in args: self.test = True + self.test_version = self._get_optional_arg(kwargs, 'test_version', 0) # Location where we do all tito work and store resulting rpms: self.rpmbuild_basedir = build_dir @@ -598,12 +599,12 @@ def _setup_test_specfile(self): munge_specfile( self.spec_file, sha, - self.commit_count, + self.test_version, fullname, self.tgz_filename, ) - self.build_version += ".git." + str(self.commit_count) + "." + str(sha) + self.build_version += ".git." + str(self.test_version) + "." + str(sha) self.ran_setup_test_specfile = True def _get_rpmbuild_dir_options(self): @@ -681,11 +682,11 @@ def _setup_test_specfile(self): # file we're building off. (note that this is a temp copy of the # spec) Swap out the actual release for one that includes the git # SHA1 we're building for our test package: - debug("setup_test_specfile:commit_count = %s" % str(self.commit_count)) + debug("setup_test_specfile:test_version = %s" % str(self.test_version)) munge_specfile( self.spec_file, self.git_commit_id[:7], - self.commit_count + self.test_version ) @@ -1101,7 +1102,7 @@ def _setup_test_specfile(self): # file we're building off. (note that this is a temp copy of the # spec) Swap out the actual release for one that includes the git # SHA1 we're building for our test package: - self.build_version += ".git." + str(self.commit_count) + "." + str(self.git_commit_id[:7]) + self.build_version += ".git." + str(self.test_version) + "." + str(self.git_commit_id[:7]) replace_spec_release(self.spec_file, self.spec_release) self.ran_setup_test_specfile = True diff --git a/src/tito/cli.py b/src/tito/cli.py index a5c604e3..a7663588 100644 --- a/src/tito/cli.py +++ b/src/tito/cli.py @@ -327,6 +327,8 @@ def __init__(self): self.parser.add_option("--test", dest="test", action="store_true", help="use current branch HEAD instead of latest package tag") + self.parser.add_option("--test-version", dest="test_version", action="store_true", + help="overrides the commit count number in the produced artifact name in test build") self.parser.add_option("--no-cleanup", dest="no_cleanup", action="store_true", help="do not clean up temporary tito build directories/files, and disable rpmbuild %clean") @@ -369,6 +371,7 @@ def main(self, argv): kwargs = { 'dist': self.options.dist, 'test': self.options.test, + 'test_version': self.options.test_version, 'offline': self.options.offline, 'auto_install': self.options.auto_install, 'rpmbuild_options': self.options.rpmbuild_options, @@ -447,6 +450,9 @@ def __init__(self): self.parser.add_option("--test", action="store_true", help="use current branch HEAD instead of latest package tag") + self.parser.add_option("--test_version", action="store_true", + help="overrides the commit count number in the produced artifact name in test build") + self.parser.add_option("-y", "--yes", dest="auto_accept", action="store_true", help="Do not require input, just accept commits and builds") @@ -594,6 +600,7 @@ def main(self, argv): releaser_config=releaser_config, no_cleanup=self.options.no_cleanup, test=self.options.test, + test_version=self.options.test_version, auto_accept=self.options.auto_accept, **kwargs) diff --git a/src/tito/release/main.py b/src/tito/release/main.py index c0fcb133..b110000c 100644 --- a/src/tito/release/main.py +++ b/src/tito/release/main.py @@ -53,6 +53,8 @@ def __init__(self, name=None, tag=None, build_dir=None, config_builder_args = self._parse_builder_args(releaser_config, target) if test: config_builder_args['test'] = [True] # builder must know to build from HEAD + self.test_version = self._get_optional_arg(kwargs, 'test_version', 0) + # Override with builder args from command line if any were given: if 'builder_args' in kwargs: From 3cffb69b6b83cf57fef11e75c62525f5c35ac8bf Mon Sep 17 00:00:00 2001 From: abdullahzen Date: Tue, 15 Dec 2020 03:49:41 -0500 Subject: [PATCH 2/5] Removed the test_version from the releaser because it's not needed --- src/tito/builder/main.py | 2 +- src/tito/cli.py | 4 ---- src/tito/release/main.py | 1 - 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/tito/builder/main.py b/src/tito/builder/main.py index 9cb64ff1..d242e2f1 100644 --- a/src/tito/builder/main.py +++ b/src/tito/builder/main.py @@ -87,11 +87,11 @@ def __init__(self, name=None, build_dir=None, self.rpmbuild_options = self._get_optional_arg(kwargs, 'rpmbuild_options', '') self.test = self._get_optional_arg(kwargs, 'test', False) + self.test_version = self._get_optional_arg(kwargs, 'test_version', 0) # Allow a builder arg to override the test setting passed in, used by # releasers in their config sections. if args and 'test' in args: self.test = True - self.test_version = self._get_optional_arg(kwargs, 'test_version', 0) # Location where we do all tito work and store resulting rpms: self.rpmbuild_basedir = build_dir diff --git a/src/tito/cli.py b/src/tito/cli.py index a7663588..a8200f6f 100644 --- a/src/tito/cli.py +++ b/src/tito/cli.py @@ -450,9 +450,6 @@ def __init__(self): self.parser.add_option("--test", action="store_true", help="use current branch HEAD instead of latest package tag") - self.parser.add_option("--test_version", action="store_true", - help="overrides the commit count number in the produced artifact name in test build") - self.parser.add_option("-y", "--yes", dest="auto_accept", action="store_true", help="Do not require input, just accept commits and builds") @@ -600,7 +597,6 @@ def main(self, argv): releaser_config=releaser_config, no_cleanup=self.options.no_cleanup, test=self.options.test, - test_version=self.options.test_version, auto_accept=self.options.auto_accept, **kwargs) diff --git a/src/tito/release/main.py b/src/tito/release/main.py index b110000c..185b5ef9 100644 --- a/src/tito/release/main.py +++ b/src/tito/release/main.py @@ -53,7 +53,6 @@ def __init__(self, name=None, tag=None, build_dir=None, config_builder_args = self._parse_builder_args(releaser_config, target) if test: config_builder_args['test'] = [True] # builder must know to build from HEAD - self.test_version = self._get_optional_arg(kwargs, 'test_version', 0) # Override with builder args from command line if any were given: From 566d1fc9bc2eb25dd1f10b33a680e798e74942d6 Mon Sep 17 00:00:00 2001 From: abdullahzen Date: Tue, 15 Dec 2020 03:58:05 -0500 Subject: [PATCH 3/5] Fixing conformance errors raised by unit tests --- src/tito/release/main.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/tito/release/main.py b/src/tito/release/main.py index 185b5ef9..c0fcb133 100644 --- a/src/tito/release/main.py +++ b/src/tito/release/main.py @@ -54,7 +54,6 @@ def __init__(self, name=None, tag=None, build_dir=None, if test: config_builder_args['test'] = [True] # builder must know to build from HEAD - # Override with builder args from command line if any were given: if 'builder_args' in kwargs: # (in case of dupes, last one wins) From 05cbd7f870506f9d501749058170627e7626fc97 Mon Sep 17 00:00:00 2001 From: abdullahzen Date: Tue, 15 Dec 2020 04:23:57 -0500 Subject: [PATCH 4/5] Fixed format of test version parameter to be an integer --- src/tito/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tito/cli.py b/src/tito/cli.py index a8200f6f..912f580b 100644 --- a/src/tito/cli.py +++ b/src/tito/cli.py @@ -327,7 +327,7 @@ def __init__(self): self.parser.add_option("--test", dest="test", action="store_true", help="use current branch HEAD instead of latest package tag") - self.parser.add_option("--test-version", dest="test_version", action="store_true", + self.parser.add_option("--test-version", dest="test_version", metavar="TESTVERSION", help="overrides the commit count number in the produced artifact name in test build") self.parser.add_option("--no-cleanup", dest="no_cleanup", action="store_true", From ebd42320b2bfe0b47914f6c24bcc4174c5e17ec4 Mon Sep 17 00:00:00 2001 From: abdullahzen Date: Tue, 15 Dec 2020 22:39:48 -0500 Subject: [PATCH 5/5] Added default value for test_version to be commit_count --- src/tito/builder/main.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/tito/builder/main.py b/src/tito/builder/main.py index d242e2f1..eaf2676e 100644 --- a/src/tito/builder/main.py +++ b/src/tito/builder/main.py @@ -87,7 +87,7 @@ def __init__(self, name=None, build_dir=None, self.rpmbuild_options = self._get_optional_arg(kwargs, 'rpmbuild_options', '') self.test = self._get_optional_arg(kwargs, 'test', False) - self.test_version = self._get_optional_arg(kwargs, 'test_version', 0) + self.test_version = self._get_optional_arg(kwargs, 'test_version', None) # Allow a builder arg to override the test setting passed in, used by # releasers in their config sections. if args and 'test' in args: @@ -633,8 +633,9 @@ def _get_display_version(self): if self.test: # should get latest commit for given directory *NOT* HEAD latest_commit = get_latest_commit(".") - self.commit_count = get_commit_count(self.build_tag, latest_commit) - version = "git-%s.%s" % (self.commit_count, latest_commit[:7]) + if self.test_version is None: + self.test_version = get_commit_count(self.build_tag, latest_commit) + version = "git-%s.%s" % (self.test_version, latest_commit[:7]) else: version = self.build_version.split("-")[0] return version