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
1e06cabf
Commit
1e06cabf
authored
Oct 07, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove Ci::Commit and Ci::Build controllers
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
3fa2cb93
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
71 additions
and
137 deletions
+71
-137
app/controllers/ci/builds_controller.rb
app/controllers/ci/builds_controller.rb
+0
-52
app/controllers/ci/commits_controller.rb
app/controllers/ci/commits_controller.rb
+0
-32
app/controllers/projects/builds_controller.rb
app/controllers/projects/builds_controller.rb
+30
-0
app/controllers/projects/commit_controller.rb
app/controllers/projects/commit_controller.rb
+8
-0
app/views/projects/builds/_build.html.haml
app/views/projects/builds/_build.html.haml
+2
-2
app/views/projects/builds/show.html.haml
app/views/projects/builds/show.html.haml
+2
-2
app/views/projects/commit/ci.html.haml
app/views/projects/commit/ci.html.haml
+1
-1
config/routes.rb
config/routes.rb
+8
-16
spec/features/builds_spec.rb
spec/features/builds_spec.rb
+20
-1
spec/features/ci/builds_spec.rb
spec/features/ci/builds_spec.rb
+0
-31
No files found.
app/controllers/ci/builds_controller.rb
deleted
100644 → 0
View file @
3fa2cb93
module
Ci
class
BuildsController
<
Ci
::
ApplicationController
before_action
:authenticate_user!
,
except:
[
:status
]
before_action
:project
before_action
:authorize_access_project!
,
except:
[
:status
]
before_action
:authorize_manage_project!
,
except:
[
:status
,
:retry
,
:cancel
]
before_action
:authorize_manage_builds!
,
only:
[
:retry
,
:cancel
]
before_action
:build
def
retry
if
@build
.
commands
.
blank?
return
page_404
end
build
=
Ci
::
Build
.
retry
(
@build
)
if
params
[
:return_to
]
redirect_to
URI
.
parse
(
params
[
:return_to
]).
path
else
redirect_to
build_path
(
build
)
end
end
def
status
render
json:
@build
.
to_json
(
only:
[
:status
,
:id
,
:sha
,
:coverage
],
methods: :sha
)
end
def
cancel
@build
.
cancel
redirect_to
build_path
(
@build
)
end
protected
def
project
@project
=
Ci
::
Project
.
find
(
params
[
:project_id
])
end
def
build
@build
||=
project
.
builds
.
unscoped
.
find_by!
(
id:
params
[
:id
])
end
def
commit_by_sha
@project
.
commits
.
find_by
(
sha:
params
[
:id
])
end
def
build_path
(
build
)
namespace_project_build_path
(
build
.
gl_project
.
namespace
,
build
.
gl_project
,
build
)
end
end
end
app/controllers/ci/commits_controller.rb
deleted
100644 → 0
View file @
3fa2cb93
module
Ci
class
CommitsController
<
Ci
::
ApplicationController
before_action
:authenticate_user!
,
except:
[
:status
,
:show
]
before_action
:authenticate_public_page!
,
only: :show
before_action
:project
before_action
:authorize_access_project!
,
except:
[
:status
,
:show
,
:cancel
]
before_action
:authorize_manage_builds!
,
only:
[
:cancel
]
def
status
commit
=
Ci
::
Project
.
find
(
params
[
:project_id
]).
commits
.
find_by_sha!
(
params
[
:id
])
render
json:
commit
.
to_json
(
only:
[
:id
,
:sha
],
methods:
[
:status
,
:coverage
])
rescue
ActiveRecord
::
RecordNotFound
render
json:
{
status:
"not_found"
}
end
def
cancel
commit
.
builds
.
running_or_pending
.
each
(
&
:cancel
)
redirect_to
namespace_project_commit_path
(
commit
.
gl_project
.
namespace
,
commit
.
gl_project
,
commit
.
sha
)
end
private
def
project
@project
||=
Ci
::
Project
.
find
(
params
[
:project_id
])
end
def
commit
@commit
||=
Ci
::
Project
.
find
(
params
[
:project_id
]).
commits
.
find_by_sha!
(
params
[
:id
])
end
end
end
app/controllers/projects/builds_controller.rb
View file @
1e06cabf
...
@@ -2,6 +2,8 @@ class Projects::BuildsController < Projects::ApplicationController
...
@@ -2,6 +2,8 @@ class Projects::BuildsController < Projects::ApplicationController
before_action
:ci_project
before_action
:ci_project
before_action
:build
before_action
:build
before_action
:authorize_admin_project!
,
except:
[
:show
,
:status
]
layout
"project"
layout
"project"
def
show
def
show
...
@@ -17,9 +19,37 @@ class Projects::BuildsController < Projects::ApplicationController
...
@@ -17,9 +19,37 @@ class Projects::BuildsController < Projects::ApplicationController
end
end
end
end
def
retry
if
@build
.
commands
.
blank?
return
page_404
end
build
=
Ci
::
Build
.
retry
(
@build
)
if
params
[
:return_to
]
redirect_to
URI
.
parse
(
params
[
:return_to
]).
path
else
redirect_to
build_path
(
build
)
end
end
def
status
render
json:
@build
.
to_json
(
only:
[
:status
,
:id
,
:sha
,
:coverage
],
methods: :sha
)
end
def
cancel
@build
.
cancel
redirect_to
build_path
(
@build
)
end
private
private
def
build
def
build
@build
||=
ci_project
.
builds
.
unscoped
.
find_by!
(
id:
params
[
:id
])
@build
||=
ci_project
.
builds
.
unscoped
.
find_by!
(
id:
params
[
:id
])
end
end
def
build_path
(
build
)
namespace_project_build_path
(
build
.
gl_project
.
namespace
,
build
.
gl_project
,
build
)
end
end
end
app/controllers/projects/commit_controller.rb
View file @
1e06cabf
...
@@ -38,6 +38,14 @@ class Projects::CommitController < Projects::ApplicationController
...
@@ -38,6 +38,14 @@ class Projects::CommitController < Projects::ApplicationController
@ci_project
=
@project
.
gitlab_ci_project
@ci_project
=
@project
.
gitlab_ci_project
end
end
def
cancel_builds
@ci_commit
=
@project
.
ci_commit
(
@commit
.
sha
)
@ci_commit
.
builds
.
running_or_pending
.
each
(
&
:cancel
)
redirect_to
namespace_project_commit_path
(
project
.
namespace
,
project
,
commit
.
sha
)
end
def
branches
def
branches
@branches
=
@project
.
repository
.
branch_names_contains
(
commit
.
id
)
@branches
=
@project
.
repository
.
branch_names_contains
(
commit
.
id
)
@tags
=
@project
.
repository
.
tag_names_contains
(
commit
.
id
)
@tags
=
@project
.
repository
.
tag_names_contains
(
commit
.
id
)
...
...
app/views/projects/builds/_build.html.haml
View file @
1e06cabf
...
@@ -43,8 +43,8 @@
...
@@ -43,8 +43,8 @@
-
if
defined?
(
controls
)
&&
current_user
&&
can?
(
current_user
,
:manage_builds
,
gl_project
)
-
if
defined?
(
controls
)
&&
current_user
&&
can?
(
current_user
,
:manage_builds
,
gl_project
)
.pull-right
.pull-right
-
if
build
.
active?
-
if
build
.
active?
=
link_to
cancel_
ci_project_build_path
(
build
.
project
,
build
,
return_to:
request
.
original_url
),
title:
'Cancel build'
do
=
link_to
cancel_
namespace_project_build_path
(
gl_project
.
namespace
,
gl_
project
,
build
,
return_to:
request
.
original_url
),
title:
'Cancel build'
do
%i
.fa.fa-remove.cred
%i
.fa.fa-remove.cred
-
elsif
build
.
commands
.
present?
-
elsif
build
.
commands
.
present?
=
link_to
retry_
ci_project_build_path
(
build
.
project
,
build
,
return_to:
request
.
original_url
),
method: :post
,
title:
'Retry build'
do
=
link_to
retry_
namespace_project_build_path
(
gl_project
.
namespace
,
gl_
project
,
build
,
return_to:
request
.
original_url
),
method: :post
,
title:
'Retry build'
do
%i
.fa.fa-repeat
%i
.fa.fa-repeat
app/views/projects/builds/show.html.haml
View file @
1e06cabf
...
@@ -72,9 +72,9 @@
...
@@ -72,9 +72,9 @@
-
if
current_user
&&
can?
(
current_user
,
:manage_builds
,
@project
)
-
if
current_user
&&
can?
(
current_user
,
:manage_builds
,
@project
)
.pull-right
.pull-right
-
if
@build
.
active?
-
if
@build
.
active?
=
link_to
"Cancel"
,
cancel_
ci_project_build_path
(
@ci_
project
,
@build
),
class:
'btn btn-sm btn-danger'
=
link_to
"Cancel"
,
cancel_
namespace_project_build_path
(
@project
.
namespace
,
@
project
,
@build
),
class:
'btn btn-sm btn-danger'
-
elsif
@build
.
commands
.
present?
-
elsif
@build
.
commands
.
present?
=
link_to
"Retry"
,
retry_
ci_project_build_path
(
@ci_
project
,
@build
),
class:
'btn btn-sm btn-primary'
,
method: :post
=
link_to
"Retry"
,
retry_
namespace_project_build_path
(
@project
.
namespace
,
@
project
,
@build
),
class:
'btn btn-sm btn-primary'
,
method: :post
-
if
@build
.
duration
-
if
@build
.
duration
%p
%p
...
...
app/views/projects/commit/ci.html.haml
View file @
1e06cabf
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
-
if
@ci_project
&&
current_user
&&
can?
(
current_user
,
:manage_builds
,
@project
)
-
if
@ci_project
&&
current_user
&&
can?
(
current_user
,
:manage_builds
,
@project
)
.pull-right
.pull-right
-
if
@ci_commit
.
builds
.
running_or_pending
.
any?
-
if
@ci_commit
.
builds
.
running_or_pending
.
any?
=
link_to
"Cancel"
,
cancel_
ci_project_commits_path
(
@ci_project
,
@ci_commit
),
class:
'btn btn-sm btn-danger'
=
link_to
"Cancel"
,
cancel_
builds_namespace_project_commit_path
(
@project
.
namespace
,
@project
,
@commit
.
sha
),
class:
'btn btn-sm btn-danger'
-
if
@ci_commit
.
yaml_errors
.
present?
-
if
@ci_commit
.
yaml_errors
.
present?
...
...
config/routes.rb
View file @
1e06cabf
...
@@ -28,21 +28,6 @@ Gitlab::Application.routes.draw do
...
@@ -28,21 +28,6 @@ Gitlab::Application.routes.draw do
end
end
end
end
resources
:commits
,
only:
[]
do
member
do
get
:status
get
:cancel
end
end
resources
:builds
,
only:
[]
do
member
do
get
:cancel
get
:status
post
:retry
end
end
resources
:runner_projects
,
only:
[
:create
,
:destroy
]
resources
:runner_projects
,
only:
[
:create
,
:destroy
]
resources
:events
,
only:
[
:index
]
resources
:events
,
only:
[
:index
]
...
@@ -486,6 +471,7 @@ Gitlab::Application.routes.draw do
...
@@ -486,6 +471,7 @@ Gitlab::Application.routes.draw do
member
do
member
do
get
:branches
get
:branches
get
:ci
get
:ci
post
:cancel_builds
end
end
end
end
...
@@ -590,7 +576,13 @@ Gitlab::Application.routes.draw do
...
@@ -590,7 +576,13 @@ Gitlab::Application.routes.draw do
end
end
end
end
resources
:builds
,
only:
[
:show
]
resources
:builds
,
only:
[
:show
]
do
member
do
get
:cancel
get
:status
post
:retry
end
end
resources
:hooks
,
only:
[
:index
,
:create
,
:destroy
],
constraints:
{
id:
/\d+/
}
do
resources
:hooks
,
only:
[
:index
,
:create
,
:destroy
],
constraints:
{
id:
/\d+/
}
do
member
do
member
do
...
...
spec/features/builds_spec.rb
View file @
1e06cabf
require
'spec_helper'
require
'spec_helper'
describe
"Builds"
do
describe
"Builds"
do
before
do
before
do
login_as
(
:user
)
login_as
(
:user
)
@commit
=
FactoryGirl
.
create
:ci_commit
@commit
=
FactoryGirl
.
create
:ci_commit
...
@@ -19,4 +18,24 @@ describe "Builds" do
...
@@ -19,4 +18,24 @@ describe "Builds" do
it
{
expect
(
page
).
to
have_content
@commit
.
git_commit_message
}
it
{
expect
(
page
).
to
have_content
@commit
.
git_commit_message
}
it
{
expect
(
page
).
to
have_content
@commit
.
git_author_name
}
it
{
expect
(
page
).
to
have_content
@commit
.
git_author_name
}
end
end
describe
"GET /:project/builds/:id/cancel"
do
before
do
@build
.
run!
visit
cancel_namespace_project_build_path
(
@gl_project
.
namespace
,
@gl_project
,
@build
)
end
it
{
expect
(
page
).
to
have_content
'canceled'
}
it
{
expect
(
page
).
to
have_content
'Retry'
}
end
describe
"POST /:project/builds/:id/retry"
do
before
do
visit
cancel_namespace_project_build_path
(
@gl_project
.
namespace
,
@gl_project
,
@build
)
click_link
'Retry'
end
it
{
expect
(
page
).
to
have_content
'pending'
}
it
{
expect
(
page
).
to
have_content
'Cancel'
}
end
end
end
spec/features/ci/builds_spec.rb
deleted
100644 → 0
View file @
3fa2cb93
require
'spec_helper'
describe
"Builds"
do
before
do
login_as
(
:user
)
@commit
=
FactoryGirl
.
create
:ci_commit
@build
=
FactoryGirl
.
create
:ci_build
,
commit:
@commit
@gl_project
=
@commit
.
project
.
gl_project
@gl_project
.
team
<<
[
@user
,
:master
]
end
describe
"GET /:project/builds/:id/cancel"
do
before
do
@build
.
run!
visit
cancel_ci_project_build_path
(
@commit
.
project
,
@build
)
end
it
{
expect
(
page
).
to
have_content
'canceled'
}
it
{
expect
(
page
).
to
have_content
'Retry'
}
end
describe
"POST /:project/builds/:id/retry"
do
before
do
visit
cancel_ci_project_build_path
(
@commit
.
project
,
@build
)
click_link
'Retry'
end
it
{
expect
(
page
).
to
have_content
'pending'
}
it
{
expect
(
page
).
to
have_content
'Cancel'
}
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