Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GitLab API Experiments
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Karl Fogel
GitLab API Experiments
Commits
92870c19
Commit
92870c19
authored
1 month ago
by
Karl Fogel
Browse files
Options
Downloads
Patches
Plain Diff
Browse a single project's issues
parent
46cfbfe3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gl-sak
+39
-26
39 additions, 26 deletions
gl-sak
with
39 additions
and
26 deletions
gl-sak
+
39
−
26
View file @
92870c19
...
...
@@ -7,11 +7,11 @@ entities (issues, labels, milestones, etc) in a GitLab project.
Usage
$ ./gl-sak --gitlab=GL_SERVER
--user USER
[--ro
o
t PROJECT_PATH] COMMAND [ARGS...]
$ ./gl-sak --gitlab=GL_SERVER [--
p
ro
jec
t PROJECT_PATH] COMMAND [ARGS...]
E.g.,
$ ./gl-sak
--user jrandom
--gitlab=https://code.librehq.com --ro
o
t foo/bar/myproj baz qux quux
$ ./gl-sak --gitlab=https://code.librehq.com --
p
ro
jec
t 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__
'
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment