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
3cdab89e
Commit
3cdab89e
authored
1 month ago
by
Adrien Lescourt
Browse files
Options
Downloads
Patches
Plain Diff
Improve stdout messages for repo creations
parent
f0839518
Branches
refactor
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
+15
-5
15 additions, 5 deletions
pwm/pwm.py
with
15 additions
and
5 deletions
pwm/pwm.py
+
15
−
5
View file @
3cdab89e
...
@@ -112,7 +112,13 @@ class Gitlab:
...
@@ -112,7 +112,13 @@ class Gitlab:
print
(
f
"
Error searching user
{
user
.
user_login_aai
}
"
)
print
(
f
"
Error searching user
{
user
.
user_login_aai
}
"
)
print
(
res
.
text
)
print
(
res
.
text
)
else
:
else
:
return
str
(
res
.
json
()[
0
][
"
id
"
])
res_json
=
res
.
json
()
if
len
(
res_json
)
==
1
:
return
str
(
res
.
json
()[
0
][
"
id
"
])
elif
len
(
res_json
)
>
1
:
print
(
f
"
ERROR: More than one users found for
{
user
.
user_login_aai
}
"
)
else
:
print
(
f
"
ERROR: No user found for
{
user
.
user_login_aai
}
"
)
def
add_users_to_repository
(
def
add_users_to_repository
(
self
,
self
,
...
@@ -120,8 +126,8 @@ class Gitlab:
...
@@ -120,8 +126,8 @@ class Gitlab:
project_name
:
str
,
project_name
:
str
,
users
:
list
[
User
],
users
:
list
[
User
],
expires_at
:
str
|
None
,
expires_at
:
str
|
None
,
):
)
->
list
[
User
]
:
"""
Add users to a repo, and set their permissions
"""
"""
Add users to a repo, and set their permissions
, returns all user added
"""
headers
=
{
"
PRIVATE-TOKEN
"
:
self
.
token
}
headers
=
{
"
PRIVATE-TOKEN
"
:
self
.
token
}
# Allow users with developer access level to push and merge on master
# Allow users with developer access level to push and merge on master
access_level
=
40
access_level
=
40
...
@@ -140,12 +146,14 @@ class Gitlab:
...
@@ -140,12 +146,14 @@ class Gitlab:
f
"
Error setting project (
{
project_name
}
) premissions
"
,
res
.
text
f
"
Error setting project (
{
project_name
}
) premissions
"
,
res
.
text
)
)
added_users
=
[]
for
user
in
users
:
for
user
in
users
:
user_id
=
self
.
get_user_id
(
user
)
user_id
=
self
.
get_user_id
(
user
)
if
user_id
is
None
:
if
user_id
is
None
:
print
(
print
(
f
"
ERROR: User
{
user
.
user_login_aai
}
will not be added to project:
{
project_name
}
"
f
"
ERROR: User
{
user
.
user_login_aai
}
will not be added to project:
{
project_name
}
"
)
)
continue
params
=
{
"
user_id
"
:
user_id
,
"
access_level
"
:
access_level
}
params
=
{
"
user_id
"
:
user_id
,
"
access_level
"
:
access_level
}
if
expires_at
:
if
expires_at
:
params
[
"
expires_at
"
]
=
expires_at
params
[
"
expires_at
"
]
=
expires_at
...
@@ -159,6 +167,8 @@ class Gitlab:
...
@@ -159,6 +167,8 @@ class Gitlab:
f
"
ERROR: User
{
user
.
user_login_aai
}
will not be added to project:
{
project_name
}
"
f
"
ERROR: User
{
user
.
user_login_aai
}
will not be added to project:
{
project_name
}
"
)
)
print
(
res
.
text
)
print
(
res
.
text
)
added_users
.
append
(
user
)
return
added_users
def
create_repository
(
def
create_repository
(
self
,
self
,
...
@@ -328,11 +338,11 @@ def command_create_group_repos(args):
...
@@ -328,11 +338,11 @@ def command_create_group_repos(args):
group
.
name
,
group
.
name
,
args
.
import_url
,
args
.
import_url
,
)
)
gl
.
add_users_to_repository
(
added_users
=
gl
.
add_users_to_repository
(
project_id
,
group
.
name
,
group
.
user_ids
,
args
.
expires_at
project_id
,
group
.
name
,
group
.
user_ids
,
args
.
expires_at
)
)
print
(
print
(
f
"
Created repo:
{
group
.
name
}
with the users:
{
[
u
.
user_login_aai
for
u
in
group
.
user
_id
s
]
}
"
f
"
Created repo:
{
group
.
name
}
with the users:
{
[
u
.
user_login_aai
for
u
in
added_
users
]
}
"
)
)
...
...
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