mirror of
https://git.centos.org/centos-git-common.git
synced 2025-02-23 16:22:56 +00:00
Added switch to filter output based on branch, add license string
This commit is contained in:
parent
c6c34b1881
commit
a6a2bc047e
1 changed files with 25 additions and 9 deletions
|
@ -1,4 +1,11 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
#
|
||||||
|
# License: GPLv3
|
||||||
|
#
|
||||||
|
# Initial Author: Bonnie King <bonniek@fnal.gov>
|
||||||
|
# Updates:
|
||||||
|
# Pat Riehecky <riehecky@fnal.gov>
|
||||||
|
#
|
||||||
'''Get list of repos from gitblit RPC, to grab CentOS sources'''
|
'''Get list of repos from gitblit RPC, to grab CentOS sources'''
|
||||||
|
|
||||||
import optparse
|
import optparse
|
||||||
|
@ -22,36 +29,45 @@ def read_args():
|
||||||
help='''project path (default 'rpms', could be 'all', 'core-sig'...)''',
|
help='''project path (default 'rpms', could be 'all', 'core-sig'...)''',
|
||||||
default='rpms')
|
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>",
|
parser.add_option('-u', '--url', metavar="<URL>",
|
||||||
help='URL to check (default %s)' % (RPCURL),
|
help='URL to check (default %s)' % (RPCURL),
|
||||||
default = RPCURL
|
default = RPCURL)
|
||||||
)
|
|
||||||
|
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
return options
|
return options
|
||||||
|
|
||||||
def get_repo_list(url, projectpath):
|
def get_repo_list(url, branch, projectpath):
|
||||||
'''return a list of repo URLs'''
|
'''return a list of repo URLs'''
|
||||||
try:
|
try:
|
||||||
req = requests.get(url)
|
req = requests.get(url)
|
||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.RequestException as err_msg:
|
||||||
print e
|
print err_msg
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
payload = req.text
|
payload = req.text
|
||||||
repos = json.loads(payload)
|
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:
|
if repos[repo]['projectPath'] != projectpath:
|
||||||
del repos[repo]
|
del repos[repo]
|
||||||
|
continue
|
||||||
|
if branchname not in repos[repo]['availableRefs']:
|
||||||
|
del repos[repo]
|
||||||
|
|
||||||
return repos.keys()
|
return repos.keys()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
'''Broken out so it can be inherited if someone wants'''
|
||||||
options = read_args()
|
options = read_args()
|
||||||
repos = get_repo_list(url=options.url, projectpath=options.project)
|
repos = get_repo_list(url=options.url, branch=options.branch, projectpath=options.project)
|
||||||
print '\n'.join(repos)
|
if repos:
|
||||||
|
print '\n'.join(repos)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Add table
Reference in a new issue