diff --git a/docs/manpages/gbp-rpm-ch.xml b/docs/manpages/gbp-rpm-ch.xml
index 70cc28bf..86e4c766 100644
--- a/docs/manpages/gbp-rpm-ch.xml
+++ b/docs/manpages/gbp-rpm-ch.xml
@@ -28,7 +28,10 @@
DIRECTORYFILEPATHFILEPATH
- COMMITISH
+
+ MESSAGE
+ COMMITISH
+
@@ -270,6 +273,17 @@
+
+
+
+
+
+ Text to use for new changelog entries. Git history and the commit
+ messages, including and
+ options are ignored in this case.
+
+
+
diff --git a/gbp/scripts/rpm_ch.py b/gbp/scripts/rpm_ch.py
index 298fd646..0ceb3093 100644
--- a/gbp/scripts/rpm_ch.py
+++ b/gbp/scripts/rpm_ch.py
@@ -291,6 +291,37 @@ def entries_from_commits(changelog, repo, commits, options):
return entries
+def entries_from_text(changelog, text, author):
+ """Generate a list of changelog entries from a string"""
+ entries = []
+ # Use current user as the author for all entries
+ for line in text.splitlines():
+ if line.strip():
+ entry_text = "- %s" % line.strip()
+ entries.append(changelog.create_entry(author=author,
+ text=entry_text))
+ return entries
+
+
+def generate_new_entries(changelog, repo, options, args):
+ """Generate new entries to be appended to changelog"""
+ if options.message:
+ author = get_author(repo, options.git_author)[0]
+ entries = entries_from_text(changelog, options.message, author)
+ else:
+ # Get range of commits from where to generate changes
+ since = get_start_commit(changelog, repo, options)
+ if args:
+ gbp.log.info("Only looking for changes in '%s'" % ", ".join(args))
+ commits = repo.get_commits(since=since, until='HEAD', paths=args,
+ options=options.git_log.split(" "))
+ commits.reverse()
+ if not commits:
+ gbp.log.info("No changes detected from %s to %s." % (since, 'HEAD'))
+ entries = entries_from_commits(changelog, repo, commits, options)
+ return entries
+
+
def update_changelog(changelog, entries, repo, spec, options):
"""Update the changelog with a range of commits"""
# Get info for section header
@@ -431,6 +462,9 @@ def build_parser(name):
dest="spawn_editor")
format_grp.add_config_file_option(option_name="editor-cmd",
dest="editor_cmd")
+ format_grp.add_option("-m", '--message',
+ help="text to use as new changelog entries - git commit "
+ "messages and the --since are ignored in this case")
# Commit/tag group options
commit_grp.add_option("-c", "--commit", action="store_true",
help="commit changes")
@@ -485,27 +519,18 @@ def main(argv):
# Find and parse changelog file
ch_file = parse_changelog_file(repo, spec, options)
- since = get_start_commit(ch_file.changelog, repo, options)
- # Get range of commits from where to generate changes
- if args:
- gbp.log.info("Only looking for changes in '%s'" % ", ".join(args))
- commits = repo.get_commits(since=since, until='HEAD', paths=args,
- options=options.git_log.split(" "))
- commits.reverse()
- if not commits:
- gbp.log.info("No changes detected from %s to %s." % (since, 'HEAD'))
+ # Get new entries
+ entries = generate_new_entries(ch_file.changelog, repo, options, args)
# Do the actual update
- entries = entries_from_commits(ch_file.changelog, repo, commits,
- options)
tag, tag_msg, author, committer = update_changelog(ch_file.changelog,
entries, repo, spec,
options)
# Write to file
ch_file.write()
- if editor_cmd:
+ if editor_cmd and not options.message:
gbpc.Command(editor_cmd, [ch_file.path])()
if options.commit:
diff --git a/tests/component/rpm/test_rpm_ch.py b/tests/component/rpm/test_rpm_ch.py
index bc57d8be..91c2358b 100644
--- a/tests/component/rpm/test_rpm_ch.py
+++ b/tests/component/rpm/test_rpm_ch.py
@@ -343,6 +343,17 @@ def test_option_editor_cmd(self):
eq_(mock_ch(['--spawn-editor=always', '--editor-cmd=']),
0)
+ def test_option_message(self):
+ """Test the --message cmdline option"""
+ self.init_test_repo('gbp-test-native')
+ orig_content = self.read_file('packaging/gbp-test-native.changes')
+
+ eq_(mock_ch(['--message', 'my entry\nanother entry']), 0)
+ content = self.read_file('packaging/gbp-test-native.changes')
+ # Added header, two entries and a blank line
+ eq_(len(content), len(orig_content) + 4)
+ eq_(content[2], '- another entry\n')
+
def test_user_customizations(self):
"""Test the user customizations"""
repo = self.init_test_repo('gbp-test-native')