1
# Copyright (C) 2010 Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
"""bzr-commitfromnews - make commit messages from the changes in a NEWS file.
19
commitfromnews is enabled by default when installed.
21
To use, just do a commit where the NEWS file for your project has a new section
22
added without providing a message to commit.
25
$ echo "\n* new thing\n" >> NEWS
27
# editor pops open to let you tweak the message, and it starts with
28
"* new thing" as the message to edit.
30
commitfromnews attempts to create a sensible default commit message by
31
including sections from a NEWS or ChangeLog file.
34
from bzrlib import msgeditor
37
def commit_template(commit, message):
38
"""Create a commit message for commit based on changes in the tree."""
39
from committemplate import CommitTemplate
40
template = CommitTemplate(commit, message)
41
return template.make()
44
def load_tests(standard_tests, module, loader):
45
return loader.loadTestsFromModuleNames(
46
['bzrlib.plugins.commitfromnews.tests'])
51
"""Register the plugin."""
53
# Does not check registered because only tests call this, and they are
56
msgeditor.hooks.install_named_hook('commit_message_template',
57
commit_template, 'commitfromnews template')