Simplify format_mmd since scm.commit is always set or returns an exception

This commit is contained in:
mprahl
2019-04-30 09:49:02 -04:00
parent f4dd91e9ec
commit 37e4c718d9
4 changed files with 32 additions and 11 deletions

View File

@@ -28,6 +28,7 @@ from os.path import dirname
from shutil import copyfile
from datetime import datetime, timedelta
from random import randint
import hashlib
from module_build_service.utils import to_text_type
import module_build_service.messaging
@@ -73,6 +74,8 @@ class FakeSCM(object):
self.mocked_scm.return_value.repository_root = "https://src.stg.fedoraproject.org/modules/"
self.mocked_scm.return_value.sourcedir = self.sourcedir
self.mocked_scm.return_value.get_module_yaml = self.get_module_yaml
self.mocked_scm.return_value.is_full_commit_hash.return_value = commit and len(commit) == 40
self.mocked_scm.return_value.get_full_commit_hash.return_value = self.get_full_commit_hash
def checkout(self, temp_dir):
self.sourcedir = path.join(temp_dir, self.name)
@@ -89,6 +92,12 @@ class FakeSCM(object):
def get_module_yaml(self):
return path.join(self.sourcedir, self.name + ".yaml")
def get_full_commit_hash(self, commit_hash=None):
if not commit_hash:
commit_hash = self.commit
sha1_hash = hashlib.sha1("random").hexdigest()
return commit_hash + sha1_hash[len(commit_hash):]
class FakeModuleBuilder(GenericBuilder):
"""