Skip to content

Commit

Permalink
rpm-ch: implement --all option
Browse files Browse the repository at this point in the history
If defined, rpm-ch uses all commits from the Git history. This can be
useful when creating a new changelog from scratch. Using '--all' causes
'--since' to be ignored.

Signed-off-by: Markus Lehtonen <[email protected]>
  • Loading branch information
marquiz committed Jan 22, 2018
1 parent 91fc213 commit 687b9af
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
11 changes: 11 additions & 0 deletions docs/manpages/gbp-rpm-ch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<arg><option>--changelog-file=</option><replaceable>FILEPATH</replaceable></arg>
<arg><option>--spec-file=</option><replaceable>FILEPATH</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>
Expand Down Expand Up @@ -161,6 +162,16 @@
</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>
Expand Down
9 changes: 7 additions & 2 deletions gbp/scripts/rpm_ch.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,9 @@ def guess_commit(section, repo, options):

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:
Expand All @@ -247,7 +249,7 @@ def get_start_commit(changelog, repo, options):
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'")
gbp.log.info("Continuing from commit '%s'" % since)
return since

Expand Down Expand Up @@ -441,6 +443,9 @@ def build_parser(name):
# 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",
Expand Down
10 changes: 10 additions & 0 deletions tests/component/rpm/test_rpm_ch.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ def test_create_changes_file(self):
# Should contain 3 lines (header, 1 entry and an empty line)
eq_(len(content), 3)

def test_option_all(self):
"""Test the --all cmdline option"""
repo = self.init_test_repo('gbp-test2')

eq_(mock_ch(['--changelog-file=CHANGES', '--all']), 0)
content = self.read_file('packaging/gbp-test2.changes')
# Should contain N+2 lines (header, N commits and an empty line)
commit_cnt = len(repo.get_commits(since=None, until='master'))
eq_(len(content), commit_cnt + 2)

def test_option_changelog_file(self):
"""Test the --changelog-file cmdline option"""
repo = self.init_test_repo('gbp-test-native')
Expand Down

0 comments on commit 687b9af

Please sign in to comment.