From b6498cf7c6b7d3014d7b16af3818155d9157951d Mon Sep 17 00:00:00 2001 From: Chenxiong Qi Date: Sep 29 2016 07:52:04 +0000 Subject: [PATCH 1/3] [DONT MERGE] Test Jenkins CI Signed-off-by: Chenxiong Qi --- diff --git a/src/pyrpkg/__init__.py b/src/pyrpkg/__init__.py index 17abde0..9efcd9b 100644 --- a/src/pyrpkg/__init__.py +++ b/src/pyrpkg/__init__.py @@ -289,11 +289,9 @@ class Commands(object): session_opts[name] = defaults[name] try: if anon: - self._anon_kojisession = koji.ClientSession(defaults['server'], - session_opts) + self._anon_kojisession = koji.ClientSession(defaults['server'], session_opts) else: - self._kojisession = koji.ClientSession(defaults['server'], - session_opts) + self._kojisession = koji.ClientSession(defaults['server'], session_opts) except: raise rpkgError('Could not initiate %s session' % os.path.basename(self.build_client)) @@ -360,8 +358,7 @@ class Commands(object): except TypeError as e: raise rpkgError('Repo in inconsistent state: %s' % e) try: - merge = self.repo.git.config('--get', - 'branch.%s.merge' % localbranch) + merge = self.repo.git.config('--get', 'branch.%s.merge' % localbranch) except git.GitCommandError as e: raise rpkgError('Unable to find remote branch. Use --dist') # Trim off the refs/heads so that we're just working with @@ -381,8 +378,7 @@ class Commands(object): """Find the name of remote from branch we're on.""" try: - remote = self.repo.git.config('--get', 'branch.%s.remote' - % self.branch_merge) + remote = self.repo.git.config('--get', 'branch.%s.remote' % self.branch_merge) except (git.GitCommandError, rpkgError) as e: remote = self.default_branch_remote self.log.debug("Could not determine the remote name: %s", str(e)) @@ -404,12 +400,10 @@ class Commands(object): url = self.repo.git.remote('get-url', '--push', self.branch_remote) except git.GitCommandError as e: try: - url = self.repo.git.config( - '--get', 'remote.%s.pushurl' % self.branch_remote) + url = self.repo.git.config('--get', 'remote.%s.pushurl' % self.branch_remote) except git.GitCommandError as e: try: - url = self.repo.git.config( - '--get', 'remote.%s.url' % self.branch_remote) + url = self.repo.git.config('--get', 'remote.%s.url' % self.branch_remote) except git.GitCommandError as e: raise rpkgError('Unable to find remote push url: %s' % e) if isinstance(url, six.text_type): @@ -607,7 +601,6 @@ class Commands(object): def load_nvr(self): """This sets the nvr attribute""" - self._nvr = '%s-%s-%s' % (self.module_name, self.ver, self.rel) @property @@ -650,12 +643,8 @@ class Commands(object): first_line_output = output.split('??')[0] parts = first_line_output.split() if len(parts) != 4: - raise rpkgError('Could not get n-v-r-e from %r' - % first_line_output) - (self._module_name_spec, - self._epoch, - self._ver, - self._rel) = parts + raise rpkgError('Could not get n-v-r-e from %r' % first_line_output) + (self._module_name_spec, self._epoch, self._ver, self._rel) = parts # Most packages don't include a "Epoch: 0" line, in which case RPM # returns '(none)' diff --git a/test/test_commands.py b/test/test_commands.py index 7267c89..2b353bb 100644 --- a/test/test_commands.py +++ b/test/test_commands.py @@ -430,3 +430,7 @@ class CheckRepoWithOrWithoutDistOptionCase(CommandTestCase): 'should not happen. Something must be going wrong.') self.fail('Should not fail. Something must be going wrong.') + + +def test_fail(self): + assert 1 == 0, 'Failure is expected.' From 5c8a465cf0a9e069845867eb71efb614afef7bda Mon Sep 17 00:00:00 2001 From: Chenxiong Qi Date: Sep 29 2016 07:52:04 +0000 Subject: [PATCH 2/3] Fix more Signed-off-by: Chenxiong Qi --- diff --git a/src/pyrpkg/__init__.py b/src/pyrpkg/__init__.py index 9efcd9b..295b0f1 100644 --- a/src/pyrpkg/__init__.py +++ b/src/pyrpkg/__init__.py @@ -1054,22 +1054,16 @@ class Commands(object): """Get the namespaced git url, if DistGit namespaces enabled Takes a module name - Returns a string of giturl - """ - if self.distgit_namespaced: if '/' in module: - giturl = self.gitbaseurl % \ - {'user': self.user, 'module': module} + giturl = self.gitbaseurl % {'user': self.user, 'module': module} else: # Default to rpms namespace for backwards compat - giturl = self.gitbaseurl % \ - {'user': self.user, 'module': "rpms/%s" % module} + giturl = self.gitbaseurl % {'user': self.user, 'module': "rpms/%s" % module} else: - giturl = self.gitbaseurl % \ - {'user': self.user, 'module': module} + giturl = self.gitbaseurl % {'user': self.user, 'module': module} return giturl @@ -1079,9 +1073,7 @@ class Commands(object): Takes a module name Returns a string of giturl - """ - if self.distgit_namespaced: if '/' in module: giturl = self.anongiturl % {'module': module} @@ -1248,8 +1240,7 @@ class Commands(object): try: os.mkdir(top_path) except OSError as e: - raise rpkgError('Could not create directory for module %s: %s' - % (module, e)) + raise rpkgError('Could not create directory for module %s: %s' % (module, e)) # Create a bare clone first. This gives us a good list of branches try: @@ -1279,8 +1270,7 @@ class Commands(object): "remote.%s.url" % self.default_branch_remote, giturl) except (git.GitCommandError, OSError) as e: - raise rpkgError('Could not locally clone %s from %s: %s' - % (branch, repo_path, e)) + raise rpkgError('Could not locally clone %s from %s: %s' % (branch, repo_path, e)) # We don't need this now. Ignore errors since keeping it does no harm shutil.rmtree(repo_path, ignore_errors=True) @@ -1324,8 +1314,7 @@ class Commands(object): elif file: # If we get a relative file name, prepend our path to it. if self.path and not file.startswith('/'): - cmd.extend(['-F', os.path.abspath(os.path.join(self.path, - file))]) + cmd.extend(['-F', os.path.abspath(os.path.join(self.path, file))]) else: cmd.extend(['-F', os.path.abspath(file)]) if not files: @@ -1341,7 +1330,6 @@ class Commands(object): try: self.repo.delete_tag(tagname) - except git.GitCommandError as e: raise rpkgError(e) @@ -1384,18 +1372,15 @@ class Commands(object): # We need something better for epel cmd = ['git', 'ls-remote', url, 'refs/heads/%s' % branch] try: - proc = subprocess.Popen(cmd, stderr=subprocess.PIPE, - stdout=subprocess.PIPE) + proc = subprocess.Popen(cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE) output, error = proc.communicate() except OSError as e: raise rpkgError(e) if error: - raise rpkgError('Got an error finding %s head for %s: %s' - % (branch, module, error)) + raise rpkgError('Got an error finding %s head for %s: %s' % (branch, module, error)) # Return the hash sum if not output: - raise rpkgError('Could not find remote branch %s for %s' - % (branch, module)) + raise rpkgError('Could not find remote branch %s for %s' % (branch, module)) return output.split()[0] def gitbuildhash(self, build): @@ -1568,8 +1553,7 @@ class Commands(object): raise rpkgError('Expanded source dir not found!') # Setup the command - cmd = ['gendiff', '%s-%s' % (self.module_name, self.ver), - '.%s' % suffix] + cmd = ['gendiff', '%s-%s' % (self.module_name, self.ver), '.%s' % suffix] # Try to run the command and capture the output try: From 9bc5aaca255860e2400c8f6a8ad88f3502e81a7e Mon Sep 17 00:00:00 2001 From: Chenxiong Qi Date: Sep 29 2016 07:54:16 +0000 Subject: [PATCH 3/3] Fix more Signed-off-by: Chenxiong Qi --- diff --git a/src/pyrpkg/cli.py b/src/pyrpkg/cli.py index a48d7c9..b9a8c19 100755 --- a/src/pyrpkg/cli.py +++ b/src/pyrpkg/cli.py @@ -463,8 +463,8 @@ defined, packages will be built sequentially.""" % {'name': self.name}) """Register the diff target""" diff_parser = self.subparsers.add_parser( - 'diff', help='Show changes between commits, commit and working ' - 'tree, etc', + 'diff', + help='Show changes between commits, commit and working tree, etc', description='Use git diff to show changes that have been made to ' 'tracked files. By default cached changes (changes ' 'that have been git added) will not be shown.') @@ -544,8 +544,8 @@ defined, packages will be built sequentially.""" % {'name': self.name}) """Register the lint target""" lint_parser = self.subparsers.add_parser( - 'lint', help='Run rpmlint against local spec and build output if ' - 'present.', + 'lint', + help='Run rpmlint against local spec and build output if present.', description='Rpmlint can be configured using the --rpmlintconf/-r' ' option or by setting a .rpmlint file in the ' 'working directory')