Commit 4259334f authored by Ahmad Sherif's avatar Ahmad Sherif
Browse files

Fix applying labels for GitHub-imported MRs

parent 232f784c8eef
......@@ -26,6 +26,7 @@ Please view this file on the master branch, on stable branches it's out of date.
- Fix Sign in page 'Forgot your password?' link overlaps on medium-large screens
- Show full status link on MR & commit pipelines
- Fix documents and comments on Build API `scope`
- Fix applying labels for GitHub-imported MRs
- Refactor email, use setter method instead AR callbacks for email attribute (Semyon Pupkov)
## 8.13.1 (2016-10-25)
......
......@@ -105,18 +105,20 @@ def request(method, *args, &block)
data = api.send(method, *args)
return data unless data.is_a?(Array)
last_response = api.last_response
if block_given?
yield data
each_response_page(&block)
# api.last_response could change while we're yielding (e.g. fetching labels for each PR)
# so we cache our own last request
each_response_page(last_response, &block)
else
each_response_page { |page| data.concat(page) }
each_response_page(last_response) { |page| data.concat(page) }
data
end
end
def each_response_page
last_response = api.last_response
def each_response_page(last_response)
while last_response.rels[:next]
sleep rate_limit_sleep_time if rate_limit_exceed?
last_response = last_response.rels[:next].get
......
......@@ -132,8 +132,15 @@ def clean_up_restored_branches(pull_request)
end
def apply_labels(issuable, raw_issuable)
if raw_issuable.labels.count > 0
label_ids = raw_issuable.labels
# GH returns labels for issues but not for pull requests!
labels = if issuable.is_a?(MergeRequest)
client.labels_for_issue(repo, raw_issuable.number)
else
raw_issuable.labels
end
if labels.count > 0
label_ids = labels
.map { |attrs| @labels[attrs.name] }
.compact
......
......@@ -154,6 +154,7 @@
{ type: :label, url: "https://api.github.com/repos/octocat/Hello-World/labels/bug", errors: "Validation failed: Title can't be blank, Title is invalid" },
{ type: :milestone, url: "https://api.github.com/repos/octocat/Hello-World/milestones/1", errors: "Validation failed: Title has already been taken" },
{ type: :issue, url: "https://api.github.com/repos/octocat/Hello-World/issues/1348", errors: "Validation failed: Title can't be blank, Title is too short (minimum is 0 characters)" },
{ type: :pull_request, url: "https://api.github.com/repos/octocat/Hello-World/pulls/1347", errors: "Invalid Repository. Use user/repo format." },
{ type: :pull_request, url: "https://api.github.com/repos/octocat/Hello-World/pulls/1347", errors: "Validation failed: Validate branches Cannot Create: This merge request already exists: [\"New feature\"]" },
{ type: :wiki, errors: "Gitlab::Shell::Error" },
{ type: :release, url: 'https://api.github.com/repos/octocat/Hello-World/releases/2', errors: "Validation failed: Description can't be blank" }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment