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
996ae12c
Commit
996ae12c
authored
Jan 19, 2016
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add option to "Trigger builds for mirror updates"
parent
97700125
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
51 additions
and
8 deletions
+51
-8
CHANGELOG-EE
CHANGELOG-EE
+1
-0
app/controllers/projects/mirrors_controller.rb
app/controllers/projects/mirrors_controller.rb
+1
-1
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+1
-0
app/helpers/application_helper.rb
app/helpers/application_helper.rb
+3
-0
app/models/repository.rb
app/models/repository.rb
+11
-0
app/services/create_commit_builds_service.rb
app/services/create_commit_builds_service.rb
+3
-1
app/services/git_push_service.rb
app/services/git_push_service.rb
+4
-1
app/services/git_tag_push_service.rb
app/services/git_tag_push_service.rb
+2
-2
app/services/projects/update_mirror_service.rb
app/services/projects/update_mirror_service.rb
+2
-2
app/views/projects/edit.html.haml
app/views/projects/edit.html.haml
+2
-0
app/views/projects/mirrors/show.html.haml
app/views/projects/mirrors/show.html.haml
+3
-0
app/views/shared/_mirror_trigger_builds_setting.html.haml
app/views/shared/_mirror_trigger_builds_setting.html.haml
+11
-0
db/migrate/20160119170055_add_mirror_trigger_builds_to_projects.rb
...e/20160119170055_add_mirror_trigger_builds_to_projects.rb
+5
-0
db/schema.rb
db/schema.rb
+2
-1
No files found.
CHANGELOG-EE
View file @
996ae12c
...
@@ -4,6 +4,7 @@ v 8.4.0 (unreleased)
...
@@ -4,6 +4,7 @@ v 8.4.0 (unreleased)
- Fix "Approvals are not reset after a new push is made if the request is coming from a fork"
- Fix "Approvals are not reset after a new push is made if the request is coming from a fork"
- Fix "User is not automatically removed from suggested approvers list if user is deleted"
- Fix "User is not automatically removed from suggested approvers list if user is deleted"
- Add option to enforce a semi-linear history by only allowing merge requests to be merged that have been rebased.
- Add option to enforce a semi-linear history by only allowing merge requests to be merged that have been rebased.
- Add option to trigger builds when branches or tags are updated from a mirrored upstream repository.
v 8.3.2
v 8.3.2
- No EE-specific changes
- No EE-specific changes
...
...
app/controllers/projects/mirrors_controller.rb
View file @
996ae12c
...
@@ -38,6 +38,6 @@ class Projects::MirrorsController < Projects::ApplicationController
...
@@ -38,6 +38,6 @@ class Projects::MirrorsController < Projects::ApplicationController
private
private
def
mirror_params
def
mirror_params
params
.
require
(
:project
).
permit
(
:mirror
,
:import_url
,
:mirror_user_id
)
params
.
require
(
:project
).
permit
(
:mirror
,
:import_url
,
:mirror_user_id
,
:mirror_trigger_builds
)
end
end
end
end
app/controllers/projects_controller.rb
View file @
996ae12c
...
@@ -260,6 +260,7 @@ class ProjectsController < ApplicationController
...
@@ -260,6 +260,7 @@ class ProjectsController < ApplicationController
:merge_requests_template
,
:merge_requests_template
,
:mirror
,
:mirror
,
:mirror_user_id
,
:mirror_user_id
,
:mirror_trigger_builds
,
:reset_approvals_on_push
:reset_approvals_on_push
)
)
end
end
...
...
app/helpers/application_helper.rb
View file @
996ae12c
...
@@ -141,6 +141,9 @@ module ApplicationHelper
...
@@ -141,6 +141,9 @@ module ApplicationHelper
# Skip if user removed branch right after that
# Skip if user removed branch right after that
return
false
unless
project
.
repository
.
branch_names
.
include?
(
event
.
branch_name
)
return
false
unless
project
.
repository
.
branch_names
.
include?
(
event
.
branch_name
)
# Skip if this was a mirror update
return
false
if
project
.
mirror?
&&
project
.
up_to_date_with_upstream?
(
event
.
branch_name
)
true
true
end
end
...
...
app/models/repository.rb
View file @
996ae12c
...
@@ -643,6 +643,17 @@ class Repository
...
@@ -643,6 +643,17 @@ class Repository
end
end
end
end
def
up_to_date_with_upstream?
(
branch_name
)
branch_commit
=
commit
(
branch_name
)
upstream_commit
=
commit
(
"refs/remotes/
#{
MIRROR_REMOTE
}
/
#{
branch_name
}
"
)
if
upstream_commit
is_ancestor?
(
branch_commit
.
id
,
upstream_commit
.
id
)
else
false
end
end
def
merge_base
(
first_commit_id
,
second_commit_id
)
def
merge_base
(
first_commit_id
,
second_commit_id
)
rugged
.
merge_base
(
first_commit_id
,
second_commit_id
)
rugged
.
merge_base
(
first_commit_id
,
second_commit_id
)
end
end
...
...
app/services/create_commit_builds_service.rb
View file @
996ae12c
class
CreateCommitBuildsService
class
CreateCommitBuildsService
def
execute
(
project
,
user
,
params
)
def
execute
(
project
,
user
,
params
,
mirror_update:
false
)
return
false
unless
project
.
builds_enabled?
return
false
unless
project
.
builds_enabled?
return
false
if
!
project
.
mirror_trigger_builds?
&&
mirror_update
sha
=
params
[
:checkout_sha
]
||
params
[
:after
]
sha
=
params
[
:checkout_sha
]
||
params
[
:after
]
origin_ref
=
params
[
:ref
]
origin_ref
=
params
[
:ref
]
...
...
app/services/git_push_service.rb
View file @
996ae12c
...
@@ -58,10 +58,13 @@ class GitPushService
...
@@ -58,10 +58,13 @@ class GitPushService
@push_data
=
build_push_data
(
oldrev
,
newrev
,
ref
)
@push_data
=
build_push_data
(
oldrev
,
newrev
,
ref
)
branch_name
=
Gitlab
::
Git
.
ref_name
(
ref
)
mirror_update
=
project
.
mirror?
&&
project
.
up_to_date_with_upstream?
(
branch_name
)
EventCreateService
.
new
.
push
(
project
,
user
,
@push_data
)
EventCreateService
.
new
.
push
(
project
,
user
,
@push_data
)
project
.
execute_hooks
(
@push_data
.
dup
,
:push_hooks
)
project
.
execute_hooks
(
@push_data
.
dup
,
:push_hooks
)
project
.
execute_services
(
@push_data
.
dup
,
:push_hooks
)
project
.
execute_services
(
@push_data
.
dup
,
:push_hooks
)
CreateCommitBuildsService
.
new
.
execute
(
project
,
@user
,
@push_data
)
CreateCommitBuildsService
.
new
.
execute
(
project
,
@user
,
@push_data
,
mirror_update:
mirror_update
)
ProjectCacheWorker
.
perform_async
(
project
.
id
)
ProjectCacheWorker
.
perform_async
(
project
.
id
)
end
end
...
...
app/services/git_tag_push_service.rb
View file @
996ae12c
class
GitTagPushService
class
GitTagPushService
attr_accessor
:project
,
:user
,
:push_data
attr_accessor
:project
,
:user
,
:push_data
def
execute
(
project
,
user
,
oldrev
,
newrev
,
ref
)
def
execute
(
project
,
user
,
oldrev
,
newrev
,
ref
,
mirror_update:
false
)
project
.
repository
.
expire_cache
project
.
repository
.
expire_cache
@project
,
@user
=
project
,
user
@project
,
@user
=
project
,
user
...
@@ -10,7 +10,7 @@ class GitTagPushService
...
@@ -10,7 +10,7 @@ class GitTagPushService
EventCreateService
.
new
.
push
(
project
,
user
,
@push_data
)
EventCreateService
.
new
.
push
(
project
,
user
,
@push_data
)
project
.
execute_hooks
(
@push_data
.
dup
,
:tag_push_hooks
)
project
.
execute_hooks
(
@push_data
.
dup
,
:tag_push_hooks
)
project
.
execute_services
(
@push_data
.
dup
,
:tag_push_hooks
)
project
.
execute_services
(
@push_data
.
dup
,
:tag_push_hooks
)
CreateCommitBuildsService
.
new
.
execute
(
project
,
@user
,
@push_data
)
CreateCommitBuildsService
.
new
.
execute
(
project
,
@user
,
@push_data
,
mirror_update:
mirror_update
)
ProjectCacheWorker
.
perform_async
(
project
.
id
)
ProjectCacheWorker
.
perform_async
(
project
.
id
)
true
true
...
...
app/services/projects/update_mirror_service.rb
View file @
996ae12c
...
@@ -43,7 +43,7 @@ module Projects
...
@@ -43,7 +43,7 @@ module Projects
else
else
begin
begin
repository
.
ff_merge
(
current_user
,
upstream_branch
.
target
,
name
)
repository
.
ff_merge
(
current_user
,
upstream_branch
.
target
,
name
)
rescue
Repository
::
PreReceiveError
,
Repository
::
CommitError
=>
e
rescue
GitHooksService
::
PreReceiveError
,
Repository
::
CommitError
=>
e
raise
UpdateError
,
e
.
message
raise
UpdateError
,
e
.
message
end
end
end
end
...
@@ -66,7 +66,7 @@ module Projects
...
@@ -66,7 +66,7 @@ module Projects
next
if
old_tag_target
==
tag
.
target
next
if
old_tag_target
==
tag
.
target
GitTagPushService
.
new
.
execute
(
project
,
current_user
,
old_tag_target
,
tag
.
target
,
"
#{
Gitlab
::
Git
::
TAG_REF_PREFIX
}#{
tag
.
name
}
"
)
GitTagPushService
.
new
.
execute
(
project
,
current_user
,
old_tag_target
,
tag
.
target
,
"
#{
Gitlab
::
Git
::
TAG_REF_PREFIX
}#{
tag
.
name
}
"
,
mirror_update:
true
)
end
end
fetch_result
fetch_result
...
...
app/views/projects/edit.html.haml
View file @
996ae12c
...
@@ -162,6 +162,8 @@
...
@@ -162,6 +162,8 @@
phpunit --coverage-text --colors=never (PHP) -
phpunit --coverage-text --colors=never (PHP) -
%code
^\s*Lines:\s*\d+.\d+\%
%code
^\s*Lines:\s*\d+.\d+\%
-
if
@project
.
mirror?
=
render
'shared/mirror_trigger_builds_setting'
,
f:
f
%fieldset
.features
%fieldset
.features
%legend
%legend
...
...
app/views/projects/mirrors/show.html.haml
View file @
996ae12c
...
@@ -66,5 +66,8 @@
...
@@ -66,5 +66,8 @@
like new branches being created or new commits being pushed to existing branches.
like new branches being created or new commits being pushed to existing branches.
They need to have at least master access to this project.
They need to have at least master access to this project.
-
if
@project
.
builds_enabled?
=
render
'shared/mirror_trigger_builds_setting'
,
f:
f
.form-actions
.form-actions
=
f
.
submit
"Save Changes"
,
class:
"btn btn-create"
=
f
.
submit
"Save Changes"
,
class:
"btn btn-create"
app/views/shared/_mirror_trigger_builds_setting.html.haml
0 → 100644
View file @
996ae12c
.form-group
.col-sm-offset-2.col-sm-10
.checkbox
=
f
.
label
:mirror_trigger_builds
do
=
f
.
check_box
:mirror_trigger_builds
%strong
Trigger builds for mirror updates
.help-block
Trigger builds when branches or tags are updated from the upstream repository.
Depending on the activity of the upstream repository, this may greatly increase the load on your CI runners.
Only enable this if you know they can handle the load.
db/migrate/20160119170055_add_mirror_trigger_builds_to_projects.rb
0 → 100644
View file @
996ae12c
class
AddMirrorTriggerBuildsToProjects
<
ActiveRecord
::
Migration
def
change
add_column
:projects
,
:mirror_trigger_builds
,
:boolean
,
default:
false
,
null:
false
end
end
db/schema.rb
View file @
996ae12c
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#
#
# It's strongly recommended that you check this file into your version control system.
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
2016011
3111034
)
do
ActiveRecord
::
Schema
.
define
(
version:
2016011
9170055
)
do
# These are extensions that must be enabled in order to support this database
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
enable_extension
"plpgsql"
...
@@ -763,6 +763,7 @@ ActiveRecord::Schema.define(version: 20160113111034) do
...
@@ -763,6 +763,7 @@ ActiveRecord::Schema.define(version: 20160113111034) do
t
.
string
"build_coverage_regex"
t
.
string
"build_coverage_regex"
t
.
boolean
"build_allow_git_fetch"
,
default:
true
,
null:
false
t
.
boolean
"build_allow_git_fetch"
,
default:
true
,
null:
false
t
.
integer
"build_timeout"
,
default:
3600
,
null:
false
t
.
integer
"build_timeout"
,
default:
3600
,
null:
false
t
.
boolean
"mirror_trigger_builds"
,
default:
false
,
null:
false
end
end
add_index
"projects"
,
[
"builds_enabled"
,
"shared_runners_enabled"
],
name:
"index_projects_on_builds_enabled_and_shared_runners_enabled"
,
using: :btree
add_index
"projects"
,
[
"builds_enabled"
,
"shared_runners_enabled"
],
name:
"index_projects_on_builds_enabled_and_shared_runners_enabled"
,
using: :btree
...
...
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