diff --git a/buildtrigger/basehandler.py b/buildtrigger/basehandler.py index 64647e06c..a929ead8b 100644 --- a/buildtrigger/basehandler.py +++ b/buildtrigger/basehandler.py @@ -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 .Dockerfile""" return file_name.endswith(".Dockerfile") or u"Dockerfile" == file_name diff --git a/buildtrigger/bitbuckethandler.py b/buildtrigger/bitbuckethandler.py index 68290cde4..84818d61c 100644 --- a/buildtrigger/bitbuckethandler.py +++ b/buildtrigger/bitbuckethandler.py @@ -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() diff --git a/buildtrigger/githubhandler.py b/buildtrigger/githubhandler.py index f6687798e..072af6e03 100644 --- a/buildtrigger/githubhandler.py +++ b/buildtrigger/githubhandler.py @@ -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: diff --git a/buildtrigger/gitlabhandler.py b/buildtrigger/gitlabhandler.py index 0bd47c910..522f51329 100644 --- a/buildtrigger/gitlabhandler.py +++ b/buildtrigger/gitlabhandler.py @@ -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): diff --git a/buildtrigger/test/test_basehandler.py b/buildtrigger/test/test_basehandler.py index d8955740a..5bf95c41b 100644 --- a/buildtrigger/test/test_basehandler.py +++ b/buildtrigger/test/test_basehandler.py @@ -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