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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
4a27d2a4
Commit
4a27d2a4
authored
Apr 05, 2017
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move Repository#new_commits to EE::Repository and make it use Gitlab::Git::RevList#new_refs
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
f2ed30f8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
14 deletions
+42
-14
app/models/ee/repository.rb
app/models/ee/repository.rb
+9
-0
app/models/repository.rb
app/models/repository.rb
+0
-9
spec/lib/gitlab/git_access_spec.rb
spec/lib/gitlab/git_access_spec.rb
+5
-5
spec/models/ee/repository_spec.rb
spec/models/ee/repository_spec.rb
+28
-0
No files found.
app/models/ee/repository.rb
View file @
4a27d2a4
...
...
@@ -12,5 +12,14 @@ module EE
expire_branch_cache
expire_content_cache
end
# Returns a list of commits that are not present in any reference
def
new_commits
(
newrev
)
refs
=
::
Gitlab
::
Git
::
RevList
.
new
(
path_to_repo:
path_to_repo
,
newrev:
newrev
).
new_refs
refs
.
map
{
|
sha
|
commit
(
sha
.
strip
)
}
end
end
end
app/models/repository.rb
View file @
4a27d2a4
...
...
@@ -634,15 +634,6 @@ class Repository
commit
(
sha
)
end
# Returns a list of commits that are not present in any reference
def
new_commits
(
newrev
)
args
=
%W(
#{
Gitlab
.
config
.
git
.
bin_path
}
rev-list
#{
newrev
}
--not --all)
Gitlab
::
Popen
.
popen
(
args
,
path_to_repo
).
first
.
split
(
"
\n
"
).
map
do
|
sha
|
commit
(
sha
.
strip
)
end
end
def
last_commit_id_for_path
(
sha
,
path
)
key
=
path
.
blank?
?
"last_commit_id_for_path:
#{
sha
}
"
:
"last_commit_id_for_path:
#{
sha
}
:
#{
Digest
::
SHA1
.
hexdigest
(
path
)
}
"
...
...
spec/lib/gitlab/git_access_spec.rb
View file @
4a27d2a4
...
...
@@ -527,7 +527,7 @@ describe Gitlab::GitAccess, lib: true do
before
do
project
.
team
<<
[
user
,
:developer
]
allow
_any_instance_of
(
R
epository
).
to
receive
(
:new_commits
).
and_return
(
allow
(
project
.
r
epository
).
to
receive
(
:new_commits
).
and_return
(
project
.
repository
.
commits_between
(
'6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9'
,
'570e7b2abdd848b95f2f578043fc23bd6f6fd24d'
)
)
end
...
...
@@ -568,7 +568,7 @@ describe Gitlab::GitAccess, lib: true do
bad_commit
=
double
(
"Commit"
,
safe_message:
'Some change'
).
as_null_object
ref_object
=
double
(
name:
'heads/master'
)
allow
(
bad_commit
).
to
receive
(
:refs
).
and_return
([
ref_object
])
allow
_any_instance_of
(
R
epository
).
to
receive
(
:commits_between
).
and_return
([
bad_commit
])
allow
(
project
.
r
epository
).
to
receive
(
:commits_between
).
and_return
([
bad_commit
])
project
.
create_push_rule
project
.
push_rule
.
update
(
commit_message_regex:
"Change some files"
)
...
...
@@ -582,8 +582,8 @@ describe Gitlab::GitAccess, lib: true do
# We use tmp ref a a temporary for Web UI commiting
ref_object
=
double
(
name:
'refs/tmp'
)
allow
(
bad_commit
).
to
receive
(
:refs
).
and_return
([
ref_object
])
allow
_any_instance_of
(
R
epository
).
to
receive
(
:commits_between
).
and_return
([
bad_commit
])
allow
_any_instance_of
(
R
epository
).
to
receive
(
:new_commits
).
and_return
([
bad_commit
])
allow
(
project
.
r
epository
).
to
receive
(
:commits_between
).
and_return
([
bad_commit
])
allow
(
project
.
r
epository
).
to
receive
(
:new_commits
).
and_return
([
bad_commit
])
project
.
create_push_rule
project
.
push_rule
.
update
(
commit_message_regex:
"Change some files"
)
...
...
@@ -612,7 +612,7 @@ describe Gitlab::GitAccess, lib: true do
describe
"file names check"
do
before
do
allow
_any_instance_of
(
R
epository
).
to
receive
(
:new_commits
).
and_return
(
allow
(
project
.
r
epository
).
to
receive
(
:new_commits
).
and_return
(
project
.
repository
.
commits_between
(
'913c66a37b4a45b9769037c55c2d238bd0942d2e'
,
'33f3729a45c02fc67d00adb1b8bca394b0e761d9'
)
)
end
...
...
spec/models/ee/repository_spec.rb
0 → 100644
View file @
4a27d2a4
require
'spec_helper'
describe
EE
::
Repository
,
models:
true
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:repository
)
{
project
.
repository
}
describe
'#new_commits'
do
let
(
:new_refs
)
do
double
(
:git_rev_list
,
new_refs:
%w[
c1acaa58bbcbc3eafe538cb8274ba387047b69f8
5937ac0a7beb003549fc5fd26fc247adbce4a52e
]
)
end
it
'delegates to Gitlab::Git::RevList'
do
expect
(
Gitlab
::
Git
::
RevList
).
to
receive
(
:new
).
with
(
path_to_repo:
repository
.
path_to_repo
,
newrev:
'aaaabbbbccccddddeeeeffffgggghhhhiiiijjjj'
).
and_return
(
new_refs
)
commits
=
repository
.
new_commits
(
'aaaabbbbccccddddeeeeffffgggghhhhiiiijjjj'
)
expect
(
commits
).
to
eq
([
repository
.
commit
(
'c1acaa58bbcbc3eafe538cb8274ba387047b69f8'
),
repository
.
commit
(
'5937ac0a7beb003549fc5fd26fc247adbce4a52e'
)
])
end
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