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
f8a4a760
Commit
f8a4a760
authored
Apr 03, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decorate commits in Gitlab::Git::repository with valid class
parent
e91ff84d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
4 deletions
+21
-4
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+10
-4
spec/lib/gitlab/git/repository_spec.rb
spec/lib/gitlab/git/repository_spec.rb
+11
-0
No files found.
lib/gitlab/git/repository.rb
View file @
f8a4a760
...
...
@@ -54,11 +54,11 @@ module Gitlab
repo
.
commits
(
root_ref
).
first
end
Commit
.
new
(
commit
)
if
commit
decorate_commit
(
commit
)
if
commit
end
def
commits_with_refs
(
n
=
20
)
commits
=
repo
.
branches
.
map
{
|
ref
|
Commit
.
new
(
ref
.
commit
,
ref
)
}
commits
=
repo
.
branches
.
map
{
|
ref
|
decorate_commit
(
ref
.
commit
,
ref
)
}
commits
.
sort!
do
|
x
,
y
|
y
.
committed_date
<=>
x
.
committed_date
...
...
@@ -74,11 +74,11 @@ module Gitlab
repo
.
commits
(
ref
,
limit
,
offset
)
else
repo
.
commits
(
ref
)
end
.
map
{
|
c
|
Commit
.
new
(
c
)
}
end
.
map
{
|
c
|
decorate_commit
(
c
)
}
end
def
commits_between
(
from
,
to
)
repo
.
commits_between
(
from
,
to
).
map
{
|
c
|
Commit
.
new
(
c
)
}
repo
.
commits_between
(
from
,
to
).
map
{
|
c
|
decorate_commit
(
c
)
}
end
def
last_commit_for
(
ref
,
path
=
nil
)
...
...
@@ -190,6 +190,12 @@ module Gitlab
def
cache_key
(
type
)
"
#{
type
}
:
#{
path_with_namespace
}
"
end
protected
def
decorate_commit
(
commit
,
ref
=
nil
)
Gitlab
::
Git
::
Commit
.
new
(
commit
,
ref
)
end
end
end
end
spec/lib/gitlab/git/repository_spec.rb
View file @
f8a4a760
...
...
@@ -82,6 +82,17 @@ describe Gitlab::Git::Repository do
end
end
describe
"commits"
do
subject
do
commits
=
repository
.
commits
(
'master'
,
'app'
,
3
,
1
)
commits
.
map
{
|
c
|
c
.
id
}
end
it
{
should
have
(
3
).
elements
}
it
{
should
include
(
"8716fc78f3c65bbf7bcf7b574febd583bc5d2812"
)
}
it
{
should_not
include
(
"bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a"
)
}
end
describe
"commits_between"
do
subject
do
commits
=
repository
.
commits_between
(
"3a4b4fb4cde7809f033822a171b9feae19d41fff"
,
...
...
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