Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
practical-work-manager
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
Model registry
Operate
Environments
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
ISC
projects
practical-work-manager
Commits
2d3c23cd
Commit
2d3c23cd
authored
2 months ago
by
Adrien Lescourt
Browse files
Options
Downloads
Patches
Plain Diff
Explicit group_id and project_id + bring back the gitedu_token file
parent
614b8878
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pwm/pwm.py
+11
-13
11 additions, 13 deletions
pwm/pwm.py
with
11 additions
and
13 deletions
pwm/pwm.py
+
11
−
13
View file @
2d3c23cd
...
@@ -253,7 +253,6 @@ class Gitlab:
...
@@ -253,7 +253,6 @@ class Gitlab:
print
(
"
Error retrieving members:
"
+
members
[
"
message
"
])
print
(
"
Error retrieving members:
"
+
members
[
"
message
"
])
exit
(
1
)
exit
(
1
)
ssh_url_to_repo
=
repo
[
"
ssh_url_to_repo
"
]
web_url
=
repo
[
"
web_url
"
]
web_url
=
repo
[
"
web_url
"
]
members_names
=
""
members_names
=
""
...
@@ -337,7 +336,7 @@ def command_clone_all(args):
...
@@ -337,7 +336,7 @@ def command_clone_all(args):
def
command_list_projects
(
args
):
def
command_list_projects
(
args
):
gl
=
Gitlab
(
args
.
token
)
gl
=
Gitlab
(
args
.
token
)
projects
=
gl
.
get_projects_in_group
(
args
.
id
)
projects
=
gl
.
get_projects_in_group
(
args
.
group_
id
)
if
args
.
show
:
if
args
.
show
:
if
args
.
show
==
"
all
"
:
if
args
.
show
==
"
all
"
:
print
(
json
.
dumps
(
projects
,
indent
=
2
))
print
(
json
.
dumps
(
projects
,
indent
=
2
))
...
@@ -361,7 +360,7 @@ def command_list_projects(args):
...
@@ -361,7 +360,7 @@ def command_list_projects(args):
def
command_list_users
(
args
):
def
command_list_users
(
args
):
gl
=
Gitlab
(
args
.
token
)
gl
=
Gitlab
(
args
.
token
)
members
=
gl
.
get_users_in_repository
(
args
.
id
)
members
=
gl
.
get_users_in_repository
(
args
.
project_
id
)
if
args
.
show
:
if
args
.
show
:
if
args
.
show
==
"
all
"
:
if
args
.
show
==
"
all
"
:
print
(
json
.
dumps
(
members
,
indent
=
2
))
print
(
json
.
dumps
(
members
,
indent
=
2
))
...
@@ -423,15 +422,9 @@ def main():
...
@@ -423,15 +422,9 @@ def main():
parser_clone
=
subparsers
.
add_parser
(
"
clone
"
,
help
=
"
Clone the repositories locally
"
)
parser_clone
=
subparsers
.
add_parser
(
"
clone
"
,
help
=
"
Clone the repositories locally
"
)
group_clone
=
parser_clone
.
add_mutually_exclusive_group
()
group_clone
=
parser_clone
.
add_mutually_exclusive_group
()
group_clone
.
add_argument
(
"
-g
"
,
"
--group
"
,
action
=
"
store_true
"
,
help
=
"
Clone repositories from a group (with group_id) (default behavior).
"
,
)
parser_clone
.
add_argument
(
parser_clone
.
add_argument
(
"
id
"
,
"
group_
id
"
,
metavar
=
"
ID
"
,
metavar
=
"
GROUP_
ID
"
,
help
=
"
The group_id (int) of the projects.
"
,
help
=
"
The group_id (int) of the projects.
"
,
)
)
parser_clone
.
add_argument
(
parser_clone
.
add_argument
(
...
@@ -454,7 +447,7 @@ def main():
...
@@ -454,7 +447,7 @@ def main():
parser_list
=
subparsers
.
add_parser
(
parser_list
=
subparsers
.
add_parser
(
"
list_projects
"
,
help
=
"
List all project in a group
"
"
list_projects
"
,
help
=
"
List all project in a group
"
)
)
parser_list
.
add_argument
(
"
id
"
,
metavar
=
"
ID
"
,
help
=
"
The group_id (int).
"
)
parser_list
.
add_argument
(
"
group_
id
"
,
metavar
=
"
GROUP_
ID
"
,
help
=
"
The group_id (int).
"
)
parser_list
.
add_argument
(
parser_list
.
add_argument
(
"
-s
"
,
"
-s
"
,
"
--show
"
,
"
--show
"
,
...
@@ -466,7 +459,7 @@ def main():
...
@@ -466,7 +459,7 @@ def main():
"
list_users
"
,
help
=
"
List all users in a repository
"
"
list_users
"
,
help
=
"
List all users in a repository
"
)
)
parser_list
.
add_argument
(
parser_list
.
add_argument
(
"
id
"
,
metavar
=
"
ID
"
,
help
=
"
The repository project_id (int).
"
"
project_
id
"
,
metavar
=
"
PROJECT_
ID
"
,
help
=
"
The repository project_id (int).
"
)
)
parser_list
.
add_argument
(
parser_list
.
add_argument
(
"
-s
"
,
"
-s
"
,
...
@@ -481,6 +474,11 @@ def main():
...
@@ -481,6 +474,11 @@ def main():
if
os
.
environ
.
get
(
"
GITEDU_TOKEN
"
):
if
os
.
environ
.
get
(
"
GITEDU_TOKEN
"
):
args
.
token
=
os
.
environ
.
get
(
"
GITEDU_TOKEN
"
)
args
.
token
=
os
.
environ
.
get
(
"
GITEDU_TOKEN
"
)
else
:
else
:
token_file
=
os
.
environ
.
get
(
"
HOME
"
,
""
)
+
"
/.config/gitedu_token
"
if
os
.
path
.
isfile
(
token_file
):
with
open
(
token_file
)
as
file
:
args
.
token
=
file
.
read
().
strip
()
if
args
.
token
is
None
:
print
(
print
(
"
Error: you must give a valid api token. Create a token here:
"
"
Error: you must give a valid api token. Create a token here:
"
+
TOKEN_URL
+
TOKEN_URL
...
...
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