Skip to content

Commit ddffd01

Browse files
larsksJakub Ruzicka
authored andcommitted
allow patches remote and branch to be set in git config
this commit allows one to configure an explicit patches remote and patches branch by setting the 'rdopkg.<branch>.patches-remote' and 'rdopkg.<branch>.patches-branch' git configuration options. Change-Id: I74d58cd70867b29c06fea1ca261e3c4ccc1406f2
1 parent 05b2a5b commit ddffd01

File tree

2 files changed

+34
-11
lines changed

2 files changed

+34
-11
lines changed

doc/rdopkg.1.adoc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,15 @@ Use `rdopkg pkgenv` to check detected patches branch.
590590
You can specify remote patches branch by `-p`/`--patches-branch` action
591591
parameter for actions that use it, such as `patch` and `new-version`.
592592
593+
You may explicitly set the name of your patches remote and patches
594+
branch in your git configuration using the
595+
`rdopkg.<branch>.patches-remote` and `rdopkg.<branch>.patches-branch`
596+
options. For example, if you are working on a `dist-git` branch named
597+
`rhel-7.4` and you want to use `rhel-7-patches` for your patches
598+
branch, you would run:
599+
600+
git config rdopkg.rhel-7.4.patches-branch rhel-7-patches
601+
593602
patches base
594603
~~~~~~~~~~~~
595604

rdopkg/guess.py

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,14 @@ def version_tag_style(version=None):
9191

9292

9393
def find_patches_branch(distgit, remote):
94-
pb = '%s/%s-patches' % (remote, distgit)
94+
cfg_branch = git.config_get('rdopkg.%s.patches-branch' % distgit)
95+
96+
if cfg_branch:
97+
# if there is an explicitly configured patches branch, use it.
98+
pb = '%s/%s' % (remote, cfg_branch)
99+
else:
100+
pb = '%s/%s-patches' % (remote, distgit)
101+
95102
if git.ref_exists('refs/remotes/%s' % pb):
96103
return pb
97104
parts = distgit.split('-')[:-1]
@@ -104,17 +111,24 @@ def find_patches_branch(distgit, remote):
104111

105112

106113
def patches_branch(distgit, pkg=None, osdist='RDO'):
107-
remotes = ['patches']
108-
# support legacy remote names
109-
if osdist == 'RHOS':
110-
remotes.append('rhos')
114+
cfg_remote = git.config_get('rdopkg.%s.patches-remote' % distgit)
115+
116+
if cfg_remote:
117+
# if there is an explicitly configured remote, just use it.
118+
remotes = [cfg_remote]
111119
else:
112-
remotes.append('redhat-openstack')
113-
# support patches branch in the same remote
114-
remote_branch = git.remote_of_local_branch(distgit) or ''
115-
remote = remote_branch.partition('/')[0]
116-
if remote:
117-
remotes.append(remote)
120+
remotes = ['patches']
121+
# support legacy remote names
122+
if osdist == 'RHOS':
123+
remotes.append('rhos')
124+
else:
125+
remotes.append('redhat-openstack')
126+
127+
# support patches branch in the same remote
128+
remote_branch = git.remote_of_local_branch(distgit) or ''
129+
remote = remote_branch.partition('/')[0]
130+
if remote:
131+
remotes.append(remote)
118132

119133
for remote in remotes:
120134
pb = find_patches_branch(distgit, remote)

0 commit comments

Comments
 (0)