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
Jérome Perrin
gitlab-ce
Commits
6a7622b2
Commit
6a7622b2
authored
Sep 29, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of dev.gitlab.org:gitlab/gitlabhq
parents
331a4675
813e2728
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
7 deletions
+39
-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
+21
-0
No files found.
app/controllers/projects/commit_controller.rb
View file @
6a7622b2
...
@@ -12,13 +12,7 @@ class Projects::CommitController < Projects::ApplicationController
...
@@ -12,13 +12,7 @@ class Projects::CommitController < Projects::ApplicationController
return
git_not_found!
unless
@commit
return
git_not_found!
unless
@commit
@line_notes
=
project
.
notes
.
for_commit_id
(
commit
.
id
).
inline
@line_notes
=
project
.
notes
.
for_commit_id
(
commit
.
id
).
inline
@branches
=
project
.
repository
.
branch_names_contains
(
commit
.
id
)
@branches
=
begin
project
.
repository
.
branch_names_contains
(
commit
.
id
)
rescue
Grit
::
Git
::
GitTimeout
[]
end
@diffs
=
@commit
.
diffs
@diffs
=
@commit
.
diffs
@note
=
project
.
build_commit_note
(
commit
)
@note
=
project
.
build_commit_note
(
commit
)
@notes_count
=
project
.
notes
.
for_commit_id
(
commit
.
id
).
count
@notes_count
=
project
.
notes
.
for_commit_id
(
commit
.
id
).
count
...
...
app/models/repository.rb
View file @
6a7622b2
...
@@ -284,4 +284,21 @@ class Repository
...
@@ -284,4 +284,21 @@ class Repository
blob_at
(
commit
.
parent_id
,
diff
.
old_path
)
blob_at
(
commit
.
parent_id
,
diff
.
old_path
)
end
end
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
end
spec/models/repository_spec.rb
0 → 100644
View file @
6a7622b2
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
describe
:last_commit_for_path
do
subject
{
repository
.
last_commit_for_path
(
sample_commit
.
id
,
'.gitignore'
).
id
}
it
{
should
eq
(
'c1acaa58bbcbc3eafe538cb8274ba387047b69f8'
)
}
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