/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/plugins/commitfromnews/__init__.py

  • Committer: Jelmer Vernooij
  • Date: 2017-06-13 00:17:21 UTC
  • mfrom: (0.191.3 trunk)
  • mto: This revision was merged to the branch mainline in revision 6739.
  • Revision ID: jelmer@jelmer.uk-20170613001721-1yi7xtlrrzmoxage
Bundle the commitfromnews plugin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2010 Canonical Ltd
 
2
#
 
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.
 
7
#
 
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.
 
12
#
 
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
 
16
 
 
17
"""bzr-commitfromnews - make commit messages from the changes in a NEWS file.
 
18
 
 
19
commitfromnews is enabled by default when installed.
 
20
 
 
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.
 
23
 
 
24
E.g.::
 
25
  $ echo "\n* new thing\n" >> NEWS
 
26
  $ bzr commit
 
27
  # editor pops open to let you tweak the message, and it starts with
 
28
    "* new thing" as the message to edit.
 
29
 
 
30
commitfromnews attempts to create a sensible default commit message by
 
31
including sections from a NEWS or ChangeLog file.
 
32
"""
 
33
 
 
34
from __future__ import absolute_import
 
35
 
 
36
from ... import msgeditor
 
37
 
 
38
 
 
39
def commit_template(commit, message):
 
40
    """Create a commit message for commit based on changes in the tree."""
 
41
    from .committemplate import CommitTemplate
 
42
    template = CommitTemplate(commit, message)
 
43
    return template.make()
 
44
 
 
45
 
 
46
def load_tests(loader, basic_tests, pattern):
 
47
    testmod_names = [
 
48
        'tests',
 
49
        ]
 
50
    basic_tests.addTest(loader.loadTestsFromModuleNames(
 
51
            ["%s.%s" % (__name__, tmn) for tmn in testmod_names]))
 
52
    return basic_tests
 
53
 
 
54
 
 
55
_registered = False
 
56
def register():
 
57
    """Register the plugin."""
 
58
    global _registered
 
59
    # Does not check registered because only tests call this, and they are
 
60
    # isolated.
 
61
    _registered = True
 
62
    msgeditor.hooks.install_named_hook('commit_message_template',
 
63
        commit_template, 'commitfromnews template')
 
64
 
 
65
register()