1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# Copyright (C) 2010 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
"""bzr-commitfromnews - make commit messages from the changes in a NEWS file.
commitfromnews is enabled by default when installed.
To use, set the ``commit.template_from_files`` setting to a path and
just do a commit where the NEWS file for your project has a new section
added without providing a message to commit.
E.g.::
$ echo "commit.template_from_files = NEWS" >> .bzr/branch/branch.conf
$ echo "\n* new thing\n" >> NEWS
$ bzr commit
# editor pops open to let you tweak the message, and it starts with
"* new thing" as the message to edit.
commitfromnews attempts to create a sensible default commit message by
including sections from a NEWS or ChangeLog file.
"""
from __future__ import absolute_import
from ... import hooks
from ...config import (
option_registry,
ListOption,
)
option_registry.register(
ListOption('commit.template_from_files', default=[], help="""\
List of fnmatch(2)-style shell file patterns to use when creating commit
templates.
"""))
def commit_template(commit, message):
"""Create a commit message for commit based on changes in the tree."""
config_stack = commit.work_tree.get_config_stack()
filespec = config_stack.get('commit.template_from_files')
if filespec:
from .committemplate import CommitTemplate
template = CommitTemplate(commit, message, filespec)
return template.make()
return message
def load_tests(loader, basic_tests, pattern):
testmod_names = [
'tests',
]
basic_tests.addTest(loader.loadTestsFromModuleNames(
["%s.%s" % (__name__, tmn) for tmn in testmod_names]))
return basic_tests
_registered = False
def register():
"""Register the plugin."""
global _registered
# Does not check registered because only tests call this, and they are
# isolated.
_registered = True
hooks.install_lazy_named_hook(
'breezy.msgeditor', 'hooks',
'commit_message_template',
commit_template, 'commitfromnews template')
register()
|