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
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:
$ curl -o order.txt
$ bdt -vvv visibility order.txt
@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. ' \
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):'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 \
else:'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
use_package = gl.projects.get(package)'Found gitlab project %s (id=%d)',
click.echo('%s: %s' % (package,
except gitlab.GitlabGetError as e:
bdt.logger.warn('Gitlab access error - package %s does not exist?',
click.echo('%s: unknown' % (package,))
......@@ -83,15 +83,19 @@ Releasing the Bob meta package
Here are the instructions to release Bob meta package:
* Run ./ bob.buildout bob.extension ...
with the list of packages from `bob/bob.nightlies' "order.txt"
* Run:
.. code-block:: sh
$ curl -o 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
$ bdt changelog ../../bob/requirements.txt
* Put the beta of version of the intended release version in
......@@ -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',
'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