-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Pull request review/approval and comment on code #3748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
85e1ad5
623a9f6
aeb0577
2c18552
9544c46
0f772d1
4ad563d
17af2d1
75b7d9b
e252d3b
3e5f3c3
61cc134
36d6631
9c6bb4b
bc93592
58fb672
066086c
7986d6e
cbdd8c9
2f46613
6d00c1a
7723e15
90d9dda
5f55ede
d2b4347
ed695c1
de7081c
7c4bf56
6ae32b2
4ea74e5
7c1edf9
8bb5113
5c2171e
0f64dad
6e55557
05df5a7
e5bde14
a8dc699
8ea8209
a550052
0f88cb8
e60b3f6
a05d052
27c488e
2b6001b
d25df5b
7592f5b
4cb3a60
f64f8e0
f07b4e1
4ad72de
e2f60f4
229129d
c083682
c7dffe6
4d0abce
c79e5a1
39fcc99
9a0c394
c8c1e70
853ed7d
b6d8aea
e3f87a9
3f48c7c
b4e43d6
45dabaf
b553556
73b325c
3cd5ee4
7f0eb69
8a84f04
fbaeb02
5dd39d3
aee593b
8f77329
d8ddade
dbc7aee
a0d9afd
b2092fe
3013c0c
858345d
e340181
3f39e23
6de1f38
65d4318
e7b2b61
8a6e6dc
5554ad2
b29e722
cb29fdb
021f028
5539c96
7eec104
ce07867
dc4a27d
4c76cf5
77caec7
f1a3e6f
a116913
64269ef
7888318
638ea14
c503a70
5f8c9a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Signed-off-by: Jonas Franz <[email protected]>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1063,10 +1063,7 @@ func (prs PullRequestList) loadAttributes(e Engine) error { | |
} | ||
|
||
// Load issues. | ||
issueIDs := make([]int64, 0, len(prs)) | ||
for i := range prs { | ||
issueIDs = append(issueIDs, prs[i].IssueID) | ||
} | ||
issueIDs := prs.getIssueIDs() | ||
issues := make([]*Issue, 0, len(issueIDs)) | ||
if err := e. | ||
Where("id > 0"). | ||
|
@@ -1085,11 +1082,44 @@ func (prs PullRequestList) loadAttributes(e Engine) error { | |
return nil | ||
} | ||
|
||
func (prs PullRequestList) getIssueIDs() []int64 { | ||
issueIDs := make([]int64, 0, len(prs)) | ||
for i := range prs { | ||
issueIDs = append(issueIDs, prs[i].IssueID) | ||
} | ||
return issueIDs | ||
} | ||
|
||
// LoadAttributes load all the prs attributes | ||
func (prs PullRequestList) LoadAttributes() error { | ||
return prs.loadAttributes(x) | ||
} | ||
|
||
func (prs PullRequestList) invalidateCodeComments(e Engine, repo *git.Repository, branch string) error { | ||
if len(prs) == 0 { | ||
return nil | ||
} | ||
issueIDs := prs.getIssueIDs() | ||
var codeComments []*Comment | ||
if err := e. | ||
Where("type = ? and invalidated = ?", CommentTypeCode, false). | ||
In("issue_id", issueIDs). | ||
Find(&codeComments); err != nil { | ||
return fmt.Errorf("find code comments: %v", err) | ||
} | ||
for _, comment := range codeComments { | ||
if err := comment.CheckInvalidation(repo, branch); err != nil { | ||
return err | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
// InvalidateCodeComments will lookup the prs for code comments which got invalidated by change | ||
func (prs PullRequestList) InvalidateCodeComments(repo *git.Repository, branch string) error { | ||
return prs.invalidateCodeComments(x, repo, branch) | ||
} | ||
|
||
func addHeadRepoTasks(prs []*PullRequest) { | ||
for _, pr := range prs { | ||
log.Trace("addHeadRepoTasks[%d]: composing new test task", pr.ID) | ||
|
@@ -1116,10 +1146,29 @@ func AddTestPullRequestTask(doer *User, repoID int64, branch string, isSync bool | |
} | ||
|
||
if isSync { | ||
if err = PullRequestList(prs).LoadAttributes(); err != nil { | ||
requests := PullRequestList(prs) | ||
if err = requests.LoadAttributes(); err != nil { | ||
log.Error(4, "PullRequestList.LoadAttributes: %v", err) | ||
} | ||
var gitRepo *git.Repository | ||
repo, err := GetRepositoryByID(repoID) | ||
if err != nil { | ||
log.Error(4, "GetRepositoryByID: %v", err) | ||
goto REQUIRED_PROCEDURE | ||
} | ||
gitRepo, err = git.OpenRepository(repo.RepoPath()) | ||
if err != nil { | ||
log.Error(4, "git.OpenRepository: %v", err) | ||
goto REQUIRED_PROCEDURE | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure how much There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand your duplication concern. Yet the line after the goto tag checks If you want to run that code in all three cases, I'd put it in a func var like this and call it in all three places. var queHooks = func() {
// iterate, preapare and add to que...
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I re-factored the complete procedure. Is it now better? |
||
} | ||
go func() { | ||
err := requests.InvalidateCodeComments(gitRepo, branch) | ||
if err != nil { | ||
log.Error(4, "PullRequestList.InvalidateCodeComments: %v", err) | ||
} | ||
}() | ||
|
||
REQUIRED_PROCEDURE: | ||
if err == nil { | ||
for _, pr := range prs { | ||
pr.Issue.PullRequest = pr | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be more approachable to make this map a concrete type and explain it with a godoc comment?
I guess its
file > line > coments
, right?