Merge pull request #2418 from charltonaustin/fix_error_with_dockerfile_content
fix(buildtrigger): fixed error from github api
This commit is contained in:
commit
c09d07e81c
5 changed files with 6 additions and 6 deletions
|
@ -259,7 +259,7 @@ class BuildTriggerHandler(object):
|
|||
pass
|
||||
|
||||
@classmethod
|
||||
def path_is_dockerfile(cls, file_name):
|
||||
def filename_is_dockerfile(cls, file_name):
|
||||
""" Returns whether the file is named Dockerfile or follows the convention <name>.Dockerfile"""
|
||||
return file_name.endswith(".Dockerfile") or u"Dockerfile" == file_name
|
||||
|
||||
|
|
|
@ -453,7 +453,7 @@ class BitbucketBuildTrigger(BuildTriggerHandler):
|
|||
raise RepositoryReadException(err_msg)
|
||||
|
||||
files = set([f['path'] for f in data['files']])
|
||||
return ["/" + file_path for file_path in files if self.path_is_dockerfile(os.path.basename(file_path))]
|
||||
return ["/" + file_path for file_path in files if self.filename_is_dockerfile(os.path.basename(file_path))]
|
||||
|
||||
def load_dockerfile_contents(self):
|
||||
repository = self._get_repository_client()
|
||||
|
|
|
@ -350,7 +350,7 @@ class GithubBuildTrigger(BuildTriggerHandler):
|
|||
commit_tree = repo.get_git_tree(default_commit.sha, recursive=True)
|
||||
|
||||
return [elem.path for elem in commit_tree.tree
|
||||
if (elem.type == u'blob' and self.path_is_dockerfile(os.path.basename(elem.path)))]
|
||||
if (elem.type == u'blob' and self.filename_is_dockerfile(os.path.basename(elem.path)))]
|
||||
except GithubException as ghe:
|
||||
message = ghe.data.get('message', 'Unable to list contents of repository: %s' % source)
|
||||
if message == 'Branch not found':
|
||||
|
@ -371,7 +371,7 @@ class GithubBuildTrigger(BuildTriggerHandler):
|
|||
raise RepositoryReadException(message)
|
||||
|
||||
path = self.get_dockerfile_path()
|
||||
if not path:
|
||||
if not path or not self.filename_is_dockerfile(os.path.basename(path)):
|
||||
return None
|
||||
|
||||
try:
|
||||
|
|
|
@ -342,7 +342,7 @@ class GitLabBuildTrigger(BuildTriggerHandler):
|
|||
msg = 'Unable to find GitLab repository tree for source: %s' % new_build_source
|
||||
raise RepositoryReadException(msg)
|
||||
|
||||
return ["/"+node['name'] for node in repo_tree if self.path_is_dockerfile(node['name'])]
|
||||
return ["/" + node['name'] for node in repo_tree if self.filename_is_dockerfile(node['name'])]
|
||||
|
||||
@_catch_timeouts
|
||||
def load_dockerfile_contents(self):
|
||||
|
|
|
@ -12,4 +12,4 @@ from buildtrigger.basehandler import BuildTriggerHandler
|
|||
(u"bad file name", False),
|
||||
])
|
||||
def test_path_is_dockerfile(input, output):
|
||||
assert BuildTriggerHandler.path_is_dockerfile(input) == output
|
||||
assert BuildTriggerHandler.filename_is_dockerfile(input) == output
|
||||
|
|
Reference in a new issue