Merging upstream version 0.15.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
470a4841cc
commit
3213982697
75 changed files with 1281 additions and 1555 deletions
|
@ -24,18 +24,18 @@ class HookTests(BaseTestCase):
|
|||
# The '--staged' flag used in the commit-msg hook fetches additional information from the underlying
|
||||
# git repo which means there already needs to be a commit in the repo
|
||||
# (as gitlint --staged doesn't work against empty repos)
|
||||
self.create_simple_commit(u"Commït Title\n\nCommit Body explaining commit.")
|
||||
self.create_simple_commit("Commït Title\n\nCommit Body explaining commit.")
|
||||
|
||||
# install git commit-msg hook and assert output
|
||||
output_installed = gitlint("install-hook", _cwd=self.tmp_git_repo)
|
||||
expected_installed = u"Successfully installed gitlint commit-msg hook in %s/.git/hooks/commit-msg\n" % \
|
||||
expected_installed = "Successfully installed gitlint commit-msg hook in %s/.git/hooks/commit-msg\n" % \
|
||||
self.tmp_git_repo
|
||||
self.assertEqualStdout(output_installed, expected_installed)
|
||||
|
||||
def tearDown(self):
|
||||
# uninstall git commit-msg hook and assert output
|
||||
output_uninstalled = gitlint("uninstall-hook", _cwd=self.tmp_git_repo)
|
||||
expected_uninstalled = u"Successfully uninstalled gitlint commit-msg hook from %s/.git/hooks/commit-msg\n" % \
|
||||
expected_uninstalled = "Successfully uninstalled gitlint commit-msg hook from %s/.git/hooks/commit-msg\n" % \
|
||||
self.tmp_git_repo
|
||||
self.assertEqualStdout(output_uninstalled, expected_uninstalled)
|
||||
|
||||
|
@ -50,24 +50,24 @@ class HookTests(BaseTestCase):
|
|||
# Answer 'yes' to question to keep violating commit-msg
|
||||
if "Your commit message contains the above violations" in line:
|
||||
response = self.responses[self.response_index]
|
||||
stdin.put("{0}\n".format(response))
|
||||
stdin.put(f"{response}\n")
|
||||
self.response_index = (self.response_index + 1) % len(self.responses)
|
||||
|
||||
def test_commit_hook_no_violations(self):
|
||||
test_filename = self.create_simple_commit(u"This ïs a title\n\nBody contënt that should work",
|
||||
test_filename = self.create_simple_commit("This ïs a title\n\nBody contënt that should work",
|
||||
out=self._interact, tty_in=True)
|
||||
|
||||
short_hash = self.get_last_commit_short_hash()
|
||||
expected_output = ["gitlint: checking commit message...\n",
|
||||
"gitlint: \x1b[32mOK\x1b[0m (no violations in commit message)\n",
|
||||
u"[master %s] This ïs a title\n" % short_hash,
|
||||
"[master %s] This ïs a title\n" % short_hash,
|
||||
" 1 file changed, 0 insertions(+), 0 deletions(-)\n",
|
||||
u" create mode 100644 %s\n" % test_filename]
|
||||
" create mode 100644 %s\n" % test_filename]
|
||||
self.assertListEqual(expected_output, self.githook_output)
|
||||
|
||||
def test_commit_hook_continue(self):
|
||||
self.responses = ["y"]
|
||||
test_filename = self.create_simple_commit(u"WIP: This ïs a title.\nContënt on the second line",
|
||||
test_filename = self.create_simple_commit("WIP: This ïs a title.\nContënt on the second line",
|
||||
out=self._interact, tty_in=True)
|
||||
|
||||
# Determine short commit-msg hash, needed to determine expected output
|
||||
|
@ -76,10 +76,10 @@ class HookTests(BaseTestCase):
|
|||
expected_output = self._violations()
|
||||
expected_output += ["Continue with commit anyways (this keeps the current commit message)? " +
|
||||
"[y(es)/n(no)/e(dit)] " +
|
||||
u"[master %s] WIP: This ïs a title. Contënt on the second line\n"
|
||||
"[master %s] WIP: This ïs a title. Contënt on the second line\n"
|
||||
% short_hash,
|
||||
" 1 file changed, 0 insertions(+), 0 deletions(-)\n",
|
||||
u" create mode 100644 %s\n" % test_filename]
|
||||
" create mode 100644 %s\n" % test_filename]
|
||||
|
||||
assert len(self.githook_output) == len(expected_output)
|
||||
for output, expected in zip(self.githook_output, expected_output):
|
||||
|
@ -89,7 +89,7 @@ class HookTests(BaseTestCase):
|
|||
|
||||
def test_commit_hook_abort(self):
|
||||
self.responses = ["n"]
|
||||
test_filename = self.create_simple_commit(u"WIP: This ïs a title.\nContënt on the second line",
|
||||
test_filename = self.create_simple_commit("WIP: This ïs a title.\nContënt on the second line",
|
||||
out=self._interact, ok_code=1, tty_in=True)
|
||||
git("rm", "-f", test_filename, _cwd=self.tmp_git_repo)
|
||||
|
||||
|
@ -101,8 +101,8 @@ class HookTests(BaseTestCase):
|
|||
"Commit aborted.\n",
|
||||
"Your commit message: \n",
|
||||
"-----------------------------------------------\n",
|
||||
u"WIP: This ïs a title.\n",
|
||||
u"Contënt on the second line\n",
|
||||
"WIP: This ïs a title.\n",
|
||||
"Contënt on the second line\n",
|
||||
"-----------------------------------------------\n"]
|
||||
|
||||
self.assertListEqual(expected_output, self.githook_output)
|
||||
|
@ -110,7 +110,7 @@ class HookTests(BaseTestCase):
|
|||
def test_commit_hook_edit(self):
|
||||
self.responses = ["e", "y"]
|
||||
env = {"EDITOR": ":"}
|
||||
test_filename = self.create_simple_commit(u"WIP: This ïs a title.\nContënt on the second line",
|
||||
test_filename = self.create_simple_commit("WIP: This ïs a title.\nContënt on the second line",
|
||||
out=self._interact, env=env, tty_in=True)
|
||||
git("rm", "-f", test_filename, _cwd=self.tmp_git_repo)
|
||||
|
||||
|
@ -124,9 +124,9 @@ class HookTests(BaseTestCase):
|
|||
expected_output += self._violations()[1:]
|
||||
expected_output += ['Continue with commit anyways (this keeps the current commit message)? ' +
|
||||
"[y(es)/n(no)/e(dit)] " +
|
||||
u"[master %s] WIP: This ïs a title. Contënt on the second line\n" % short_hash,
|
||||
"[master %s] WIP: This ïs a title. Contënt on the second line\n" % short_hash,
|
||||
" 1 file changed, 0 insertions(+), 0 deletions(-)\n",
|
||||
u" create mode 100644 %s\n" % test_filename]
|
||||
" create mode 100644 %s\n" % test_filename]
|
||||
|
||||
assert len(self.githook_output) == len(expected_output)
|
||||
for output, expected in zip(self.githook_output, expected_output):
|
||||
|
@ -147,7 +147,7 @@ class HookTests(BaseTestCase):
|
|||
```
|
||||
"""
|
||||
tmp_git_repo = self.create_tmp_git_repo()
|
||||
self.create_simple_commit(u"Simple title\n\nContënt in the body", git_repo=tmp_git_repo)
|
||||
self.create_simple_commit("Simple title\n\nContënt in the body", git_repo=tmp_git_repo)
|
||||
|
||||
worktree_dir = self.generate_temp_path()
|
||||
self.tmp_git_repos.append(worktree_dir) # make sure we clean up the worktree afterwards
|
||||
|
@ -156,10 +156,10 @@ class HookTests(BaseTestCase):
|
|||
|
||||
output_installed = gitlint("install-hook", _cwd=worktree_dir)
|
||||
expected_hook_path = os.path.join(tmp_git_repo, ".git", "hooks", "commit-msg")
|
||||
expected_msg = "Successfully installed gitlint commit-msg hook in {0}\n".format(expected_hook_path)
|
||||
expected_msg = f"Successfully installed gitlint commit-msg hook in {expected_hook_path}\r\n"
|
||||
self.assertEqual(output_installed, expected_msg)
|
||||
|
||||
output_uninstalled = gitlint("uninstall-hook", _cwd=worktree_dir)
|
||||
expected_hook_path = os.path.join(tmp_git_repo, ".git", "hooks", "commit-msg")
|
||||
expected_msg = "Successfully uninstalled gitlint commit-msg hook from {0}\n".format(expected_hook_path)
|
||||
expected_msg = f"Successfully uninstalled gitlint commit-msg hook from {expected_hook_path}\r\n"
|
||||
self.assertEqual(output_uninstalled, expected_msg)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue