mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-05-12 10:57:58 +08:00
Simplify format_mmd since scm.commit is always set or returns an exception
This commit is contained in:
@@ -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):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user