Commit 47606bcf authored by Jelmer Vernooij's avatar Jelmer Vernooij

Obey git global and per-tree committer settings.

parent f9f402ad
......@@ -6,6 +6,7 @@ lintian-brush (0.2) UNRELEASED; urgency=medium
* Add --verbose option.
* Fix running of specific fixers.
* Add missing dependency on python3-dulwich. Closes: #912219
* Obey git global and per-tree committer settings.
-- Jelmer Vernooij <jelmer@debian.org> Sun, 28 Oct 2018 15:44:06 +0000
......
......@@ -28,6 +28,8 @@ import warnings
from breezy import ui
import breezy.bzr # noqa: F401
import breezy.git # noqa: F401
from breezy.clean_tree import (
iter_deletables,
)
......@@ -225,6 +227,22 @@ def delete_items(deletables, dry_run=False):
'unable to remove "{0}": {1}.'.format(path, e.strerror))
def get_committer(tree):
"""Get the committer string for a tree.
Args:
tree: A Tree object
Returns:
A committer string
"""
# TODO(jelmer): Perhaps this logic should be in Breezy?
if getattr(tree.branch.repository, '_git', None):
return tree.branch.repository._git._get_user_identity()
else:
config = tree.branch.get_config_stack()
return config.get('email')
def run_lintian_fixer(local_tree, fixer, update_changelog=True):
"""Run a lintian fixer on a tree.
......@@ -284,7 +302,8 @@ def run_lintian_fixer(local_tree, fixer, update_changelog=True):
"for more details.\n") % tag
local_tree.commit(description, allow_pointless=False,
reporter=NullCommitReporter())
reporter=NullCommitReporter(),
committer=get_committer(local_tree))
# TODO(jelmer): Run sbuild & verify lintian warning is gone?
return result.fixed_lintian_tags, summary
......
......@@ -220,6 +220,53 @@ Arch: all
[], list(self.tree.iter_changes(self.tree.basis_tree())))
class HonorsVcsCommitter(TestCaseWithTransport):
def make_package_tree(self, format):
tree = self.make_branch_and_tree('.', format=format)
self.build_tree_contents([
('debian/', ),
('debian/control', """\
Source: blah
Vcs-Git: https://example.com/blah
Testsuite: autopkgtest
Binary: blah
Arch: all
"""),
CHANGELOG_FILE])
tree.add(['debian', 'debian/changelog', 'debian/control'])
tree.commit('Initial thingy.')
return tree
def make_change(self, tree):
with tree.lock_write():
fixed_tags, summary = run_lintian_fixer(
tree, DummyFixer('dummy', 'some-tag'),
update_changelog=False)
self.assertEqual(summary, "Fixed some tag.")
self.assertEqual(['some-tag'], fixed_tags)
self.assertEqual(2, tree.branch.revno())
self.assertEqual(
tree.get_file_lines('debian/control')[-1],
b"a new line\n")
def test_honors_tree_committer_config(self):
tree = self.make_package_tree('git')
with open(os.path.join(tree.basedir, '.git/config'), 'w') as f:
f.write("""\
[user]
email = jane@example.com
name = Jane Example
""")
self.make_change(tree)
rev = tree.branch.repository.get_revision(tree.branch.last_revision())
self.assertEqual(rev.committer, 'Jane Example <jane@example.com>')
# TODO(jelmer): run_lintian_fixers
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment