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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
69c04498
Commit
69c04498
authored
Oct 12, 2015
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small bug fixes
parent
0aefeeb8
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
22 deletions
+39
-22
app/models/ci/build.rb
app/models/ci/build.rb
+12
-4
app/models/commit_status.rb
app/models/commit_status.rb
+16
-7
app/views/projects/commit_statuses/_commit_status.html.haml
app/views/projects/commit_statuses/_commit_status.html.haml
+8
-8
doc/api/commits.md
doc/api/commits.md
+0
-1
lib/api/commit_statuses.rb
lib/api/commit_statuses.rb
+3
-2
No files found.
app/models/ci/build.rb
View file @
69c04498
...
...
@@ -212,15 +212,23 @@ module Ci
"
#{
dir_to_trace
}
/
#{
id
}
.log"
end
def
description
name
end
def
target_url
Gitlab
::
Application
.
routes
.
url_helpers
.
namespace_project_build_url
(
gl_project
.
namespace
,
gl_project
,
self
)
end
def
cancel_url
if
active?
cancel_namespace_project_build_path
(
gl_project
.
namespace
,
gl_project
,
self
,
return_to:
request
.
original_url
)
end
end
def
retry_url
if
commands
.
present?
cancel_namespace_project_build_path
(
gl_project
.
namespace
,
gl_project
,
self
,
return_to:
request
.
original_url
)
end
end
private
def
yaml_variables
...
...
app/models/commit_status.rb
View file @
69c04498
...
...
@@ -11,14 +11,14 @@ class CommitStatus < ActiveRecord::Base
alias_attribute
:author
,
:user
scope
:running
,
->
()
{
where
(
status:
'running'
)
}
scope
:pending
,
->
()
{
where
(
status:
'pending'
)
}
scope
:success
,
->
()
{
where
(
status:
'success'
)
}
scope
:failed
,
->
()
{
where
(
status:
'failed'
)
}
scope
:running_or_pending
,
->
()
{
where
(
status
:[
:running
,
:pending
])
}
scope
:latest
,
->
()
{
where
(
id:
unscope
(
:select
).
select
(
'max(id)'
).
group
(
:name
,
:ref
)).
order
(
stage_idx: :asc
)
}
scope
:running
,
->
{
where
(
status:
'running'
)
}
scope
:pending
,
->
{
where
(
status:
'pending'
)
}
scope
:success
,
->
{
where
(
status:
'success'
)
}
scope
:failed
,
->
{
where
(
status:
'failed'
)
}
scope
:running_or_pending
,
->
{
where
(
status
:[
:running
,
:pending
])
}
scope
:latest
,
->
{
where
(
id:
unscope
(
:select
).
select
(
'max(id)'
).
group
(
:name
,
:ref
)).
order
(
stage_idx: :asc
)
}
scope
:for_ref
,
->
(
ref
)
{
where
(
ref:
[
ref
,
nil
])
}
scope
:running_or_pending
,
->
()
{
where
(
status:
[
:running
,
:pending
])
}
scope
:running_or_pending
,
->
{
where
(
status:
[
:running
,
:pending
])
}
state_machine
:status
,
initial: :pending
do
event
:run
do
...
...
@@ -55,6 +55,7 @@ class CommitStatus < ActiveRecord::Base
delegate
:sha
,
:short_sha
,
:gl_project
,
to: :commit
,
prefix:
false
# TODO: this should be removed with all references
def
before_sha
Gitlab
::
Git
::
BLANK_SHA
end
...
...
@@ -78,4 +79,12 @@ class CommitStatus < ActiveRecord::Base
Time
.
now
-
started_at
end
end
def
cancel_url
nil
end
def
retry_url
nil
end
end
app/views/projects/commit_statuses/_commit_status.html.haml
View file @
69c04498
...
...
@@ -9,7 +9,7 @@
-
else
%strong
Build ##{commit_status.id}
-
if
defined?
(
ref
)
-
if
defined?
(
ref
)
&&
ref
%td
=
commit_status
.
ref
...
...
@@ -17,7 +17,7 @@
=
commit_status
.
stage
%td
=
commit_status
.
description
=
commit_status
.
name
.pull-right
-
if
commit_status
.
tags
.
any?
-
commit_status
.
tags
.
each
do
|
tag
|
...
...
@@ -36,17 +36,17 @@
-
if
commit_status
.
finished_at
%span
#{
time_ago_in_words
commit_status
.
finished_at
}
ago
-
if
defined?
(
coverage
)
-
if
defined?
(
coverage
)
&&
coverage
%td
.coverage
-
if
commit_status
.
try
(
:coverage
)
#{
commit_status
.
coverage
}
%
%td
-
if
defined?
(
controls
)
&&
current_user
&&
can?
(
current_user
,
:manage_builds
,
gl_project
)
-
if
defined?
(
controls
)
&&
c
ontrols
&&
c
urrent_user
&&
can?
(
current_user
,
:manage_builds
,
gl_project
)
.pull-right
-
if
commit_status
.
active?
=
link_to
c
ancel_namespace_project_build_path
(
gl_project
.
namespace
,
gl_project
,
commit_status
,
return_to:
request
.
original_url
),
title:
'Cancel commit_status
'
do
-
if
commit_status
.
cancel_url
=
link_to
c
ommit_status
.
cancel_url
,
title:
'Cancel
'
do
%i
.fa.fa-remove.cred
-
elsif
commit_status
.
commands
.
present?
=
link_to
retry_namespace_project_build_path
(
gl_project
.
namespace
,
gl_project
,
commit_status
,
return_to:
request
.
original_url
),
method: :post
,
title:
'Retry commit_status
'
do
-
elsif
commit_status
.
retry_url
=
link_to
commit_status
.
retry_url
,
method: :post
,
title:
'Retry
'
do
%i
.fa.fa-repeat
doc/api/commits.md
View file @
69c04498
...
...
@@ -203,7 +203,6 @@ Parameters:
## Post the status to commit
Adds or updates a status of a commit.
Optionally you can post comments on a specific line of a commit. Therefor both
`path`
,
`line_new`
and
`line_old`
are required.
```
POST /projects/:id/statuses/:sha
...
...
lib/api/commit_statuses.rb
View file @
69c04498
...
...
@@ -5,7 +5,6 @@ module API
class
CommitStatus
<
Grape
::
API
resource
:projects
do
before
{
authenticate!
}
before
{
authorize!
:read_commit_statuses
,
user_project
}
# Get a commit's statuses
#
...
...
@@ -19,13 +18,14 @@ module API
# Examples:
# GET /projects/:id/repository/commits/:sha/statuses
get
':id/repository/commits/:sha/statuses'
do
authorize!
:read_commit_statuses
,
user_project
sha
=
params
[
:sha
]
ci_commit
=
user_project
.
ci_commit
(
sha
)
not_found!
'Commit'
unless
ci_commit
statuses
=
ci_commit
.
statuses
statuses
=
statuses
.
latest
unless
parse_boolean
(
params
[
:all
])
statuses
=
statuses
.
where
(
ref:
params
[
:ref
])
if
params
[
:ref
].
present?
statuses
=
statuses
.
where
(
nam
e:
params
[
:stage
])
if
params
[
:stage
].
present?
statuses
=
statuses
.
where
(
stag
e:
params
[
:stage
])
if
params
[
:stage
].
present?
statuses
=
statuses
.
where
(
name:
params
[
:name
])
if
params
[
:name
].
present?
present
paginate
(
statuses
),
with:
Entities
::
CommitStatus
end
...
...
@@ -43,6 +43,7 @@ module API
# Examples:
# POST /projects/:id/statuses/:sha
post
':id/statuses/:sha'
do
authorize!
:create_commit_statuses
,
user_project
required_attributes!
[
:state
]
attrs
=
attributes_for_keys
[
:ref
,
:target_url
,
:description
,
:context
,
:name
]
commit
=
@project
.
commit
(
params
[
:sha
])
...
...
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