diff --git a/bob/devtools/scripts/visibility.py b/bob/devtools/scripts/visibility.py new file mode 100644 index 0000000000000000000000000000000000000000..0ef0bc18e5bf758774c5d3045d6a163fdbc423f7 --- /dev/null +++ b/bob/devtools/scripts/visibility.py @@ -0,0 +1,75 @@ +#!/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,)) diff --git a/doc/release.rst b/doc/release.rst index 7e1c393668f7fbcd8e3fcb54aa4b0501bd06a498..595aa4ff0c68b03b7a56f976972d1821f4b18ec3 100644 --- a/doc/release.rst +++ b/doc/release.rst @@ -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`` diff --git a/setup.py b/setup.py index 2ca9417cf117ad8787f5cd8feb2f8dad7a34a5a0..86d4b7a8f96c786eda75a8f03aaa9f9e40ac7e6b 100644 --- a/setup.py +++ b/setup.py @@ -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',