Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
c2f3cd94
Commit
c2f3cd94
authored
Aug 03, 2015
by
Brendan Burns
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add LGTM timestamp checking.
parent
39735939
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
0 deletions
+38
-0
github.go
contrib/submit-queue/github/github.go
+38
-0
No files found.
contrib/submit-queue/github/github.go
View file @
c2f3cd94
...
@@ -86,6 +86,28 @@ type FilterConfig struct {
...
@@ -86,6 +86,28 @@ type FilterConfig struct {
RequiredStatusContexts
[]
string
RequiredStatusContexts
[]
string
}
}
func
validateLGTMAfterPush
(
client
*
github
.
Client
,
user
,
project
string
,
pr
*
github
.
PullRequest
)
(
bool
,
error
)
{
var
lgtmTime
*
time
.
Time
events
,
_
,
err
:=
client
.
Issues
.
ListIssueEvents
(
user
,
project
,
*
pr
.
Number
,
&
github
.
ListOptions
{})
if
err
!=
nil
{
glog
.
Errorf
(
"Error getting events for issue: %v"
,
err
)
return
false
,
err
}
for
ix
:=
range
events
{
event
:=
&
events
[
ix
]
if
*
event
.
Event
==
"labeled"
&&
*
event
.
Label
.
Name
==
"lgtm"
{
*
lgtmTime
=
*
event
.
CreatedAt
}
}
if
lgtmTime
==
nil
{
return
false
,
fmt
.
Errorf
(
"Couldn't find time for LGTM label, this shouldn't happen, skipping PR: %d"
,
*
pr
.
Number
)
}
if
pr
.
Head
==
nil
||
pr
.
Head
.
Repo
==
nil
||
pr
.
Head
.
Repo
.
PushedAt
==
nil
{
return
false
,
fmt
.
Errorf
(
"Couldn't find push time for PR, this shouldn't happen, skipping PR: %d"
,
*
pr
.
Number
)
}
return
pr
.
Head
.
Repo
.
PushedAt
.
Before
(
*
lgtmTime
),
nil
}
// For each PR in the project that matches:
// For each PR in the project that matches:
// * pr.Number > minPRNumber
// * pr.Number > minPRNumber
// * is mergeable
// * is mergeable
...
@@ -124,6 +146,7 @@ func ForEachCandidatePRDo(client *github.Client, user, project string, fn PRFunc
...
@@ -124,6 +146,7 @@ func ForEachCandidatePRDo(client *github.Client, user, project string, fn PRFunc
glog
.
Errorf
(
"Failed to get issue for PR: %v"
,
err
)
glog
.
Errorf
(
"Failed to get issue for PR: %v"
,
err
)
continue
continue
}
}
glog
.
V
(
8
)
.
Infof
(
"%v"
,
issue
.
Labels
)
glog
.
V
(
8
)
.
Infof
(
"%v"
,
issue
.
Labels
)
if
!
hasLabels
(
issue
.
Labels
,
[]
string
{
"lgtm"
,
"cla: yes"
})
{
if
!
hasLabels
(
issue
.
Labels
,
[]
string
{
"lgtm"
,
"cla: yes"
})
{
continue
continue
...
@@ -133,6 +156,21 @@ func ForEachCandidatePRDo(client *github.Client, user, project string, fn PRFunc
...
@@ -133,6 +156,21 @@ func ForEachCandidatePRDo(client *github.Client, user, project string, fn PRFunc
continue
continue
}
}
if
ok
,
err
:=
validateLGTMAfterPush
(
client
,
user
,
project
,
pr
);
err
!=
nil
{
glog
.
Errorf
(
"Error validating LGTM: %v, Skipping: %d"
,
err
,
*
pr
.
Number
)
continue
}
else
if
!
ok
{
glog
.
Errorf
(
"PR pushed after LGTM, attempting to remove LGTM and skipping"
)
staleLGTMBody
:=
"LGTM was before last commit, removing LGTM"
if
_
,
_
,
err
:=
client
.
Issues
.
CreateComment
(
user
,
project
,
*
pr
.
Number
,
&
github
.
IssueComment
{
Body
:
&
staleLGTMBody
});
err
!=
nil
{
glog
.
Warningf
(
"Failed to create remove label comment: %v"
,
err
)
}
if
_
,
err
:=
client
.
Issues
.
RemoveLabelForIssue
(
user
,
project
,
*
pr
.
Number
,
"lgtm"
);
err
!=
nil
{
glog
.
Warningf
(
"Failed to remove 'lgtm' label for stale lgtm on %d"
,
*
pr
.
Number
)
}
continue
}
// This is annoying, github appears to only temporarily cache mergeability, if it is nil, wait
// This is annoying, github appears to only temporarily cache mergeability, if it is nil, wait
// for an async refresh and retry.
// for an async refresh and retry.
if
pr
.
Mergeable
==
nil
{
if
pr
.
Mergeable
==
nil
{
...
...
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