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
Léo-Paul Géneau
gitlab-ce
Commits
442a6e88
Commit
442a6e88
authored
Feb 16, 2018
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API method /projects/:id/repository/commits now works over every commit
parent
981b5905
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
14 deletions
+33
-14
app/models/repository.rb
app/models/repository.rb
+3
-2
lib/api/commits.rb
lib/api/commits.rb
+6
-3
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+24
-9
No files found.
app/models/repository.rb
View file @
442a6e88
...
@@ -139,7 +139,7 @@ class Repository
...
@@ -139,7 +139,7 @@ class Repository
end
end
end
end
def
commits
(
ref
,
path:
nil
,
limit:
nil
,
offset:
nil
,
skip_merges:
false
,
after:
nil
,
before
:
nil
)
def
commits
(
ref
=
nil
,
path:
nil
,
limit:
nil
,
offset:
nil
,
skip_merges:
false
,
after:
nil
,
before:
nil
,
all
:
nil
)
options
=
{
options
=
{
repo:
raw_repository
,
repo:
raw_repository
,
ref:
ref
,
ref:
ref
,
...
@@ -149,7 +149,8 @@ class Repository
...
@@ -149,7 +149,8 @@ class Repository
after:
after
,
after:
after
,
before:
before
,
before:
before
,
follow:
Array
(
path
).
length
==
1
,
follow:
Array
(
path
).
length
==
1
,
skip_merges:
skip_merges
skip_merges:
skip_merges
,
all:
all
}
}
commits
=
Gitlab
::
Git
::
Commit
.
where
(
options
)
commits
=
Gitlab
::
Git
::
Commit
.
where
(
options
)
...
...
lib/api/commits.rb
View file @
442a6e88
...
@@ -18,25 +18,28 @@ module API
...
@@ -18,25 +18,28 @@ module API
optional
:since
,
type:
DateTime
,
desc:
'Only commits after or on this date will be returned'
optional
:since
,
type:
DateTime
,
desc:
'Only commits after or on this date will be returned'
optional
:until
,
type:
DateTime
,
desc:
'Only commits before or on this date will be returned'
optional
:until
,
type:
DateTime
,
desc:
'Only commits before or on this date will be returned'
optional
:path
,
type:
String
,
desc:
'The file path'
optional
:path
,
type:
String
,
desc:
'The file path'
optional
:all
,
type:
Boolean
,
desc:
'Every commit will be returned'
use
:pagination
use
:pagination
end
end
get
':id/repository/commits'
do
get
':id/repository/commits'
do
path
=
params
[
:path
]
path
=
params
[
:path
]
before
=
params
[
:until
]
before
=
params
[
:until
]
after
=
params
[
:since
]
after
=
params
[
:since
]
ref
=
params
[
:ref_name
]
||
user_project
.
try
(
:default_branch
)
||
'master'
ref
=
params
[
:ref_name
]
||
user_project
.
try
(
:default_branch
)
||
'master'
unless
params
[
:all
]
offset
=
(
params
[
:page
]
-
1
)
*
params
[
:per_page
]
offset
=
(
params
[
:page
]
-
1
)
*
params
[
:per_page
]
all
=
params
[
:all
]
commits
=
user_project
.
repository
.
commits
(
ref
,
commits
=
user_project
.
repository
.
commits
(
ref
,
path:
path
,
path:
path
,
limit:
params
[
:per_page
],
limit:
params
[
:per_page
],
offset:
offset
,
offset:
offset
,
before:
before
,
before:
before
,
after:
after
)
after:
after
,
all:
all
)
commit_count
=
commit_count
=
if
path
||
before
||
after
if
path
||
before
||
after
user_project
.
repository
.
count_commits
(
ref:
ref
,
path:
path
,
before:
before
,
after:
after
)
user_project
.
repository
.
count_commits
(
ref:
ref
,
path:
path
,
before:
before
,
after:
after
,
all:
all
)
else
else
# Cacheable commit count.
# Cacheable commit count.
user_project
.
repository
.
commit_count_for_ref
(
ref
)
user_project
.
repository
.
commit_count_for_ref
(
ref
)
...
...
lib/gitlab/git/repository.rb
View file @
442a6e88
...
@@ -489,13 +489,16 @@ module Gitlab
...
@@ -489,13 +489,16 @@ module Gitlab
# Used in gitaly-ruby
# Used in gitaly-ruby
def
raw_log
(
options
)
def
raw_log
(
options
)
sha
=
unless
options
[
:all
]
actual_ref
=
options
[
:ref
]
||
root_ref
actual_ref
=
options
[
:ref
]
||
root_ref
begin
begin
sha
=
sha_from_ref
(
actual_ref
)
sha_from_ref
(
actual_ref
)
rescue
Rugged
::
OdbError
,
Rugged
::
InvalidError
,
Rugged
::
ReferenceError
rescue
Rugged
::
OdbError
,
Rugged
::
InvalidError
,
Rugged
::
ReferenceError
# Return an empty array if the ref wasn't found
# Return an empty array if the ref wasn't found
return
[]
return
[]
end
end
end
log_by_shell
(
sha
,
options
)
log_by_shell
(
sha
,
options
)
end
end
...
@@ -1701,7 +1704,12 @@ module Gitlab
...
@@ -1701,7 +1704,12 @@ module Gitlab
cmd
<<
'--no-merges'
if
options
[
:skip_merges
]
cmd
<<
'--no-merges'
if
options
[
:skip_merges
]
cmd
<<
"--after=
#{
options
[
:after
].
iso8601
}
"
if
options
[
:after
]
cmd
<<
"--after=
#{
options
[
:after
].
iso8601
}
"
if
options
[
:after
]
cmd
<<
"--before=
#{
options
[
:before
].
iso8601
}
"
if
options
[
:before
]
cmd
<<
"--before=
#{
options
[
:before
].
iso8601
}
"
if
options
[
:before
]
if
options
[
:all
]
cmd
+=
%w[--all --reverse]
elsif
sha
cmd
<<
sha
cmd
<<
sha
end
# :path can be a string or an array of strings
# :path can be a string or an array of strings
if
options
[
:path
].
present?
if
options
[
:path
].
present?
...
@@ -1918,8 +1926,15 @@ module Gitlab
...
@@ -1918,8 +1926,15 @@ module Gitlab
cmd
<<
"--before=
#{
options
[
:before
].
iso8601
}
"
if
options
[
:before
]
cmd
<<
"--before=
#{
options
[
:before
].
iso8601
}
"
if
options
[
:before
]
cmd
<<
"--max-count=
#{
options
[
:max_count
]
}
"
if
options
[
:max_count
]
cmd
<<
"--max-count=
#{
options
[
:max_count
]
}
"
if
options
[
:max_count
]
cmd
<<
"--left-right"
if
options
[
:left_right
]
cmd
<<
"--left-right"
if
options
[
:left_right
]
if
options
[
:all
]
cmd
+=
%w[--count --all]
elsif
options
[
:ref
].
present?
cmd
+=
%W[--count
#{
options
[
:ref
]
}
]
cmd
+=
%W[--count
#{
options
[
:ref
]
}
]
end
cmd
+=
%W[--
#{
options
[
:path
]
}
]
if
options
[
:path
].
present?
cmd
+=
%W[--
#{
options
[
:path
]
}
]
if
options
[
:path
].
present?
cmd
cmd
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