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
0
Merge Requests
0
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
iv
gitlab-ce
Commits
29a7c679
Commit
29a7c679
authored
Oct 05, 2015
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix GitLabCiService and remove ci_yaml_file from CI push data
parent
c9853897
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
43 deletions
+13
-43
app/models/project_services/gitlab_ci_service.rb
app/models/project_services/gitlab_ci_service.rb
+2
-21
spec/models/project_services/gitlab_ci_service_spec.rb
spec/models/project_services/gitlab_ci_service_spec.rb
+4
-4
spec/requests/ci/api/commits_spec.rb
spec/requests/ci/api/commits_spec.rb
+1
-2
spec/services/ci/create_commit_service_spec.rb
spec/services/ci/create_commit_service_spec.rb
+6
-16
No files found.
app/models/project_services/gitlab_ci_service.rb
View file @
29a7c679
...
@@ -40,18 +40,9 @@ class GitlabCiService < CiService
...
@@ -40,18 +40,9 @@ class GitlabCiService < CiService
def
execute
(
data
)
def
execute
(
data
)
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
sha
=
data
[
:checkout_sha
]
ci_project
=
project
.
gitlab_ci_project
if
sha
.
present?
file
=
ci_yaml_file
(
sha
)
if
file
&&
file
.
data
data
.
merge!
(
ci_yaml_file:
file
.
data
)
end
end
ci_project
=
Ci
::
Project
.
find_by
(
gitlab_id:
project
.
id
)
if
ci_project
if
ci_project
current_user
=
User
.
find_by
(
id:
data
[
:user_id
])
Ci
::
CreateCommitService
.
new
.
execute
(
ci_project
,
current_user
,
data
)
Ci
::
CreateCommitService
.
new
.
execute
(
ci_project
,
current_user
,
data
)
end
end
end
end
...
@@ -99,14 +90,4 @@ class GitlabCiService < CiService
...
@@ -99,14 +90,4 @@ class GitlabCiService < CiService
def
fields
def
fields
[]
[]
end
end
private
def
ci_yaml_file
(
sha
)
repository
.
blob_at
(
sha
,
'.gitlab-ci.yml'
)
end
def
repository
project
.
repository
end
end
end
spec/models/project_services/gitlab_ci_service_spec.rb
View file @
29a7c679
...
@@ -39,8 +39,8 @@ describe GitlabCiService do
...
@@ -39,8 +39,8 @@ describe GitlabCiService do
end
end
describe
:build_page
do
describe
:build_page
do
it
{
expect
(
@service
.
build_page
(
"2ab7834c"
,
'master'
)).
to
eq
(
"http://localhost/ci/projects/
#{
@ci_project
.
id
}
/
refs/master/
commits/2ab7834c"
)}
it
{
expect
(
@service
.
build_page
(
"2ab7834c"
,
'master'
)).
to
eq
(
"http://localhost/ci/projects/
#{
@ci_project
.
id
}
/commits/2ab7834c"
)}
it
{
expect
(
@service
.
build_page
(
"issue#2"
,
'master'
)).
to
eq
(
"http://localhost/ci/projects/
#{
@ci_project
.
id
}
/
refs/master/
commits/issue%232"
)}
it
{
expect
(
@service
.
build_page
(
"issue#2"
,
'master'
)).
to
eq
(
"http://localhost/ci/projects/
#{
@ci_project
.
id
}
/commits/issue%232"
)}
end
end
describe
"execute"
do
describe
"execute"
do
...
@@ -48,8 +48,8 @@ describe GitlabCiService do
...
@@ -48,8 +48,8 @@ describe GitlabCiService do
let
(
:project
)
{
create
(
:project
,
name:
'project'
)
}
let
(
:project
)
{
create
(
:project
,
name:
'project'
)
}
let
(
:push_sample_data
)
{
Gitlab
::
PushDataBuilder
.
build_sample
(
project
,
user
)
}
let
(
:push_sample_data
)
{
Gitlab
::
PushDataBuilder
.
build_sample
(
project
,
user
)
}
it
"calls
ci_yaml_fil
e"
do
it
"calls
CreateCommitServic
e"
do
expect
(
@service
).
to
receive
(
:ci_yaml_file
).
with
(
push_sample_data
[
:checkout_sha
]
)
expect
_any_instance_of
(
Ci
::
CreateCommitService
).
to
receive
(
:execute
).
with
(
@ci_project
,
user
,
push_sample_data
)
@service
.
execute
(
push_sample_data
)
@service
.
execute
(
push_sample_data
)
end
end
...
...
spec/requests/ci/api/commits_spec.rb
View file @
29a7c679
...
@@ -44,8 +44,7 @@ describe Ci::API::API, 'Commits' do
...
@@ -44,8 +44,7 @@ describe Ci::API::API, 'Commits' do
"email"
=>
"jordi@softcatala.org"
,
"email"
=>
"jordi@softcatala.org"
,
}
}
}
}
],
]
ci_yaml_file:
gitlab_ci_yaml
}
}
end
end
...
...
spec/services/ci/create_commit_service_spec.rb
View file @
29a7c679
...
@@ -17,7 +17,6 @@ module Ci
...
@@ -17,7 +17,6 @@ module Ci
ref:
'refs/heads/master'
,
ref:
'refs/heads/master'
,
before:
'00000000'
,
before:
'00000000'
,
after:
'31das312'
,
after:
'31das312'
,
ci_yaml_file:
gitlab_ci_yaml
,
commits:
[
{
message:
"Message"
}
]
commits:
[
{
message:
"Message"
}
]
)
)
end
end
...
@@ -35,7 +34,6 @@ module Ci
...
@@ -35,7 +34,6 @@ module Ci
ref:
'refs/tags/0_1'
,
ref:
'refs/tags/0_1'
,
before:
'00000000'
,
before:
'00000000'
,
after:
'31das312'
,
after:
'31das312'
,
ci_yaml_file:
gitlab_ci_yaml
,
commits:
[
{
message:
"Message"
}
]
commits:
[
{
message:
"Message"
}
]
)
)
expect
(
result
).
to
be_persisted
expect
(
result
).
to
be_persisted
...
@@ -49,7 +47,6 @@ module Ci
...
@@ -49,7 +47,6 @@ module Ci
ref:
'refs/heads/0_1'
,
ref:
'refs/heads/0_1'
,
before:
'00000000'
,
before:
'00000000'
,
after:
'31das312'
,
after:
'31das312'
,
ci_yaml_file:
config
,
commits:
[
{
message:
"Message"
}
]
commits:
[
{
message:
"Message"
}
]
)
)
expect
(
result
).
to
be_persisted
expect
(
result
).
to
be_persisted
...
@@ -62,7 +59,6 @@ module Ci
...
@@ -62,7 +59,6 @@ module Ci
ref:
'refs/heads/0_1'
,
ref:
'refs/heads/0_1'
,
before:
'00000000'
,
before:
'00000000'
,
after:
'31das312'
,
after:
'31das312'
,
ci_yaml_file:
nil
,
commits:
[
{
message:
'Message'
}
]
commits:
[
{
message:
'Message'
}
]
)
)
expect
(
result
).
to
be_persisted
expect
(
result
).
to
be_persisted
...
@@ -83,8 +79,7 @@ module Ci
...
@@ -83,8 +79,7 @@ module Ci
ref:
'refs/tags/0_1'
,
ref:
'refs/tags/0_1'
,
before:
'00000000'
,
before:
'00000000'
,
after:
'31das312'
,
after:
'31das312'
,
commits:
commits
,
commits:
commits
ci_yaml_file:
gitlab_ci_yaml
)
)
expect
(
commit
.
builds
.
any?
).
to
be
false
expect
(
commit
.
builds
.
any?
).
to
be
false
expect
(
commit
.
status
).
to
eq
(
"skipped"
)
expect
(
commit
.
status
).
to
eq
(
"skipped"
)
...
@@ -98,8 +93,7 @@ module Ci
...
@@ -98,8 +93,7 @@ module Ci
ref:
'refs/tags/0_1'
,
ref:
'refs/tags/0_1'
,
before:
'00000000'
,
before:
'00000000'
,
after:
'31das312'
,
after:
'31das312'
,
commits:
commits
,
commits:
commits
ci_yaml_file:
gitlab_ci_yaml
)
)
expect
(
commit
.
builds
.
first
.
name
).
to
eq
(
"staging"
)
expect
(
commit
.
builds
.
first
.
name
).
to
eq
(
"staging"
)
...
@@ -112,8 +106,7 @@ module Ci
...
@@ -112,8 +106,7 @@ module Ci
ref:
'refs/tags/0_1'
,
ref:
'refs/tags/0_1'
,
before:
'00000000'
,
before:
'00000000'
,
after:
'31das312'
,
after:
'31das312'
,
commits:
commits
,
commits:
commits
ci_yaml_file:
"invalid: file"
)
)
expect
(
commit
.
builds
.
any?
).
to
be
false
expect
(
commit
.
builds
.
any?
).
to
be
false
expect
(
commit
.
status
).
to
eq
(
"skipped"
)
expect
(
commit
.
status
).
to
eq
(
"skipped"
)
...
@@ -128,8 +121,7 @@ module Ci
...
@@ -128,8 +121,7 @@ module Ci
ref:
'refs/heads/master'
,
ref:
'refs/heads/master'
,
before:
'00000000'
,
before:
'00000000'
,
after:
'31das312'
,
after:
'31das312'
,
commits:
commits
,
commits:
commits
ci_yaml_file:
gitlab_ci_yaml
)
)
expect
(
commit
.
builds
.
count
(
:all
)).
to
eq
(
2
)
expect
(
commit
.
builds
.
count
(
:all
)).
to
eq
(
2
)
...
@@ -137,8 +129,7 @@ module Ci
...
@@ -137,8 +129,7 @@ module Ci
ref:
'refs/heads/master'
,
ref:
'refs/heads/master'
,
before:
'00000000'
,
before:
'00000000'
,
after:
'31das312'
,
after:
'31das312'
,
commits:
commits
,
commits:
commits
ci_yaml_file:
gitlab_ci_yaml
)
)
expect
(
commit
.
builds
.
count
(
:all
)).
to
eq
(
2
)
expect
(
commit
.
builds
.
count
(
:all
)).
to
eq
(
2
)
end
end
...
@@ -152,8 +143,7 @@ module Ci
...
@@ -152,8 +143,7 @@ module Ci
ref:
'refs/tags/0_1'
,
ref:
'refs/tags/0_1'
,
before:
'00000000'
,
before:
'00000000'
,
after:
'31das312'
,
after:
'31das312'
,
commits:
commits
,
commits:
commits
ci_yaml_file:
"invalid: file"
)
)
expect
(
commit
.
status
).
to
eq
(
"failed"
)
expect
(
commit
.
status
).
to
eq
(
"failed"
)
...
...
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