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
02ae6c5a
Commit
02ae6c5a
authored
Mar 17, 2018
by
zauberstuhl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix case-sensitive build flags and use last commit instead of first
parent
8df848c5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
webhook.go
webhook.go
+6
-6
No files found.
webhook.go
View file @
02ae6c5a
...
...
@@ -87,17 +87,16 @@ func webhook(w http.ResponseWriter, r *http.Request) {
}
// check PR title and body for [ci] or [ci skip] flag
if
pr
.
Title
!=
nil
&&
strings
.
Contains
(
strings
.
ToLower
(
*
pr
.
Title
),
if
pr
.
Title
!=
nil
&&
strings
.
Contains
(
pr
.
GetTitle
(
),
fmt
.
Sprintf
(
"[%s]"
,
buildFlag
))
{
flagExists
=
true
}
else
if
pr
.
Body
!=
nil
&&
strings
.
Contains
(
strings
.
ToLower
(
*
pr
.
Body
),
}
else
if
pr
.
Body
!=
nil
&&
strings
.
Contains
(
pr
.
GetBody
(
),
fmt
.
Sprintf
(
"[%s]"
,
buildFlag
))
{
flagExists
=
true
}
else
{
// check labels for build flag if we haven't already found it
for
_
,
label
:=
range
pr
.
Labels
{
if
label
.
Name
!=
nil
&&
strings
.
Contains
(
strings
.
ToLower
(
label
.
GetName
()),
buildFlag
)
{
if
label
.
Name
!=
nil
&&
strings
.
Contains
(
label
.
GetName
(),
buildFlag
)
{
flagExists
=
true
break
}
...
...
@@ -106,14 +105,15 @@ func webhook(w http.ResponseWriter, r *http.Request) {
if
!
flagExists
{
// last but not least check the commit message for flags
client
:=
github
.
NewClient
(
nil
)
commits
,
_
,
err
:=
client
.
PullRequests
.
ListCommits
(
context
.
Background
(),
commits
,
_
,
err
:=
client
.
PullRequests
.
ListCommits
(
context
.
Background
(),
pr
.
GetHead
()
.
GetUser
()
.
GetLogin
(),
pr
.
GetHead
()
.
GetRepo
()
.
GetName
(),
pr
.
GetNumber
(),
&
github
.
ListOptions
{})
if
err
==
nil
&&
len
(
commits
)
>
0
{
// check only last commit since older ones are irrelevant
commitMsg
:=
strings
.
ToLower
(
commits
[
0
]
.
GetCommit
()
.
GetMessage
()
)
commitMsg
:=
commits
[
len
(
commits
)
-
1
]
.
GetCommit
()
.
GetMessage
(
)
flagExists
=
strings
.
Contains
(
commitMsg
,
fmt
.
Sprintf
(
"[%s]"
,
buildFlag
))
}
else
{
...
...
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