本文整理汇总了Python中lintreview.diff.DiffCollection.get_files方法的典型用法代码示例。如果您正苦于以下问题:Python DiffCollection.get_files方法的具体用法?Python DiffCollection.get_files怎么用?Python DiffCollection.get_files使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lintreview.diff.DiffCollection
的用法示例。
在下文中一共展示了DiffCollection.get_files方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_files__two_files__append_base
# 需要导入模块: from lintreview.diff import DiffCollection [as 别名]
# 或者: from lintreview.diff.DiffCollection import get_files [as 别名]
def test_get_files__two_files__append_base(self):
changes = DiffCollection(self.two_files)
expected = [
"/some/path/Console/Command/Task/AssetBuildTask.php",
"/some/path/Test/test_files/View/Parse/single.ctp",
]
result = changes.get_files(append_base="/some/path/")
eq_(expected, result)
result = changes.get_files(append_base="/some/path")
eq_(expected, result)
示例2: Processor
# 需要导入模块: from lintreview.diff import DiffCollection [as 别名]
# 或者: from lintreview.diff.DiffCollection import get_files [as 别名]
class Processor(object):
def __init__(self, client, number, head, target_path):
self._client = client
self._number = number
self._head = head
self._target_path = target_path
self._changes = None
self._problems = Problems(target_path)
self._review = Review(client, number)
def load_changes(self):
log.info('Loading pull request patches from github.')
files = self._client.pull_requests.list_files(self._number)
pull_request_patches = files.all()
self._changes = DiffCollection(pull_request_patches)
self._problems.set_changes(self._changes)
def run_tools(self, review_config):
if self._changes is None:
raise RuntimeError('No loaded changes, cannot run tools. '
'Try calling load_changes first.')
files_to_check = self._changes.get_files(
append_base=self._target_path,
ignore_patterns=review_config.ignore_patterns())
tools.run(
review_config,
self._problems,
files_to_check,
self._target_path)
def publish(self, wait_time=0):
self._problems.limit_to_changes()
self._review.publish(self._problems, self._head, wait_time)
示例3: test_get_files__one_file
# 需要导入模块: from lintreview.diff import DiffCollection [as 别名]
# 或者: from lintreview.diff.DiffCollection import get_files [as 别名]
def test_get_files__one_file(self):
changes = DiffCollection(self.one_file)
result = changes.get_files()
expected = [
"View/Helper/AssetCompressHelper.php"
]
eq_(expected, result)
示例4: test_get_files__two_files
# 需要导入模块: from lintreview.diff import DiffCollection [as 别名]
# 或者: from lintreview.diff.DiffCollection import get_files [as 别名]
def test_get_files__two_files(self):
changes = DiffCollection(self.two_files)
result = changes.get_files()
expected = [
"Console/Command/Task/AssetBuildTask.php",
"Test/test_files/View/Parse/single.ctp",
]
eq_(expected, result)
示例5: test_get_files__two_files__ignore_pattern
# 需要导入模块: from lintreview.diff import DiffCollection [as 别名]
# 或者: from lintreview.diff.DiffCollection import get_files [as 别名]
def test_get_files__two_files__ignore_pattern(self):
changes = DiffCollection(self.two_files)
expected = [
"Console/Command/Task/AssetBuildTask.php",
]
ignore = ['Test/**']
result = changes.get_files(ignore_patterns=ignore)
self.assertEqual(expected, result)
示例6: test_get_files__ignore_pattern__multiple_wildcard
# 需要导入模块: from lintreview.diff import DiffCollection [as 别名]
# 或者: from lintreview.diff.DiffCollection import get_files [as 别名]
def test_get_files__ignore_pattern__multiple_wildcard(self):
data = load_fixture('multiple_wildcard_pull_request.json')
changes = DiffCollection(create_pull_files(data))
expected = [
"buildpacks/buildpack-ruby/tests/ruby-sinatra/test_web.rb",
]
ignore = ['buildpacks/*/tests/*/test.sh']
result = changes.get_files(ignore_patterns=ignore)
self.assertEqual(expected, result)
示例7: Processor
# 需要导入模块: from lintreview.diff import DiffCollection [as 别名]
# 或者: from lintreview.diff.DiffCollection import get_files [as 别名]
class Processor(object):
_client = None
_number = None
_head = None
_target_path = None
_changes = None
_problems = None
_review = None
_config = None
def __init__(self, client, number, head, target_path, config=None):
self._client = client
self._number = number
self._head = head
self._target_path = target_path
self._problems = Problems(target_path)
self._review = Review(client, number)
if config is None:
config = {}
self._config = config
def load_changes(self):
log.info('Loading pull request patches from github.')
files = self._client.pull_requests.list_files(self._number)
pull_request_patches = files.all()
self._changes = DiffCollection(pull_request_patches)
self._problems.set_changes(self._changes)
def run_tools(self, review_config):
if self._changes is None:
raise RuntimeError('No loaded changes, cannot run tools. '
'Try calling load_changes first.')
files_to_check = self._changes.get_files(
append_base=self._target_path,
ignore_patterns=review_config.ignore_patterns())
commits_to_check = self.get_commits(self._number)
tools.run(
review_config,
self._problems,
files_to_check,
commits_to_check,
self._target_path)
def publish(self):
self._problems.limit_to_changes()
self._review.publish(
self._problems,
self._head,
self._config.get('SUMMARY_THRESHOLD'))
def get_commits(self, number):
return self._client.pull_requests.list_commits(number).all()
示例8: Processor
# 需要导入模块: from lintreview.diff import DiffCollection [as 别名]
# 或者: from lintreview.diff.DiffCollection import get_files [as 别名]
class Processor(object):
_repository = None
_pull_request = None
_target_path = None
_changes = None
_problems = None
_review = None
_config = None
def __init__(self, repository, pull_request, target_path, config=None):
config = config if config else {}
self._config = config
self._repository = repository
self._pull_request = pull_request
self._target_path = target_path
self._problems = Problems(target_path)
self._review = Review(repository, pull_request, config)
def load_changes(self):
log.info('Loading pull request patches from github.')
files = self._pull_request.files()
self._changes = DiffCollection(files)
self._problems.set_changes(self._changes)
def run_tools(self, review_config):
if self._changes is None:
raise RuntimeError('No loaded changes, cannot run tools. '
'Try calling load_changes first.')
files_to_check = self._changes.get_files(
append_base=self._target_path,
ignore_patterns=review_config.ignore_patterns())
commits_to_check = self._pull_request.commits()
log.debug("_problems before tools: %s" % len(self._problems))
self._problems = tools.run(
review_config,
self._problems,
files_to_check,
commits_to_check,
self._target_path)
log.debug("_problems after tools: %s" % len(self._problems))
def publish(self):
self._problems.limit_to_changes()
self._review.publish(
self._problems,
self._pull_request.head,
self._config.get('SUMMARY_THRESHOLD'))
示例9: test_parsing_diffs__renamed_file_and_blob
# 需要导入模块: from lintreview.diff import DiffCollection [as 别名]
# 或者: from lintreview.diff.DiffCollection import get_files [as 别名]
def test_parsing_diffs__renamed_file_and_blob(self):
changes = DiffCollection(self.renamed_files)
self.assertEqual(0, len(changes),
'Should be no files as a blob and a rename happened')
self.assertEqual([], changes.get_files())
示例10: test_parsing_diffs_removed__file
# 需要导入模块: from lintreview.diff import DiffCollection [as 别名]
# 或者: from lintreview.diff.DiffCollection import get_files [as 别名]
def test_parsing_diffs_removed__file(self):
changes = DiffCollection(self.removed_files)
self.assertEqual(0, len(changes),
'Should be no files as the file was removed')
self.assertEqual([], changes.get_files())
示例11: Processor
# 需要导入模块: from lintreview.diff import DiffCollection [as 别名]
# 或者: from lintreview.diff.DiffCollection import get_files [as 别名]
class Processor(object):
_repository = None
_pull_request = None
_target_path = None
_changes = None
_review = None
_config = None
problems = None
def __init__(self, repository, pull_request, target_path, config):
self._config = config
self._repository = repository
self._pull_request = pull_request
self._target_path = target_path
self.problems = Problems()
self._review = Review(repository, pull_request, config)
def load_changes(self):
log.info('Loading pull request patches from github.')
files = self._pull_request.files()
self._changes = DiffCollection(files)
self.problems.set_changes(self._changes)
def run_tools(self):
if self._changes is None:
raise RuntimeError('No loaded changes, cannot run tools. '
'Try calling load_changes first.')
config = self._config
files_to_check = self._changes.get_files(
ignore_patterns=config.ignore_patterns()
)
commits_to_check = self._pull_request.commits()
tool_list = tools.factory(
config,
self.problems,
self._target_path)
if config.fixers_enabled():
self.apply_fixers(tool_list, files_to_check)
tools.run(tool_list, files_to_check, commits_to_check)
def apply_fixers(self, tool_list, files_to_check):
try:
fixer_context = fixers.create_context(
self._config,
self._target_path,
self._repository,
self._pull_request,
)
fixer_diff = fixers.run_fixers(
tool_list,
self._target_path,
files_to_check)
fixers.apply_fixer_diff(
self._changes,
fixer_diff,
fixer_context)
except (ConfigurationError, WorkflowError) as e:
log.info('Fixer application failed. Got %s', e)
message = u'Unable to apply fixers. {}'.format(e)
self.problems.add(InfoComment(message))
except Exception as e:
log.info('Fixer application failed, '
'rolling back working tree. Got %s', e)
fixers.rollback_changes(self._target_path)
def publish(self, check_run_id=None):
self.problems.limit_to_changes()
if check_run_id:
self._review.publish_checkrun(
self.problems,
check_run_id)
else:
self._review.publish_review(
self.problems,
self._pull_request.head)