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
88b1e0ff
Commit
88b1e0ff
authored
10 years ago
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Faster branch contains detection for commit
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
2ebd2d41
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
7 deletions
+33
-7
app/controllers/projects/commit_controller.rb
app/controllers/projects/commit_controller.rb
+1
-7
app/models/repository.rb
app/models/repository.rb
+17
-0
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+15
-0
No files found.
app/controllers/projects/commit_controller.rb
View file @
88b1e0ff
...
...
@@ -12,13 +12,7 @@ class Projects::CommitController < Projects::ApplicationController
return
git_not_found!
unless
@commit
@line_notes
=
project
.
notes
.
for_commit_id
(
commit
.
id
).
inline
@branches
=
begin
project
.
repository
.
branch_names_contains
(
commit
.
id
)
rescue
Grit
::
Git
::
GitTimeout
[]
end
@branches
=
project
.
repository
.
branch_names_contains
(
commit
.
id
)
@diffs
=
@commit
.
diffs
@note
=
project
.
build_commit_note
(
commit
)
@notes_count
=
project
.
notes
.
for_commit_id
(
commit
.
id
).
count
...
...
This diff is collapsed.
Click to expand it.
app/models/repository.rb
View file @
88b1e0ff
...
...
@@ -284,4 +284,21 @@ class Repository
blob_at
(
commit
.
parent_id
,
diff
.
old_path
)
end
end
def
branch_names_contains
(
sha
)
args
=
%W(git branch --contains
#{
sha
}
)
names
=
Gitlab
::
Popen
.
popen
(
args
,
path_to_repo
).
first
if
names
.
respond_to?
(
:split
)
names
=
names
.
split
(
"
\n
"
).
map
(
&
:strip
)
names
.
each
do
|
name
|
name
.
slice!
'* '
end
names
else
[]
end
end
end
This diff is collapsed.
Click to expand it.
spec/models/repository_spec.rb
0 → 100644
View file @
88b1e0ff
require
'spec_helper'
describe
Repository
do
include
RepoHelpers
let
(
:repository
)
{
create
(
:project
).
repository
}
describe
:branch_names_contains
do
subject
{
repository
.
branch_names_contains
(
sample_commit
.
id
)
}
it
{
should
include
(
'master'
)
}
it
{
should_not
include
(
'feature'
)
}
it
{
should_not
include
(
'fix'
)
}
end
end
This diff is collapsed.
Click to expand it.
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