Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Testsuite Server
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Feneas
federation
Testsuite Server
Commits
1c35276c
Commit
1c35276c
authored
Mar 19, 2018
by
zauberstuhl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check installed hooks and skip it if it exists
parent
1d27efd1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
3 deletions
+21
-3
frontend.go
frontend.go
+21
-3
No files found.
frontend.go
View file @
1c35276c
...
...
@@ -108,7 +108,7 @@ func resultPage(w http.ResponseWriter, r *http.Request) {
}
name
:=
"web"
h
ook
:=
github
.
Hook
{
newH
ook
:=
github
.
Hook
{
Name
:
&
name
,
Events
:
[]
string
{
"pull_request"
},
Config
:
map
[
string
]
interface
{}{
"content_type"
:
"json"
,
...
...
@@ -118,13 +118,31 @@ func resultPage(w http.ResponseWriter, r *http.Request) {
}
if
!
devMode
{
_
,
_
,
err
:=
client
.
Repositories
.
CreateHook
(
ctx
,
repoSlice
[
0
],
repoSlice
[
1
],
&
hook
)
hooks
,
_
,
err
:=
client
.
Repositories
.
ListHooks
(
ctx
,
repoSlice
[
0
],
repoSlice
[
1
],
&
github
.
ListOptions
{})
if
err
!=
nil
{
logger
.
Println
(
err
)
render
(
w
,
"error.html"
,
"Cannot
create the repository hook
"
)
render
(
w
,
"error.html"
,
"Cannot
list repository hooks
"
)
return
}
var
hookExists
=
false
for
_
,
hook
:=
range
hooks
{
if
hook
.
GetURL
()
==
newHook
.
Config
[
"url"
]
.
(
string
)
{
hookExists
=
true
}
}
if
!
hookExists
{
_
,
_
,
err
:=
client
.
Repositories
.
CreateHook
(
ctx
,
repoSlice
[
0
],
repoSlice
[
1
],
&
newHook
)
if
err
!=
nil
{
logger
.
Println
(
err
)
render
(
w
,
"error.html"
,
"Cannot create repository hooks"
)
return
}
}
err
=
repo
.
CreateOrUpdate
()
if
err
!=
nil
{
logger
.
Println
(
err
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment