<arg><option>--packaging-dir=</option><replaceable>DIRECTORY</replaceable></arg>
<arg><option>--changelog-file=</option><replaceable>FILEPATH</replaceable></arg>
<arg><option>--spec-file=</option><replaceable>FILEPATH</replaceable></arg>
- <arg><option>--since=</option><replaceable>COMMITISH</replaceable></arg>
+ <group>
+ <arg><option>--all</option></arg>
+ <arg><option>--message=</option><replaceable>MESSAGE</replaceable></arg>
+ <arg><option>--since=</option><replaceable>COMMITISH</replaceable></arg>
+ </group>
<arg><option>--no-release</option></arg>
<arg><option>--[no-]git-author</option></arg>
<arg><option>--[no-]full</option></arg>
</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>--all</option>
+ </term>
+ <listitem>
+ <para>
+ Use all commits from the Git history, overrides
+ <option>--since</option>.
+ </para>
+ </listitem>
+ </varlistentry>
<varlistentry>
<term><option>--since=</option><replaceable>COMMITTISH</replaceable>
</term>
</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>--message=<replaceable>MESSAGE</replaceable></option>
+ </term>
+ <listitem>
+ <para>
+ Text to use for new changelog entries. Git history and the commit
+ messages, including <option>--since</option> and
+ <option>--all</option> options are ignored in this case.
+ </para>
+ </listitem>
+ </varlistentry>
<varlistentry>
<term><option>--customizations=</option><replaceable>CUSTOMIZATION-FILE</replaceable>
</term>
def get_start_commit(changelog, repo, options):
"""Get the start commit from which to generate new entries"""
- if options.since:
+ if options.all:
+ since = None
+ elif options.since:
since = options.since
else:
if changelog.sections:
since = None
if not since:
raise GbpError("Couldn't determine starting point from "
- "changelog, please use the '--since' option")
+ "changelog, please use the '--since' or '--all' option")
gbp.log.info("Continuing from commit '%s'" % since)
return since
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
# Range group options
range_grp.add_option("-s", "--since", dest="since",
help="commit to start from (e.g. HEAD^^^, release/0.1.2)")
+ range_grp.add_option("--all", action="store_true",
+ help="use all commits from the Git history, overrides "
+ "--since")
# Formatting group options
format_grp.add_option("--no-release", action="store_false", default=True,
dest="release",
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")
return parser
# 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'))
# Do the actual update
- entries = entries_from_commits(ch_file.changelog, repo, commits,
- options)
+ entries = generate_new_entries(ch_file.changelog, repo, options, args)
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])()
except (GbpError, GitRepositoryError, ChangelogError, NoSpecError) as err: