Skip to content
Snippets Groups Projects
Commit 92870c19 authored by Karl Fogel's avatar Karl Fogel
Browse files

Browse a single project's issues

parent 46cfbfe3
No related branches found
No related tags found
No related merge requests found
......@@ -7,11 +7,11 @@ entities (issues, labels, milestones, etc) in a GitLab project.
Usage
$ ./gl-sak --gitlab=GL_SERVER --user USER [--root PROJECT_PATH] COMMAND [ARGS...]
$ ./gl-sak --gitlab=GL_SERVER [--project PROJECT_PATH] COMMAND [ARGS...]
E.g.,
$ ./gl-sak --user jrandom --gitlab=https://code.librehq.com --root foo/bar/myproj baz qux quux
$ ./gl-sak --gitlab=https://code.librehq.com --project foo/bar/myproj baz qux quux
TBD: Document some commands, some of which take further arguments.
......@@ -68,6 +68,26 @@ for more about the Python GitLab API package.""")
# Read https://docs.python.org/dev/library/argparse.html#sub-commands
# when it's time for subcommands.
def list_instance(gl):
"""Print general information about GitLab server GL.
This is not really for practical usage; it's more meant to help
a developer explore what's available via the API."""
projects = gl.projects.list(iterator=True)
for project in projects:
print(f"*** {project.name_with_namespace} ({project.id}):")
issues = project.issues.list(get_all=True)
# for issue in issues:
# print(f"{issue}")
print("")
groups = gl.groups.list(iterator=True)
for group in groups:
print(f"{group}")
# This isn't quite right yet:
#
# boards = gl.boards.list(iterator=True)
# for board in boards:
# print(f"*** {board} ({board.id}):")
def main():
# Set up options and arguments
arg_parser = argparse.ArgumentParser(
......@@ -81,11 +101,8 @@ def main():
'--gitlab',
help="The URL of the GitLab server (not with path appended)")
arg_parser.add_argument(
'--root',
help="The root path of the project to operate on")
arg_parser.add_argument(
'--user',
help="The username to log in to GitLab with")
'--project',
help="The project to operate on (i.e., the project path)")
authn_token_arg = arg_parser.add_mutually_exclusive_group()
authn_token_arg.add_argument(
'-T', '--authn-token',
......@@ -105,28 +122,24 @@ def main():
private_token=args.authn_token)
gl.auth()
# WARNING: Turning on debugging can cause credentials and other
# sensitive data to be printed on the console.
#
## WARNING: Turning on debugging can cause credentials and other
## sensitive data to be printed on the console.
# gl.enable_debug()
projects = gl.projects.list(iterator=True)
for project in projects:
print(f"*** {project.name_with_namespace} ({project.id}):")
issues = project.issues.list(get_all=True)
# for issue in issues:
# print(f"{issue}")
print("")
groups = gl.groups.list(iterator=True)
for group in groups:
print(f"{group}")
## Uncomment for exploration.
# list_instance(gl)
# This isn't quite right yet:
#
# boards = gl.boards.list(iterator=True)
# for board in boards:
# print(f"*** {board} ({board.id}):")
# Instantiate specified project, if any.
project = None
try:
project = gl.projects.get(args.project, None)
except gitlab.exceptions.GitlabGetError as e:
sys.stderr.write(f"ERROR: No such project '{args.project}'\n")
sys.exit(1)
issues = project.issues.list(get_all=True)
for issue in issues:
print(f"{issue}\n")
if __name__ == '__main__':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment