mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-05 11:48:33 +08:00
Merge #728 FIx for issue 673
This commit is contained in:
@@ -134,7 +134,7 @@ class SCM(object):
|
||||
if stderr:
|
||||
log.warning(stderr)
|
||||
if proc.returncode != 0:
|
||||
raise RuntimeError("Failed on %r, retcode %r, out %r, err %r" % (
|
||||
raise UnprocessableEntity("Failed on %r, retcode %r, out %r, err %r" % (
|
||||
cmd, proc.returncode, stdout, stderr))
|
||||
return proc.returncode, stdout, stderr
|
||||
|
||||
@@ -186,7 +186,7 @@ class SCM(object):
|
||||
"""
|
||||
if self.scheme == "git":
|
||||
log.debug("Getting/verifying commit hash for %s" % self.repository)
|
||||
output = SCM._run(["git", "ls-remote", self.repository, branch])[1]
|
||||
output = SCM._run(["git", "ls-remote", "--exit-code", self.repository, branch])[1]
|
||||
if output:
|
||||
self.commit = output.split("\t")[0]
|
||||
return self.commit
|
||||
|
||||
@@ -65,8 +65,10 @@ class TestSCMModule(unittest.TestCase):
|
||||
scm = module_build_service.scm.SCM(repo_path)
|
||||
assert scm.scheme == 'git', scm.scheme
|
||||
fname = tempfile.mktemp(suffix='mbs-scm-test')
|
||||
scm.get_latest(branch='master; touch %s' % fname)
|
||||
assert not os.path.exists(fname), "%r exists! Vulnerable." % fname
|
||||
try:
|
||||
scm.get_latest(branch='master; touch %s' % fname)
|
||||
except UnprocessableEntity:
|
||||
assert not os.path.exists(fname), "%r exists! Vulnerable." % fname
|
||||
|
||||
def test_local_extract_name(self):
|
||||
scm = module_build_service.scm.SCM(repo_path)
|
||||
@@ -115,3 +117,8 @@ class TestSCMModule(unittest.TestCase):
|
||||
scm.checkout(self.tempdir)
|
||||
scm.verify()
|
||||
scm.get_module_yaml()
|
||||
|
||||
@raises(UnprocessableEntity)
|
||||
def test_get_latest_incorect_component_branch(self):
|
||||
scm = module_build_service.scm.SCM(repo_path)
|
||||
scm.get_latest(branch='foobar')
|
||||
|
||||
Reference in New Issue
Block a user