Commit 1065f3d3 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'github-org-repos' into 'master'

Fix missing GitHub organisation repositories on import page.

Private repositories belonging to organizations rather than users can't be imported because `client.repos(org.login)` was requesting `/users/:org_login/repos` (which only returns public org repo's), while we need `/orgs/:org_login/repos` (which includes both public and private). The `client.org_repos` method does this.

cc @marin This is a bug in 7.8.x, but I'm not sure if it needs a minor release now or if it can go in 7.9.

See merge request !1683
parents 59621e90 3175438f
...@@ -62,6 +62,7 @@ v 7.8.4 ...@@ -62,6 +62,7 @@ v 7.8.4
v 7.8.3 v 7.8.3
- Bump version of gitlab_git fixing annotated tags without message - Bump version of gitlab_git fixing annotated tags without message
- Allow smb:// links in Markdown text. - Allow smb:// links in Markdown text.
- Fix missing GitHub organisation repositories on import page.
v 7.8.2 v 7.8.2
- Fix service migration issue when upgrading from versions prior to 7.3 - Fix service migration issue when upgrading from versions prior to 7.3
......
...@@ -14,7 +14,7 @@ class Import::GithubController < Import::BaseController ...@@ -14,7 +14,7 @@ class Import::GithubController < Import::BaseController
def status def status
@repos = client.repos @repos = client.repos
client.orgs.each do |org| client.orgs.each do |org|
@repos += client.repos(org.login) @repos += client.org_repos(org.login)
end end
@already_added_projects = current_user.created_projects.where(import_type: "github") @already_added_projects = current_user.created_projects.where(import_type: "github")
......
...@@ -27,17 +27,20 @@ describe Import::GithubController do ...@@ -27,17 +27,20 @@ describe Import::GithubController do
describe "GET status" do describe "GET status" do
before do before do
@repo = OpenStruct.new(login: 'vim', full_name: 'asd/vim') @repo = OpenStruct.new(login: 'vim', full_name: 'asd/vim')
@org = OpenStruct.new(login: 'company')
@org_repo = OpenStruct.new(login: 'company', full_name: 'company/repo')
end end
it "assigns variables" do it "assigns variables" do
@project = create(:project, import_type: 'github', creator_id: user.id) @project = create(:project, import_type: 'github', creator_id: user.id)
controller.stub_chain(:client, :repos).and_return([@repo]) controller.stub_chain(:client, :repos).and_return([@repo])
controller.stub_chain(:client, :orgs).and_return([]) controller.stub_chain(:client, :orgs).and_return([@org])
controller.stub_chain(:client, :org_repos).with(@org.login).and_return([@org_repo])
get :status get :status
expect(assigns(:already_added_projects)).to eq([@project]) expect(assigns(:already_added_projects)).to eq([@project])
expect(assigns(:repos)).to eq([@repo]) expect(assigns(:repos)).to eq([@repo, @org_repo])
end end
it "does not show already added project" do it "does not show already added project" do
......
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