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
c2cdefd4
Commit
c2cdefd4
authored
Jun 19, 2018
by
Zeger-Jan van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Force push is handled by Gitaly now
Closes gitlab-org/gitaly#348
parent
d04ac745
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
11 additions
and
46 deletions
+11
-46
lib/gitlab/checks/force_push.rb
lib/gitlab/checks/force_push.rb
+4
-12
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+0
-4
lib/gitlab/git/rev_list.rb
lib/gitlab/git/rev_list.rb
+0
-9
spec/lib/gitlab/checks/force_push_spec.rb
spec/lib/gitlab/checks/force_push_spec.rb
+7
-11
spec/lib/gitlab/git/rev_list_spec.rb
spec/lib/gitlab/git/rev_list_spec.rb
+0
-10
No files found.
lib/gitlab/checks/force_push.rb
View file @
c2cdefd4
...
@@ -7,18 +7,10 @@ module Gitlab
...
@@ -7,18 +7,10 @@ module Gitlab
# Created or deleted branch
# Created or deleted branch
return
false
if
Gitlab
::
Git
.
blank_ref?
(
oldrev
)
||
Gitlab
::
Git
.
blank_ref?
(
newrev
)
return
false
if
Gitlab
::
Git
.
blank_ref?
(
oldrev
)
||
Gitlab
::
Git
.
blank_ref?
(
newrev
)
GitalyClient
.
migrate
(
:force_push
)
do
|
is_enabled
|
if
is_enabled
!
project
!
project
.
repository
.
repository
.
gitaly_commit_client
.
gitaly_commit_client
.
ancestor?
(
oldrev
,
newrev
)
.
ancestor?
(
oldrev
,
newrev
)
else
Gitlab
::
Git
::
RevList
.
new
(
project
.
repository
.
raw
,
oldrev:
oldrev
,
newrev:
newrev
).
missed_ref
.
present?
end
end
end
end
end
end
end
end
...
...
lib/gitlab/git/repository.rb
View file @
c2cdefd4
...
@@ -1476,10 +1476,6 @@ module Gitlab
...
@@ -1476,10 +1476,6 @@ module Gitlab
run_git!
(
args
,
lazy_block:
block
)
run_git!
(
args
,
lazy_block:
block
)
end
end
def
missed_ref
(
oldrev
,
newrev
)
run_git!
([
'rev-list'
,
'--max-count=1'
,
oldrev
,
"^
#{
newrev
}
"
])
end
def
with_worktree
(
worktree_path
,
branch
,
sparse_checkout_files:
nil
,
env
:)
def
with_worktree
(
worktree_path
,
branch
,
sparse_checkout_files:
nil
,
env
:)
base_args
=
%w(worktree add --detach)
base_args
=
%w(worktree add --detach)
...
...
lib/gitlab/git/rev_list.rb
View file @
c2cdefd4
# Gitaly note: JV: will probably be migrated indirectly by migrating the call sites.
module
Gitlab
module
Gitlab
module
Git
module
Git
class
RevList
class
RevList
...
@@ -45,13 +43,6 @@ module Gitlab
...
@@ -45,13 +43,6 @@ module Gitlab
&
lazy_block
)
&
lazy_block
)
end
end
# This methods returns an array of missed references
#
# Should become obsolete after https://gitlab.com/gitlab-org/gitaly/issues/348.
def
missed_ref
repository
.
missed_ref
(
oldrev
,
newrev
).
split
(
"
\n
"
)
end
private
private
def
execute
(
args
)
def
execute
(
args
)
...
...
spec/lib/gitlab/checks/force_push_spec.rb
View file @
c2cdefd4
require
'spec_helper'
require
'spec_helper'
describe
Gitlab
::
Checks
::
ForcePush
do
describe
Gitlab
::
Checks
::
ForcePush
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
set
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:repository
)
{
project
.
repository
.
raw
}
context
"exit code checking"
,
:skip_gitaly_mock
do
describe
'.force_push?'
do
it
"does not raise a runtime error if the `popen` call to git returns a zero exit code"
do
it
'returns false if the repo is empty'
do
allow
(
repository
).
to
receive
(
:popen
).
and_return
([
'normal output'
,
0
]
)
allow
(
project
).
to
receive
(
:empty_repo?
).
and_return
(
true
)
expect
{
described_class
.
force_push?
(
project
,
'oldrev'
,
'newrev'
)
}.
not_to
raise_error
expect
(
described_class
.
force_push?
(
project
,
'HEAD'
,
'HEAD~'
)).
to
be
(
false
)
end
end
it
"raises a GitError error if the `popen` call to git returns a non-zero exit code"
do
it
'checks if old rev is an anchestor'
do
allow
(
repository
).
to
receive
(
:popen
).
and_return
([
'error'
,
1
])
expect
(
described_class
.
force_push?
(
project
,
'HEAD'
,
'HEAD~'
)).
to
be
(
true
)
expect
{
described_class
.
force_push?
(
project
,
'oldrev'
,
'newrev'
)
}
.
to
raise_error
(
Gitlab
::
Git
::
Repository
::
GitError
)
end
end
end
end
end
end
spec/lib/gitlab/git/rev_list_spec.rb
View file @
c2cdefd4
...
@@ -93,14 +93,4 @@ describe Gitlab::Git::RevList do
...
@@ -93,14 +93,4 @@ describe Gitlab::Git::RevList do
expect
{
|
b
|
rev_list
.
all_objects
(
&
b
)
}.
to
yield_with_args
(
%w[sha1 sha2]
)
expect
{
|
b
|
rev_list
.
all_objects
(
&
b
)
}.
to
yield_with_args
(
%w[sha1 sha2]
)
end
end
end
end
context
"#missed_ref"
do
let
(
:rev_list
)
{
described_class
.
new
(
repository
,
oldrev:
'oldrev'
,
newrev:
'newrev'
)
}
it
'calls out to `popen`'
do
stub_popen_rev_list
(
'--max-count=1'
,
'oldrev'
,
'^newrev'
,
with_lazy_block:
false
,
output:
"sha1
\n
sha2"
)
expect
(
rev_list
.
missed_ref
).
to
eq
(
%w[sha1 sha2]
)
end
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