Skip to content

Commit 687b9af

Browse files
committed
rpm-ch: implement --all option
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]>
1 parent 91fc213 commit 687b9af

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

docs/manpages/gbp-rpm-ch.xml

+11
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<arg><option>--changelog-file=</option><replaceable>FILEPATH</replaceable></arg>
3030
<arg><option>--spec-file=</option><replaceable>FILEPATH</replaceable></arg>
3131
<group>
32+
<arg><option>--all</option></arg>
3233
<arg><option>--message=</option><replaceable>MESSAGE</replaceable></arg>
3334
<arg><option>--since=</option><replaceable>COMMITISH</replaceable></arg>
3435
</group>
@@ -161,6 +162,16 @@
161162
</para>
162163
</listitem>
163164
</varlistentry>
165+
<varlistentry>
166+
<term><option>--all</option>
167+
</term>
168+
<listitem>
169+
<para>
170+
Use all commits from the Git history, overrides
171+
<option>--since</option>.
172+
</para>
173+
</listitem>
174+
</varlistentry>
164175
<varlistentry>
165176
<term><option>--since=</option><replaceable>COMMITTISH</replaceable>
166177
</term>

gbp/scripts/rpm_ch.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,9 @@ def guess_commit(section, repo, options):
238238

239239
def get_start_commit(changelog, repo, options):
240240
"""Get the start commit from which to generate new entries"""
241-
if options.since:
241+
if options.all:
242+
since = None
243+
elif options.since:
242244
since = options.since
243245
else:
244246
if changelog.sections:
@@ -247,7 +249,7 @@ def get_start_commit(changelog, repo, options):
247249
since = None
248250
if not since:
249251
raise GbpError("Couldn't determine starting point from "
250-
"changelog, please use the '--since' option")
252+
"changelog, please use the '--since' or '--all'")
251253
gbp.log.info("Continuing from commit '%s'" % since)
252254
return since
253255

@@ -441,6 +443,9 @@ def build_parser(name):
441443
# Range group options
442444
range_grp.add_option("-s", "--since", dest="since",
443445
help="commit to start from (e.g. HEAD^^^, release/0.1.2)")
446+
range_grp.add_option("--all", action="store_true",
447+
help="use all commits from the Git history, overrides "
448+
"--since")
444449
# Formatting group options
445450
format_grp.add_option("--no-release", action="store_false", default=True,
446451
dest="release",

tests/component/rpm/test_rpm_ch.py

+10
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,16 @@ def test_create_changes_file(self):
109109
# Should contain 3 lines (header, 1 entry and an empty line)
110110
eq_(len(content), 3)
111111

112+
def test_option_all(self):
113+
"""Test the --all cmdline option"""
114+
repo = self.init_test_repo('gbp-test2')
115+
116+
eq_(mock_ch(['--changelog-file=CHANGES', '--all']), 0)
117+
content = self.read_file('packaging/gbp-test2.changes')
118+
# Should contain N+2 lines (header, N commits and an empty line)
119+
commit_cnt = len(repo.get_commits(since=None, until='master'))
120+
eq_(len(content), commit_cnt + 2)
121+
112122
def test_option_changelog_file(self):
113123
"""Test the --changelog-file cmdline option"""
114124
repo = self.init_test_repo('gbp-test-native')

0 commit comments

Comments
 (0)