Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gitlab-deps
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
pipelines
tools
gitlab-deps
Commits
669266ef
Commit
669266ef
authored
2 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
Add a "clear-hooks" command
Useful in emergencies to undo mistakes done by set-hooks.
parent
9ce7a22c
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#45666
passed
2 years ago
Stage: build
Stage: release
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
gitlab_deps/hooks.py
+9
-0
9 additions, 0 deletions
gitlab_deps/hooks.py
gitlab_deps/main.py
+19
-1
19 additions, 1 deletion
gitlab_deps/main.py
with
28 additions
and
1 deletion
gitlab_deps/hooks.py
+
9
−
0
View file @
669266ef
...
...
@@ -18,3 +18,12 @@ def check_hook(gl, hook_url, webhook_token, project_path, dry_run):
'
pipeline_events
'
:
True
,
'
token
'
:
webhook_token
,
})
def
clear_hooks
(
gl
,
project_path
,
dry_run
):
project
=
gl
.
projects
.
get
(
project_path
)
for
h
in
project
.
hooks
.
list
():
logging
.
info
(
'
%s: removing hook %s
'
,
project_path
,
h
.
url
)
if
not
dry_run
:
h
.
delete
()
This diff is collapsed.
Click to expand it.
gitlab_deps/main.py
+
19
−
1
View file @
669266ef
...
...
@@ -7,7 +7,7 @@ from urllib.parse import urlsplit
from
.deps
import
get_branches
,
list_projects
,
list_deps
,
\
split_project_branch
,
read_deps
from
.hooks
import
check_hook
from
.hooks
import
check_hook
,
clear_hooks
from
.rebuild
import
rebuild_deps
from
.server
import
run_app
...
...
@@ -105,6 +105,14 @@ from standard input if a filename is omitted or specified as '-'.
type
=
argparse
.
FileType
(
'
r
'
),
nargs
=
'
?
'
,
default
=
sys
.
stdin
)
clear_hooks_parser
=
subparsers
.
add_parser
(
'
clear-hooks
'
,
parents
=
[
common_parser
])
clear_hooks_parser
.
add_argument
(
'
projects_list
'
,
type
=
argparse
.
FileType
(
'
r
'
),
nargs
=
'
?
'
,
default
=
sys
.
stdin
)
# Setup pipeline hooks on the specified projects.
set_hooks_parser
=
subparsers
.
add_parser
(
'
set-hooks
'
,
...
...
@@ -264,6 +272,16 @@ specified as '-'.
logging
.
error
(
'
error checking project %s: %s
'
,
project_path
,
e
)
elif
cmd
==
'
clear-hooks
'
:
projects
=
set
(
y
[
0
]
for
y
in
(
split_project_branch
(
x
.
strip
())
for
x
in
args
.
projects_list
))
for
project_path
in
projects
:
try
:
clear_hooks
(
gl
,
project_path
,
args
.
dry_run
)
except
Exception
as
e
:
logging
.
error
(
'
error clearing hooks for project %s: %s
'
,
project_path
,
e
)
elif
cmd
==
'
server
'
:
deps
=
read_deps
(
args
.
dependencies_list
)
run_app
(
gl
,
deps
,
args
.
bind_host
,
args
.
bind_port
,
...
...
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