text
stringlengths 0
828
|
|---|
# Make sure that the number of supplied values matches the number of
|
# corresponding values read from the channel.
|
assert(len(values) == len(original_values))
|
for i in range(len(original_values)):
|
if values[i] != original_values[i]:
|
write_f(channel, values[i], i)"
|
973,"def _get_files_modified():
|
""""""Get the list of modified files that are Python or Jinja2.""""""
|
cmd = ""git diff-index --cached --name-only --diff-filter=ACMRTUXB HEAD""
|
_, files_modified, _ = run(cmd)
|
extensions = [re.escape(ext) for ext in list(SUPPORTED_FILES) + ["".rst""]]
|
test = ""(?:{0})$"".format(""|"".join(extensions))
|
return list(filter(lambda f: re.search(test, f), files_modified))"
|
974,"def _get_git_author():
|
""""""Return the git author from the git variables.""""""
|
_, stdout, _ = run(""git var GIT_AUTHOR_IDENT"")
|
git_author = stdout[0]
|
return git_author[:git_author.find("">"") + 1]"
|
975,"def _get_component(filename, default=""global""):
|
""""""Get component name from filename.""""""
|
if hasattr(filename, ""decode""):
|
filename = filename.decode()
|
parts = filename.split(os.path.sep)
|
if len(parts) >= 3:
|
if parts[1] in ""modules legacy ext"".split():
|
return parts[2]
|
if len(parts) >= 2:
|
if parts[1] in ""base celery utils"".split():
|
return parts[1]
|
if len(parts) >= 1:
|
if parts[0] in ""grunt docs"".split():
|
return parts[0]
|
return default"
|
976,"def _prepare_commit_msg(tmp_file, author, files_modified=None, template=None):
|
""""""Prepare the commit message in tmp_file.
|
It will build the commit message prefilling the component line, as well
|
as the signature using the git author and the modified files.
|
The file remains untouched if it is not empty.
|
""""""
|
files_modified = files_modified or []
|
template = template or ""{component}:\n\nSigned-off-by: {author}\n{extra}""
|
if hasattr(template, ""decode""):
|
template = template.decode()
|
with open(tmp_file, ""r"", ""utf-8"") as fh:
|
contents = fh.readlines()
|
msg = filter(lambda x: not (x.startswith(""#"") or x.isspace()),
|
contents)
|
if len(list(msg)):
|
return
|
component = ""unknown""
|
components = _get_components(files_modified)
|
if len(components) == 1:
|
component = components[0]
|
elif len(components) > 1:
|
component = ""/"".join(components)
|
contents.append(
|
""# WARNING: Multiple components detected - consider splitting ""
|
""commit.\r\n""
|
)
|
with open(tmp_file, ""w"", ""utf-8"") as fh:
|
fh.write(template.format(component=component,
|
author=author,
|
extra="""".join(contents)))"
|
977,"def _check_message(message, options):
|
""""""Checking the message and printing the errors.""""""
|
options = options or dict()
|
options.update(get_options())
|
options.update(_read_local_kwalitee_configuration())
|
errors = check_message(message, **options)
|
if errors:
|
for error in errors:
|
print(error, file=sys.stderr)
|
return False
|
return True"
|
978,"def prepare_commit_msg_hook(argv):
|
""""""Hook: prepare a commit message.""""""
|
options = get_options()
|
# Check if the repo has a configuration repo
|
options.update(_read_local_kwalitee_configuration())
|
_prepare_commit_msg(argv[1],
|
_get_git_author(),
|
_get_files_modified(),
|
options.get('template'))
|
return 0"
|
979,"def commit_msg_hook(argv):
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.