From 387f93151be304421fa22b8a641672e25af5ca1e Mon Sep 17 00:00:00 2001 From: Chenxiong Qi Date: Jul 08 2016 07:57:35 +0000 Subject: handle correct spec path when push from outside the repo Resolves: 1353699 Signed-off-by: Chenxiong Qi --- diff --git a/src/pyrpkg/__init__.py b/src/pyrpkg/__init__.py index ccdf753..60640d2 100644 --- a/src/pyrpkg/__init__.py +++ b/src/pyrpkg/__init__.py @@ -1733,7 +1733,7 @@ class Commands(object): self.log.warning('Current branch cannot be pushed anywhere!') # check missing patches ts = rpm.TransactionSet() - specfile = ts.parseSpec(self.spec) + specfile = ts.parseSpec(os.path.join(self.path, self.spec)) missing_patches = [] for source in specfile.sources: if source[0].endswith('.patch'): diff --git a/test/commands/test_push.py b/test/commands/test_push.py index fde4e29..5a0c69c 100644 --- a/test/commands/test_push.py +++ b/test/commands/test_push.py @@ -1,14 +1,11 @@ -import os -import shutil -import tempfile +# -*- coding: utf-8 -*- -import git -import subprocess +import os from . import CommandTestCase -SPECFILE_TEMPLATE="""Name: test +SPECFILE_TEMPLATE = """Name: test Version: 1.0 Release: 1.0 Summary: test @@ -28,6 +25,8 @@ CLONE_CONFIG = ''' bz.default-component %(module)s sendemail.to %(module)s-owner@fedoraproject.org ''' + + class CommandPushTestCase(CommandTestCase): def test_push_without_patches(self): self.make_new_git(self.module) @@ -56,7 +55,6 @@ class CommandPushTestCase(CommandTestCase): except pyrpkg.rpkgError: self.fail("No unpushed patches. This shouldn't raise exception") - def test_push_one_uncommitted_patch(self): self.make_new_git(self.module) @@ -190,3 +188,31 @@ class CommandPushTestCase(CommandTestCase): cmd.push() self.assertRaises(pyrpkg.rpkgError, raises) + + def test_push_outside_repo(self): + """push from outside repo with --path option""" + + self.make_new_git(self.module) + + import pyrpkg + cmd = pyrpkg.Commands(self.path, self.lookaside, + self.lookasidehash, + self.lookaside_cgi, self.gitbaseurl, + self.anongiturl, self.branchre, self.kojiconfig, + self.build_client, self.user, self.dist, + self.target, self.quiet) + cmd.clone_config = CLONE_CONFIG + cmd.clone(self.module, anon=True) + cmd.path = os.path.join(self.path, self.module) + os.chdir(os.path.join(self.path, self.module)) + + spec_file = 'module.spec' + with open(spec_file, 'w') as f: + f.write(SPECFILE_TEMPLATE % '') + + cmd.repo.index.add([spec_file]) + cmd.repo.index.commit("add SPEC") + + # Now, change directory to parent and test the push + os.chdir(self.path) + cmd.push()