[CentOS-devel] [PATCH] Added branch filtering lines
Johnny Hughes
johnny at centos.org
Tue Jun 24 09:19:52 UTC 2014
commited
On 06/23/2014 10:19 AM, Pat Riehecky wrote:
> From: Pat Riehecky <riehecky at fnal.gov>
>
> ---
> centos.git.repolist.py | 34 +++++++++++++++++++++++++---------
> 1 files changed, 25 insertions(+), 9 deletions(-)
>
> diff --git a/centos.git.repolist.py b/centos.git.repolist.py
> index 908530d..75122ae 100755
> --- a/centos.git.repolist.py
> +++ b/centos.git.repolist.py
> @@ -1,4 +1,11 @@
> #!/usr/bin/env python
> +#
> +# License: GPLv3
> +#
> +# Initial Author: Bonnie King <bonniek at fnal.gov>
> +# Updates:
> +# Pat Riehecky <riehecky at fnal.gov>
> +#
> '''Get list of repos from gitblit RPC, to grab CentOS sources'''
>
> import optparse
> @@ -22,36 +29,45 @@ def read_args():
> help='''project path (default 'rpms', could be 'all', 'core-sig'...)''',
> default='rpms')
>
> + parser.add_option('-b', '--branch', metavar="<branch name>",
> + help='Only list repos with this branch (default master)',
> + default = 'master')
> +
> parser.add_option('-u', '--url', metavar="<URL>",
> help='URL to check (default %s)' % (RPCURL),
> - default = RPCURL
> - )
> + default = RPCURL)
>
> (options, args) = parser.parse_args()
> return options
>
> -def get_repo_list(url, projectpath):
> +def get_repo_list(url, branch, projectpath):
> '''return a list of repo URLs'''
> try:
> req = requests.get(url)
> - except requests.exceptions.RequestException as e:
> - print e
> + except requests.exceptions.RequestException as err_msg:
> + print err_msg
> sys.exit(1)
>
> payload = req.text
> repos = json.loads(payload)
> + branchname = 'refs/heads/' + branch
>
> - if projectpath != 'all':
> - for repo in repos.keys():
> + for repo in repos.keys():
> + if projectpath != 'all':
> if repos[repo]['projectPath'] != projectpath:
> del repos[repo]
> + continue
> + if branchname not in repos[repo]['availableRefs']:
> + del repos[repo]
>
> return repos.keys()
>
> def main():
> + '''Broken out so it can be inherited if someone wants'''
> options = read_args()
> - repos = get_repo_list(url=options.url, projectpath=options.project)
> - print '\n'.join(repos)
> + repos = get_repo_list(url=options.url, branch=options.branch, projectpath=options.project)
> + if repos:
> + print '\n'.join(repos)
>
> if __name__ == "__main__":
> main()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
URL: <http://lists.centos.org/pipermail/centos-devel/attachments/20140624/b0720ebd/attachment.sig>
More information about the CentOS-devel
mailing list