Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/gitlab/client/projects.rb
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,18 @@ def unshare_project_with_group(project, id)
delete("/projects/#{url_encode project}/share/#{id}")
end

# Transfer a project to a new namespace.
#
# @example
# Gitlab.transfer_project(42, 'yolo')
#
# @param [Integer, String] project The ID or path of a project
# @param [Integer, String] namespace The ID or path of the namespace to transfer to project to
# @return [Gitlab::ObjectifiedHash] Information about transfered project.
def transfer_project(project, namespace)
put("/projects/#{url_encode project}/transfer", body: { namespace: namespace })
end

# Stars a project.
# @see https://docs.gitlab.com/ce/api/projects.html#star-a-project
#
Expand Down
2 changes: 1 addition & 1 deletion lib/gitlab/page_links.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Gitlab
class PageLinks
HEADER_LINK = 'Link'
DELIM_LINKS = ','
LINK_REGEX = /<([^>]+)>; rel=\"([^\"]+)\"/
LINK_REGEX = /<([^>]+)>; rel=\"([^\"]+)\"/.freeze
METAS = %w[last next first prev].freeze

attr_accessor(*METAS)
Expand Down
59 changes: 59 additions & 0 deletions spec/fixtures/transfer_project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"id": 1,
"description": null,
"name": "test",
"name_with_namespace": "Yolo / test",
"path": "test",
"path_with_namespace": "yolo/test",
"created_at": "2018-10-26T21:14:12.851Z",
"default_branch": "master",
"tag_list": [],
"ssh_url_to_repo": "[email protected]:yolo/test.git",
"http_url_to_repo": "https://gitlab.com/yolo/test.git",
"web_url": "https://gitlab.com/yolo/test",
"readme_url": null,
"avatar_url": null,
"star_count": 0,
"forks_count": 0,
"last_activity_at": "2018-10-26T21:14:12.851Z",
"namespace": {
"id": 2,
"name": "Yolo",
"path": "yolo",
"kind": "group",
"full_path": "yolo",
"parent_id": null
},
"_links": {
"self": "https://gitlab.com/api/v4/projects/1",
"issues": "https://gitlab.com/api/v4/projects/1/issues",
"merge_requests": "https://gitlab.com/api/v4/projects/1/merge_requests",
"repo_branches": "https://gitlab.com/api/v4/projects/1/repository/branches",
"labels": "https://gitlab.com/api/v4/projects/1/labels",
"events": "https://gitlab.com/api/v4/projects/1/events",
"members": "https://gitlab.com/api/v4/projects/1/members"
},
"archived": false,
"visibility": "private",
"resolve_outdated_diff_discussions": false,
"container_registry_enabled": true,
"issues_enabled": true,
"merge_requests_enabled": true,
"wiki_enabled": true,
"jobs_enabled": true,
"snippets_enabled": true,
"shared_runners_enabled": true,
"lfs_enabled": true,
"creator_id": 42,
"import_status": "none",
"open_issues_count": 0,
"public_jobs": true,
"ci_config_path": null,
"shared_with_groups": [],
"only_allow_merge_if_pipeline_succeeds": false,
"request_access_enabled": false,
"only_allow_merge_if_all_discussions_are_resolved": false,
"printing_merge_request_link_enabled": true,
"merge_method": "merge",
"mirror": false
}
16 changes: 16 additions & 0 deletions spec/gitlab/client/projects_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,22 @@
end
end

describe '.transfer_project' do
before do
stub_put('/projects/3/transfer', 'transfer_project')
@transfered_project = Gitlab.transfer_project(3, 'yolo')
end

it 'gets the correct resource' do
expect(a_put('/projects/3/transfer')
.with(body: { namespace: 'yolo' })).to have_been_made
end

it 'returns information about the transfered project' do
expect(@transfered_project.id).to eq(1)
end
end

describe '.star_project' do
before do
stub_post('/projects/3/star', 'project_star')
Expand Down