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
528f9cde
Commit
528f9cde
authored
Oct 12, 2017
by
Brett Walker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved throttling into the controller. if we hit the throttling
threshhold, a message is shown indicating we didn't perform the search
parent
6d3eea7b
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
21 deletions
+38
-21
commit_controller.rb
app/controllers/projects/commit_controller.rb
+5
-2
commits_helper.rb
app/helpers/commits_helper.rb
+17
-7
repository.rb
app/models/repository.rb
+4
-4
branches.html.haml
app/views/projects/commit/branches.html.haml
+12
-8
No files found.
app/controllers/projects/commit_controller.rb
View file @
528f9cde
...
@@ -56,8 +56,11 @@ class Projects::CommitController < Projects::ApplicationController
...
@@ -56,8 +56,11 @@ class Projects::CommitController < Projects::ApplicationController
end
end
def
branches
def
branches
@branches
=
@project
.
repository
.
branch_names_contains
(
commit
.
id
,
1000
)
# branch_names_contains/tag_names_contains can take a long time when there are thousands of
@tags
=
@project
.
repository
.
tag_names_contains
(
commit
.
id
,
1000
)
# branches/tags - each `git branch --contains xxx` request can consume a cpu core.
# so only do the query when there are a manageable number of branches/tags
@branches
=
@project
.
repository
.
branch_count
>
1000
?
[:
limit_exceeded
]
:
@project
.
repository
.
branch_names_contains
(
commit
.
id
)
@tags
=
@project
.
repository
.
tag_count
>
1000
?
[:
limit_exceeded
]
:
@project
.
repository
.
tag_names_contains
(
commit
.
id
)
render
layout:
false
render
layout:
false
end
end
...
...
app/helpers/commits_helper.rb
View file @
528f9cde
...
@@ -60,23 +60,33 @@ module CommitsHelper
...
@@ -60,23 +60,33 @@ module CommitsHelper
branches
.
include?
(
project
.
default_branch
)
?
branches
.
delete
(
project
.
default_branch
)
:
branches
.
pop
branches
.
include?
(
project
.
default_branch
)
?
branches
.
delete
(
project
.
default_branch
)
:
branches
.
pop
end
end
# returns a link formatted as a commit branch link
def
commit_branch_link
(
url
,
text
)
link_to
(
url
,
class:
'label label-gray ref-name'
)
do
icon
(
'code-fork'
)
+
"
#{
text
}
"
end
end
# Returns the sorted alphabetically links to branches, separated by a comma
# Returns the sorted alphabetically links to branches, separated by a comma
def
commit_branches_links
(
project
,
branches
)
def
commit_branches_links
(
project
,
branches
)
branches
.
sort
.
map
do
|
branch
|
branches
.
sort
.
map
do
|
branch
|
link_to
(
project_ref_path
(
project
,
branch
),
class:
"label label-gray ref-name"
)
do
commit_branch_link
(
project_ref_path
(
project
,
branch
),
branch
)
icon
(
'code-fork'
)
+
"
#{
branch
}
"
end
.
join
(
' '
).
html_safe
end
# returns a link formatted as a commit tag link
def
commit_tag_link
(
url
,
text
)
link_to
(
url
,
class:
'label label-gray ref-name'
)
do
icon
(
'tag'
)
+
"
#{
text
}
"
end
end
end
.
join
(
" "
).
html_safe
end
end
# Returns the sorted links to tags, separated by a comma
# Returns the sorted links to tags, separated by a comma
def
commit_tags_links
(
project
,
tags
)
def
commit_tags_links
(
project
,
tags
)
sorted
=
VersionSorter
.
rsort
(
tags
)
sorted
=
VersionSorter
.
rsort
(
tags
)
sorted
.
map
do
|
tag
|
sorted
.
map
do
|
tag
|
link_to
(
project_ref_path
(
project
,
tag
),
class:
"label label-gray ref-name"
)
do
commit_tag_link
(
project_ref_path
(
project
,
tag
),
tag
)
icon
(
'tag'
)
+
"
#{
tag
}
"
end
.
join
(
' '
).
html_safe
end
end
.
join
(
" "
).
html_safe
end
end
def
link_to_browse_code
(
project
,
commit
)
def
link_to_browse_code
(
project
,
commit
)
...
...
app/models/repository.rb
View file @
528f9cde
...
@@ -715,12 +715,12 @@ class Repository
...
@@ -715,12 +715,12 @@ class Repository
end
end
end
end
def
branch_names_contains
(
sha
,
limit
=
nil
)
def
branch_names_contains
(
sha
)
limit
&&
branch_count
>
limit
?
[]
:
refs_contains_sha
(
'branch'
,
sha
)
refs_contains_sha
(
'branch'
,
sha
)
end
end
def
tag_names_contains
(
sha
,
limit
=
nil
)
def
tag_names_contains
(
sha
)
limit
&&
tag_count
>
limit
?
[]
:
refs_contains_sha
(
'tag'
,
sha
)
refs_contains_sha
(
'tag'
,
sha
)
end
end
def
local_branches
def
local_branches
...
...
app/views/projects/commit/branches.html.haml
View file @
528f9cde
-
if
@branches
.
any?
||
@tags
.
any?
-
if
@branches
.
any?
-
branch
=
commit_default_branch
(
@project
,
@branches
)
-
branch
=
commit_default_branch
(
@project
,
@branches
)
=
link_to
(
project_ref_path
(
@project
,
branch
),
class:
"label label-gray ref-name"
)
do
-
if
branch
==
:limit_exceeded
=
icon
(
'code-fork'
)
=
commit_branch_link
(
'#'
,
_
(
'Too many branches to search'
))
=
branch
-
else
=
commit_branch_link
(
project_ref_path
(
@project
,
branch
),
branch
)
-# `commit_default_branch` deletes the default branch from `@branches`,
-# `commit_default_branch` deletes the default branch from `@branches`,
-# so only render this if we have more branche
s left
-# so only render this if we have more branches or tag
s left
-
if
@branches
.
any?
||
@tags
.
any?
-
if
@branches
.
any?
||
@tags
.
any?
%span
%span
=
link_to
"…"
,
"#"
,
class:
"js-details-expand label label-gray"
=
link_to
"…"
,
"#"
,
class:
"js-details-expand label label-gray"
%span
.js-details-content.hide
%span
.js-details-content.hide
=
commit_branches_links
(
@project
,
@branches
)
if
@branches
.
any?
=
commit_branches_links
(
@project
,
@branches
)
if
@branches
.
any?
=
commit_tags_links
(
@project
,
@tags
)
if
@tags
.
any?
-
if
@tags
.
first
==
:limit_exceeded
=
commit_tag_link
(
'#'
,
_
(
'Too many tags to search'
))
-
elsif
@tags
.
any?
=
commit_tags_links
(
@project
,
@tags
)
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