BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
52352dcc
Commit
52352dcc
authored
Feb 08, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move badge implementation to builds controller
parent
442a49db
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
24 deletions
+13
-24
builds_controller.rb
app/controllers/projects/builds_controller.rb
+10
-5
commit_controller.rb
app/controllers/projects/commit_controller.rb
+0
-11
routes.rb
config/routes.rb
+3
-8
No files found.
app/controllers/projects/builds_controller.rb
View file @
52352dcc
class
Projects
::
BuildsController
<
Projects
::
ApplicationController
class
Projects
::
BuildsController
<
Projects
::
ApplicationController
before_action
:build
,
except:
[
:index
,
:cancel_all
]
before_action
:build
,
except:
[
:index
,
:cancel_all
]
before_action
:authorize_read_build!
,
except:
[
:cancel
,
:cancel_all
,
:retry
]
before_action
:authorize_read_build!
,
except:
[
:cancel
,
:cancel_all
,
:retry
]
before_action
:authorize_update_build!
,
except:
[
:index
,
:show
,
:status
]
before_action
:authorize_update_build!
,
except:
[
:index
,
:show
,
:status
]
layout
'project'
layout
"project"
# Skip authentication for status badge only
skip_before_action
:authenticate_user!
,
:reject_blocked!
,
:project
,
:repository
,
:authorize_manage_builds!
,
:build
,
only:
[
:badge
]
def
index
def
index
@scope
=
params
[
:scope
]
@scope
=
params
[
:scope
]
...
@@ -24,7 +26,6 @@ class Projects::BuildsController < Projects::ApplicationController
...
@@ -24,7 +26,6 @@ class Projects::BuildsController < Projects::ApplicationController
def
cancel_all
def
cancel_all
@project
.
builds
.
running_or_pending
.
each
(
&
:cancel
)
@project
.
builds
.
running_or_pending
.
each
(
&
:cancel
)
redirect_to
namespace_project_builds_path
(
project
.
namespace
,
project
)
redirect_to
namespace_project_builds_path
(
project
.
namespace
,
project
)
end
end
...
@@ -47,7 +48,6 @@ class Projects::BuildsController < Projects::ApplicationController
...
@@ -47,7 +48,6 @@ class Projects::BuildsController < Projects::ApplicationController
end
end
build
=
Ci
::
Build
.
retry
(
@build
)
build
=
Ci
::
Build
.
retry
(
@build
)
redirect_to
build_path
(
build
)
redirect_to
build_path
(
build
)
end
end
...
@@ -57,10 +57,15 @@ class Projects::BuildsController < Projects::ApplicationController
...
@@ -57,10 +57,15 @@ class Projects::BuildsController < Projects::ApplicationController
def
cancel
def
cancel
@build
.
cancel
@build
.
cancel
redirect_to
build_path
(
@build
)
redirect_to
build_path
(
@build
)
end
end
def
badge
project
=
Project
.
find_with_namespace
(
"
#{
params
[
:namespace_id
]
}
/
#{
params
[
:project_id
]
}
"
)
image
=
Ci
::
ImageForBuildService
.
new
.
execute
(
project
,
ref:
params
[
:ref
])
send_file
(
image
.
path
,
filename:
image
.
name
,
disposition:
'inline'
,
type:
'image/svg+xml'
)
end
private
private
def
build
def
build
...
...
app/controllers/projects/commit_controller.rb
View file @
52352dcc
...
@@ -10,11 +10,6 @@ class Projects::CommitController < Projects::ApplicationController
...
@@ -10,11 +10,6 @@ class Projects::CommitController < Projects::ApplicationController
before_action
:commit
before_action
:commit
before_action
:define_show_vars
,
only:
[
:show
,
:builds
]
before_action
:define_show_vars
,
only:
[
:show
,
:builds
]
# Skip authentication for status badge only
skip_before_action
:authenticate_user!
,
:reject_blocked!
,
:project
,
:repository
,
:require_non_empty_project
,
:authorize_download_code!
,
:commit
,
only:
[
:badge
]
def
show
def
show
return
git_not_found!
unless
@commit
return
git_not_found!
unless
@commit
...
@@ -62,12 +57,6 @@ class Projects::CommitController < Projects::ApplicationController
...
@@ -62,12 +57,6 @@ class Projects::CommitController < Projects::ApplicationController
render
layout:
false
render
layout:
false
end
end
def
badge
project
=
Project
.
find_with_namespace
(
"
#{
params
[
:namespace_id
]
}
/
#{
params
[
:project_id
]
}
"
)
image
=
Ci
::
ImageForBuildService
.
new
.
execute
(
project
,
ref:
params
[
:id
])
send_file
(
image
.
path
,
filename:
image
.
name
,
disposition:
'inline'
,
type:
'image/svg+xml'
)
end
private
private
def
commit
def
commit
...
...
config/routes.rb
View file @
52352dcc
...
@@ -493,13 +493,6 @@ Rails.application.routes.draw do
...
@@ -493,13 +493,6 @@ Rails.application.routes.draw do
constraints:
{
id:
/(?:[^.]|\.(?!atom$))+/
,
format:
/atom/
},
constraints:
{
id:
/(?:[^.]|\.(?!atom$))+/
,
format:
/atom/
},
as: :commits
as: :commits
)
)
get
(
'/status/*id/badge'
,
to:
'commit#badge'
,
constraints:
{
format:
/png/
},
as: :build_badge
)
end
end
resource
:avatar
,
only:
[
:show
,
:destroy
]
resource
:avatar
,
only:
[
:show
,
:destroy
]
...
@@ -615,9 +608,11 @@ Rails.application.routes.draw do
...
@@ -615,9 +608,11 @@ Rails.application.routes.draw do
resource
:variables
,
only:
[
:show
,
:update
]
resource
:variables
,
only:
[
:show
,
:update
]
resources
:triggers
,
only:
[
:index
,
:create
,
:destroy
]
resources
:triggers
,
only:
[
:index
,
:create
,
:destroy
]
resources
:builds
,
only:
[
:index
,
:show
]
do
resources
:builds
,
only:
[
:index
,
:show
]
,
constraints:
{
id:
/\d+/
}
do
collection
do
collection
do
post
:cancel_all
post
:cancel_all
get
:badge
,
path:
'status/*ref/badge'
,
constraints:
{
ref:
Gitlab
::
Regex
.
git_reference_regex
,
format:
/svg/
}
end
end
member
do
member
do
...
...
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