Skip to content

Commit f19034b

Browse files
author
Jakub Ruzicka
committed
patch: new -B/--no-bump option to only sync patches
New -B/--no-bump option makes rdopkg patch only update patches from patches branch without bumping .spec Release and generating %changelog. You can use it with -l/--local-patches to get behavior of deprecated update-patches: rdopkg patch --no-bump --local-patches is an equivalent of deprecated rdopkg update-patches but with extra benefits of rdopkg patch, such as ability to operate on both local and remote patches branch. Also update manual and references from `rdopkg update-patches`. Change-Id: Id15c0d872f3fcef4f4f6c75a299951a813c02c58
1 parent bdb4b6d commit f19034b

File tree

4 files changed

+41
-15
lines changed

4 files changed

+41
-15
lines changed

doc/rdopkg.1.adoc

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,15 @@ Introduce new patches to the package.
9999

100100
This action works with patches branch
101101
(see <<patches-branch,AUTOMAGIC -> patches branch>>).
102+
102103
By default, `rdopkg` resets local patches branch to remote patches branch.
103-
You can skip this this with `--local-patches` to directly use local patches
104-
branch as is.
104+
You can skip this this with `-l`/`--local-patches` to directly use local
105+
patches branch as is.
105106

106107
Don't forget to `git fetch` before running the action.
107108

108-
After running `rdopkg patch`, new commit will contain the changes.
109+
After running `rdopkg patch`, new commit will contain the changes if there are
110+
any.
109111

110112
You can use `-C`/`--changelog` option to select how `rdopkg` detects new/old
111113
patches and changelog message:
@@ -115,13 +117,21 @@ patches and changelog message:
115117
removal & addition of patches and rewriting -patches history)
116118
* `plain`: just use generic "- Update patches" message
117119

120+
Or you can use `-B`/`--no-bump` to skip Release bump and changelog generation
121+
and only update patch files and their references in the .spec file. This is
122+
useful when you only need to align distgit with patches branch.
123+
118124
*Flow:*
119125

120126
* Unless `-l`/`--local-patches` was used, reset local patches branch to
121127
remote patches branch.
122-
* Update .spec file: bump Release, create new %changelog entry with new
123-
patches' titles and create a commit.
124-
* Update patches from local patches branch (`update-patches` action)
128+
* Update patch files from local patches branch.
129+
* Update .spec file with correct patch files references.
130+
* Unless `-B`/`--no-bump` was used, update .spec file: bump Release, create
131+
new %changelog entry with new patches' titles depending on
132+
`-C`/`--changelog` option.
133+
* Create new commit with the changes using %changelog to generate commit
134+
message if available.
125135
* Display the diff.
126136

127137
ACTION: new-version

rdopkg/actions/distgit/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@
7070
help="top gerrit review id of the patch chain"),
7171
Arg('force', shortcut='-f', action='store_true',
7272
help="use patch even if it was not validated in CI"),
73+
Arg('no_bump', shortcut='-B', action='store_true',
74+
help="don't bump release and generate changelog "
75+
"(update patches only)"),
7376
Arg('changelog', shortcut='-C',
7477
choices=['detect', 'count', 'plain'],
7578
help="how to generate changelog from patches"),
@@ -140,8 +143,7 @@
140143
description=(
141144
"WARNING: This is a low-level action for backward "
142145
"compatibility with ancient update-patches.sh script.\n\n"
143-
"Please use `rdopkg patch [--local-patches]` instead.\n\n"
144-
"This action is deprecated and will be removed eventually."),
146+
"Please use `rdopkg patch -lB` instead.\n\n"),
145147
steps=[
146148
Action('update_patches_deprecated'),
147149
Action('get_package_env'),

rdopkg/actions/distgit/actions.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,10 @@ def rebase_patches_branch(new_version, local_patches_branch,
512512
def check_new_patches(version, local_patches_branch,
513513
patches_style=None, local_patches=False,
514514
patches_branch=None, changes=None,
515-
version_tag_style=None, changelog=None):
515+
version_tag_style=None, changelog=None,
516+
no_bump=False):
517+
if no_bump:
518+
return
516519
if not changes:
517520
changes = []
518521
if changelog:
@@ -615,7 +618,11 @@ def get_upstream_patches(version, local_patches_branch,
615618

616619
def update_spec(branch=None, changes=None,
617620
new_rpm_version=None, new_release=None,
618-
new_milestone=None, new_patches_base=None):
621+
new_milestone=None, new_patches_base=None,
622+
no_bump=False):
623+
624+
if no_bump:
625+
return
619626
if not changes:
620627
changes = []
621628
_ensure_branch(branch)
@@ -908,7 +915,5 @@ def update_patches_deprecated():
908915
msg = ("\n{t.warn}DEPRECATION WARNING{t.normal}\n\n"
909916
"This is a low-level action for backward "
910917
"compatibility with ancient update-patches.sh script.\n\n"
911-
"Please use {t.cmd}rdopkg patch [--local-patches]{t.normal} "
912-
"instead.\n\n"
913-
"This action is deprecated and will be removed eventually.\n")
918+
"Please use {t.cmd}rdopkg patch -lB{t.normal} instead.\n\n")
914919
print(msg.format(t=log.term))

tests/test_patch.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,11 @@ def test_patch_noop_plain(tmpdir):
137137
_test_patch_noop(tmpdir, 'patched', ['patch', '-l', '-C', 'plain'])
138138

139139

140-
def _test_patch_regen(tmpdir, distgit, distgit_after, cmd):
140+
def test_patch_noop_no_bump(tmpdir):
141+
_test_patch_noop(tmpdir, 'patched', ['patch', '-l', '--no-bump'])
142+
143+
144+
def _test_patch_regen(tmpdir, distgit, distgit_after, cmd, norm_changelog=True):
141145
dist_path = common.prep_spec_test(tmpdir, distgit)
142146
with dist_path.as_cwd():
143147
common.prep_patches_branch()
@@ -146,7 +150,8 @@ def _test_patch_regen(tmpdir, distgit, distgit_after, cmd):
146150
rdopkg(*cmd)
147151
commit_after = git('rev-parse', 'HEAD')
148152
git_clean = git.is_clean()
149-
common.norm_changelog()
153+
if norm_changelog:
154+
common.norm_changelog()
150155
common.assert_distgit(dist_path, distgit_after)
151156
assert commit_before != commit_after, "New commit not created after patch regen"
152157
assert git_clean, "git not clean after action"
@@ -166,3 +171,7 @@ def test_patch_regen_count(tmpdir):
166171

167172
def test_patch_regen_plain(tmpdir):
168173
_test_patch_regen(tmpdir, 'patched', 'patched-regen', ['patch', '-l', '--changelog', 'plain'])
174+
175+
176+
def test_patch_regen_no_bump(tmpdir):
177+
_test_patch_regen(tmpdir, 'patched', 'patched', ['patch', '-l', '--no-bump'], norm_changelog=False)

0 commit comments

Comments
 (0)