Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
9c230180
Commit
9c230180
authored
Apr 06, 2015
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CI project forking
parent
0d0042d2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
0 deletions
+42
-0
app/models/project_services/gitlab_ci_service.rb
app/models/project_services/gitlab_ci_service.rb
+24
-0
app/services/projects/fork_service.rb
app/services/projects/fork_service.rb
+6
-0
app/workers/fork_registrator_worker.rb
app/workers/fork_registrator_worker.rb
+12
-0
No files found.
app/models/project_services/gitlab_ci_service.rb
View file @
9c230180
...
...
@@ -59,6 +59,26 @@ class GitlabCiService < CiService
end
end
def
register_fork
(
new_project
,
user_token
)
params
=
{
id:
new_project
.
id
,
name_with_namespace:
new_project
.
name_with_namespace
,
web_url:
new_project
.
web_url
,
default_branch:
new_project
.
default_branch
,
ssh_url_to_repo:
new_project
.
ssh_url_to_repo
}
HTTParty
.
post
(
register_fork_path
,
body:
{
project_id:
project
.
id
,
project_token:
token
,
user_token:
user_token
,
data:
params
.
to_yaml
},
verify:
false
)
end
def
commit_coverage
(
sha
,
ref
)
response
=
get_ci_build
(
sha
,
ref
)
...
...
@@ -75,6 +95,10 @@ class GitlabCiService < CiService
project_url
+
"?ref="
+
project
.
default_branch
end
def
register_fork_path
project_url
.
sub
(
/projects\/\d*/
,
'api/v1/forks'
)
end
def
status_img_path
project_url
+
"/status.png?ref="
+
project
.
default_branch
end
...
...
app/services/projects/fork_service.rb
View file @
9c230180
...
...
@@ -40,12 +40,18 @@ module Projects
if
project
.
save
project
.
team
<<
[
@current_user
,
:master
]
end
#Now fork the repo
unless
gitlab_shell
.
fork_repository
(
@from_project
.
path_with_namespace
,
project
.
namespace
.
path
)
raise
'forking failed in gitlab-shell'
end
project
.
ensure_satellite_exists
end
if
@from_project
.
gitlab_ci?
ForkRegistratorWorker
.
perform_async
(
@from_project
.
id
,
project
.
id
,
@current_user
.
private_token
)
end
rescue
=>
ex
project
.
errors
.
add
(
:base
,
'Fork transaction failed.'
)
project
.
destroy
...
...
app/workers/fork_registrator_worker.rb
0 → 100644
View file @
9c230180
class
ForkRegistratorWorker
include
Sidekiq
::
Worker
sidekiq_options
queue: :default
def
perform
(
from_project_id
,
to_project_id
,
private_token
)
from_project
=
Project
.
find
(
from_project_id
)
to_project
=
Project
.
find
(
to_project_id
)
from_project
.
gitlab_ci_service
.
register_fork
(
to_project
,
private_token
)
end
end
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