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
Boxiang Sun
gitlab-ce
Commits
1556d484
Commit
1556d484
authored
Jul 15, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Track a user who created a pipeline
parent
8b7932c2
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
31 additions
and
6 deletions
+31
-6
CHANGELOG
CHANGELOG
+1
-0
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+2
-0
app/models/project.rb
app/models/project.rb
+2
-2
app/models/user.rb
app/models/user.rb
+1
-0
app/services/ci/create_pipeline_service.rb
app/services/ci/create_pipeline_service.rb
+1
-0
app/services/create_commit_builds_service.rb
app/services/create_commit_builds_service.rb
+7
-1
db/migrate/20160715132507_add_user_id_to_pipeline.rb
db/migrate/20160715132507_add_user_id_to_pipeline.rb
+7
-0
db/schema.rb
db/schema.rb
+2
-1
lib/api/commit_statuses.rb
lib/api/commit_statuses.rb
+1
-1
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+3
-0
spec/models/user_spec.rb
spec/models/user_spec.rb
+2
-0
spec/services/create_commit_builds_service_spec.rb
spec/services/create_commit_builds_service_spec.rb
+2
-1
No files found.
CHANGELOG
View file @
1556d484
...
@@ -53,6 +53,7 @@ v 8.10.0 (unreleased)
...
@@ -53,6 +53,7 @@ v 8.10.0 (unreleased)
- Fix user creation with stronger minimum password requirements !4054 (nathan-pmt)
- Fix user creation with stronger minimum password requirements !4054 (nathan-pmt)
- Only show New Snippet button to users that can create snippets.
- Only show New Snippet button to users that can create snippets.
- PipelinesFinder uses git cache data
- PipelinesFinder uses git cache data
- Track a user who created a pipeline
- Actually render old and new sections of parallel diff next to each other
- Actually render old and new sections of parallel diff next to each other
- Throttle the update of `project.pushes_since_gc` to 1 minute.
- Throttle the update of `project.pushes_since_gc` to 1 minute.
- Allow expanding and collapsing files in diff view (!4990)
- Allow expanding and collapsing files in diff view (!4990)
...
...
app/models/ci/pipeline.rb
View file @
1556d484
...
@@ -6,6 +6,8 @@ module Ci
...
@@ -6,6 +6,8 @@ module Ci
self
.
table_name
=
'ci_commits'
self
.
table_name
=
'ci_commits'
belongs_to
:project
,
class_name:
'::Project'
,
foreign_key: :gl_project_id
belongs_to
:project
,
class_name:
'::Project'
,
foreign_key: :gl_project_id
belongs_to
:user
has_many
:statuses
,
class_name:
'CommitStatus'
,
foreign_key: :commit_id
has_many
:statuses
,
class_name:
'CommitStatus'
,
foreign_key: :commit_id
has_many
:builds
,
class_name:
'Ci::Build'
,
foreign_key: :commit_id
has_many
:builds
,
class_name:
'Ci::Build'
,
foreign_key: :commit_id
has_many
:trigger_requests
,
dependent: :destroy
,
class_name:
'Ci::TriggerRequest'
,
foreign_key: :commit_id
has_many
:trigger_requests
,
dependent: :destroy
,
class_name:
'Ci::TriggerRequest'
,
foreign_key: :commit_id
...
...
app/models/project.rb
View file @
1556d484
...
@@ -1038,8 +1038,8 @@ class Project < ActiveRecord::Base
...
@@ -1038,8 +1038,8 @@ class Project < ActiveRecord::Base
pipelines
.
order
(
id: :desc
).
find_by
(
sha:
sha
,
ref:
ref
)
pipelines
.
order
(
id: :desc
).
find_by
(
sha:
sha
,
ref:
ref
)
end
end
def
ensure_pipeline
(
sha
,
ref
)
def
ensure_pipeline
(
sha
,
ref
,
current_user
=
nil
)
pipeline
(
sha
,
ref
)
||
pipelines
.
create
(
sha:
sha
,
ref:
ref
)
pipeline
(
sha
,
ref
)
||
pipelines
.
create
(
sha:
sha
,
ref:
ref
,
user:
current_user
)
end
end
def
enable_ci
def
enable_ci
...
...
app/models/user.rb
View file @
1556d484
...
@@ -85,6 +85,7 @@ class User < ActiveRecord::Base
...
@@ -85,6 +85,7 @@ class User < ActiveRecord::Base
has_one
:abuse_report
,
dependent: :destroy
has_one
:abuse_report
,
dependent: :destroy
has_many
:spam_logs
,
dependent: :destroy
has_many
:spam_logs
,
dependent: :destroy
has_many
:builds
,
dependent: :nullify
,
class_name:
'Ci::Build'
has_many
:builds
,
dependent: :nullify
,
class_name:
'Ci::Build'
has_many
:pipelines
,
dependent: :nullify
,
class_name:
'Ci::Pipeline'
has_many
:todos
,
dependent: :destroy
has_many
:todos
,
dependent: :destroy
has_many
:notification_settings
,
dependent: :destroy
has_many
:notification_settings
,
dependent: :destroy
has_many
:award_emoji
,
dependent: :destroy
has_many
:award_emoji
,
dependent: :destroy
...
...
app/services/ci/create_pipeline_service.rb
View file @
1556d484
...
@@ -2,6 +2,7 @@ module Ci
...
@@ -2,6 +2,7 @@ module Ci
class
CreatePipelineService
<
BaseService
class
CreatePipelineService
<
BaseService
def
execute
def
execute
pipeline
=
project
.
pipelines
.
new
(
params
)
pipeline
=
project
.
pipelines
.
new
(
params
)
pipeline
.
user
=
current_user
unless
ref_names
.
include?
(
params
[
:ref
])
unless
ref_names
.
include?
(
params
[
:ref
])
pipeline
.
errors
.
add
(
:base
,
'Reference not found'
)
pipeline
.
errors
.
add
(
:base
,
'Reference not found'
)
...
...
app/services/create_commit_builds_service.rb
View file @
1556d484
...
@@ -14,7 +14,13 @@ class CreateCommitBuildsService
...
@@ -14,7 +14,13 @@ class CreateCommitBuildsService
return
false
return
false
end
end
@pipeline
=
Ci
::
Pipeline
.
new
(
project:
project
,
sha:
sha
,
ref:
ref
,
before_sha:
before_sha
,
tag:
tag
)
@pipeline
=
Ci
::
Pipeline
.
new
(
project:
project
,
sha:
sha
,
ref:
ref
,
before_sha:
before_sha
,
tag:
tag
,
user:
user
)
##
##
# Skip creating pipeline if no gitlab-ci.yml is found
# Skip creating pipeline if no gitlab-ci.yml is found
...
...
db/migrate/20160715132507_add_user_id_to_pipeline.rb
0 → 100644
View file @
1556d484
class
AddUserIdToPipeline
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
def
change
add_column
:ci_commits
,
:user_id
,
:integer
end
end
db/schema.rb
View file @
1556d484
...
@@ -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:
2016071
2171823
)
do
ActiveRecord
::
Schema
.
define
(
version:
2016071
5132507
)
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"
...
@@ -199,6 +199,7 @@ ActiveRecord::Schema.define(version: 20160712171823) do
...
@@ -199,6 +199,7 @@ ActiveRecord::Schema.define(version: 20160712171823) do
t
.
datetime
"started_at"
t
.
datetime
"started_at"
t
.
datetime
"finished_at"
t
.
datetime
"finished_at"
t
.
integer
"duration"
t
.
integer
"duration"
t
.
integer
"user_id"
end
end
add_index
"ci_commits"
,
[
"gl_project_id"
,
"sha"
],
name:
"index_ci_commits_on_gl_project_id_and_sha"
,
using: :btree
add_index
"ci_commits"
,
[
"gl_project_id"
,
"sha"
],
name:
"index_ci_commits_on_gl_project_id_and_sha"
,
using: :btree
...
...
lib/api/commit_statuses.rb
View file @
1556d484
...
@@ -64,7 +64,7 @@ module API
...
@@ -64,7 +64,7 @@ module API
ref
=
branches
.
first
ref
=
branches
.
first
end
end
pipeline
=
@project
.
ensure_pipeline
(
commit
.
sha
,
ref
)
pipeline
=
@project
.
ensure_pipeline
(
commit
.
sha
,
ref
,
current_user
)
name
=
params
[
:name
]
||
params
[
:context
]
name
=
params
[
:name
]
||
params
[
:context
]
status
=
GenericCommitStatus
.
running_or_pending
.
find_by
(
pipeline:
pipeline
,
name:
name
,
ref:
params
[
:ref
])
status
=
GenericCommitStatus
.
running_or_pending
.
find_by
(
pipeline:
pipeline
,
name:
name
,
ref:
params
[
:ref
])
...
...
spec/models/ci/pipeline_spec.rb
View file @
1556d484
...
@@ -5,9 +5,12 @@ describe Ci::Pipeline, models: true do
...
@@ -5,9 +5,12 @@ describe Ci::Pipeline, models: true do
let
(
:pipeline
)
{
FactoryGirl
.
create
:ci_pipeline
,
project:
project
}
let
(
:pipeline
)
{
FactoryGirl
.
create
:ci_pipeline
,
project:
project
}
it
{
is_expected
.
to
belong_to
(
:project
)
}
it
{
is_expected
.
to
belong_to
(
:project
)
}
it
{
is_expected
.
to
belong_to
(
:user
)
}
it
{
is_expected
.
to
have_many
(
:statuses
)
}
it
{
is_expected
.
to
have_many
(
:statuses
)
}
it
{
is_expected
.
to
have_many
(
:trigger_requests
)
}
it
{
is_expected
.
to
have_many
(
:trigger_requests
)
}
it
{
is_expected
.
to
have_many
(
:builds
)
}
it
{
is_expected
.
to
have_many
(
:builds
)
}
it
{
is_expected
.
to
validate_presence_of
:sha
}
it
{
is_expected
.
to
validate_presence_of
:sha
}
it
{
is_expected
.
to
validate_presence_of
:status
}
it
{
is_expected
.
to
validate_presence_of
:status
}
...
...
spec/models/user_spec.rb
View file @
1556d484
...
@@ -31,6 +31,8 @@ describe User, models: true do
...
@@ -31,6 +31,8 @@ describe User, models: true do
it
{
is_expected
.
to
have_many
(
:spam_logs
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:spam_logs
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:todos
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:todos
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:award_emoji
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:award_emoji
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:builds
).
dependent
(
:nullify
)
}
it
{
is_expected
.
to
have_many
(
:pipelines
).
dependent
(
:nullify
)
}
describe
'#group_members'
do
describe
'#group_members'
do
it
'does not include group memberships for which user is a requester'
do
it
'does not include group memberships for which user is a requester'
do
...
...
spec/services/create_commit_builds_service_spec.rb
View file @
1556d484
...
@@ -3,7 +3,7 @@ require 'spec_helper'
...
@@ -3,7 +3,7 @@ require 'spec_helper'
describe
CreateCommitBuildsService
,
services:
true
do
describe
CreateCommitBuildsService
,
services:
true
do
let
(
:service
)
{
CreateCommitBuildsService
.
new
}
let
(
:service
)
{
CreateCommitBuildsService
.
new
}
let
(
:project
)
{
FactoryGirl
.
create
(
:empty_project
)
}
let
(
:project
)
{
FactoryGirl
.
create
(
:empty_project
)
}
let
(
:user
)
{
nil
}
let
(
:user
)
{
create
(
:user
)
}
before
do
before
do
stub_ci_pipeline_to_return_yaml_file
stub_ci_pipeline_to_return_yaml_file
...
@@ -24,6 +24,7 @@ describe CreateCommitBuildsService, services: true do
...
@@ -24,6 +24,7 @@ describe CreateCommitBuildsService, services: true do
it
{
expect
(
pipeline
).
to
be_valid
}
it
{
expect
(
pipeline
).
to
be_valid
}
it
{
expect
(
pipeline
).
to
be_persisted
}
it
{
expect
(
pipeline
).
to
be_persisted
}
it
{
expect
(
pipeline
).
to
eq
(
project
.
pipelines
.
last
)
}
it
{
expect
(
pipeline
).
to
eq
(
project
.
pipelines
.
last
)
}
it
{
expect
(
pipeline
).
to
have_attributes
(
:user
=>
user
)
}
it
{
expect
(
pipeline
.
builds
.
first
).
to
be_kind_of
(
Ci
::
Build
)
}
it
{
expect
(
pipeline
.
builds
.
first
).
to
be_kind_of
(
Ci
::
Build
)
}
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