Commit 4fa051ae authored by André Anjos's avatar André Anjos 💬
Browse files

[scripts][visibility] Add script to check for repo visibility

parent 017f8e87
#!/usr/bin/env python
import os
import sys
import click
import gitlab
from . import bdt
from ..release import get_gitlab_instance
@click.command(context_settings=dict(
ignore_unknown_options=True,
allow_extra_args=True,
),
epilog='''
Examples:
1. Check the visibility of a package you can access
$ bdt -vvv visibility bob/bob.extension
2. Checks the visibility of all packages in a file list:
\b
$ curl -o order.txt https://gitlab.idiap.ch/bob/bob.nightlies/raw/master/order.txt
$ bdt -vvv visibility order.txt
''')
@click.argument('target')
@click.option('-g', '--group', default='bob', show_default=True,
help='Gitlab default group name where packages are located (if not ' \
'specified using a "/" on the package name - e.g. ' \
'"bob/bob.extension")')
@bdt.raise_on_error
def visibility(target, group):
"""Checks if the gitlab repository is visible to the current user
This command checks if the named package is visible to the currently logged
in user, and reports its visibility level ('public', 'internal',
'private'). If the package does not exist or it is private to the current
user, it says 'unknown' instead.
"""
gl = get_gitlab_instance()
# reads package list or considers name to be a package name
if os.path.exists(target) and os.path.isfile(target):
bdt.logger.info('Reading package names from file %s...', target)
with open(target, 'rt') as f:
packages = [k.strip() for k in f.readlines() if k.strip() and not \
k.strip().startswith('#')]
else:
bdt.logger.info('Assuming %s is a package name (file does not ' \
'exist)...', target)
packages = [target]
# iterates over the packages and dumps required information
for package in packages:
if '/' not in package:
package = '/'.join((group, package))
# retrieves the gitlab package object
try:
use_package = gl.projects.get(package)
bdt.logger.info('Found gitlab project %s (id=%d)',
use_package.attributes['path_with_namespace'], use_package.id)
click.echo('%s: %s' % (package,
use_package.attributes['visibility'].lower()))
except gitlab.GitlabGetError as e:
bdt.logger.warn('Gitlab access error - package %s does not exist?',
package)
click.echo('%s: unknown' % (package,))
......@@ -83,15 +83,19 @@ Releasing the Bob meta package
Here are the instructions to release Bob meta package:
* Run ./check_private.sh bob.buildout bob.extension ...
with the list of packages from `bob/bob.nightlies' "order.txt"
<https://gitlab.idiap.ch/bob/bob.nightlies/blob/master/order.txt>`_
* Run:
.. code-block:: sh
$ curl -o order.txt https://gitlab.idiap.ch/bob/bob.nightlies/raw/master/order.txt
$ bdt -vvv visibility order.txt
* Put the list of public packages in ../../bob/requirements.txt
* Run ``bdt changelog`` first:
.. code-block:: sh
$ bdt changelog -l ../../bob/requirements.txt -R -- TOKEN | tee bob_changelog.md
$ bdt changelog ../../bob/requirements.txt bob_changelog.md
* Put the beta of version of the intended release version in
``../../bob/version.txt``
......
......@@ -41,11 +41,12 @@ setup(
'release = bob.devtools.scripts.release:release',
'changelog = bob.devtools.scripts.changelog:changelog',
'lasttag = bob.devtools.scripts.lasttag:lasttag',
'visibility = bob.devtools.scripts.visibility:visibility',
],
},
classifiers=[
'Framework :: Bob',
'Development Status :: 5 - Production/Stable',
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Natural Language :: English',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment