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
c770d2f9
Commit
c770d2f9
authored
Jul 06, 2018
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make more things mandatory
parent
b62825fd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
77 deletions
+12
-77
lib/gitlab/git/commit.rb
lib/gitlab/git/commit.rb
+3
-15
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+0
-29
lib/gitlab/git/support/format-git-cat-file-input
lib/gitlab/git/support/format-git-cat-file-input
+0
-21
lib/gitlab/shell.rb
lib/gitlab/shell.rb
+9
-12
No files found.
lib/gitlab/git/commit.rb
View file @
c770d2f9
...
...
@@ -164,13 +164,8 @@ module Gitlab
# relation to each other. The last 10 commits for a branch for example,
# should go through .where
def
batch_by_oid
(
repo
,
oids
)
repo
.
gitaly_migrate
(
:list_commits_by_oid
,
status:
Gitlab
::
GitalyClient
::
MigrationStatus
::
OPT_OUT
)
do
|
is_enabled
|
if
is_enabled
repo
.
gitaly_commit_client
.
list_commits_by_oid
(
oids
)
else
oids
.
map
{
|
oid
|
find
(
repo
,
oid
)
}.
compact
end
repo
.
wrapped_gitaly_errors
do
repo
.
gitaly_commit_client
.
list_commits_by_oid
(
oids
)
end
end
...
...
@@ -289,14 +284,7 @@ module Gitlab
def
deltas
@deltas
||=
begin
deltas
=
Gitlab
::
GitalyClient
.
migrate
(
:commit_deltas
)
do
|
is_enabled
|
if
is_enabled
@repository
.
gitaly_commit_client
.
commit_deltas
(
self
)
else
rugged_diff_from_parent
.
each_delta
end
end
deltas
=
@repository
.
gitaly_commit_client
.
commit_deltas
(
self
)
deltas
.
map
{
|
delta
|
Gitlab
::
Git
::
Diff
.
new
(
delta
)
}
end
end
...
...
lib/gitlab/git/repository.rb
View file @
c770d2f9
...
...
@@ -1858,35 +1858,6 @@ module Gitlab
def
sha_from_ref
(
ref
)
rev_parse_target
(
ref
).
oid
end
def
build_git_cmd
(
*
args
)
object_directories
=
alternate_object_directories
.
join
(
File
::
PATH_SEPARATOR
)
env
=
{
'PWD'
=>
self
.
path
}
env
[
'GIT_ALTERNATE_OBJECT_DIRECTORIES'
]
=
object_directories
if
object_directories
.
present?
[
env
,
::
Gitlab
.
config
.
git
.
bin_path
,
*
args
,
{
chdir:
self
.
path
}
]
end
def
git_diff_cmd
(
old_rev
,
new_rev
)
old_rev
=
old_rev
==
::
Gitlab
::
Git
::
BLANK_SHA
?
::
Gitlab
::
Git
::
EMPTY_TREE_ID
:
old_rev
build_git_cmd
(
'diff'
,
old_rev
,
new_rev
,
'--raw'
)
end
def
git_cat_file_cmd
format
=
'%(objectname) %(objectsize) %(rest)'
build_git_cmd
(
'cat-file'
,
"--batch-check=
#{
format
}
"
)
end
def
format_git_cat_file_script
File
.
expand_path
(
'../support/format-git-cat-file-input'
,
__FILE__
)
end
end
end
end
lib/gitlab/git/support/format-git-cat-file-input
deleted
100755 → 0
View file @
b62825fd
#!/usr/bin/env ruby
# This script formats the output of the `git diff <old_rev> <new_rev> --raw`
# command so it can be processed by `git cat-file`
# We need to convert this:
# ":100644 100644 5f53439... 85bc2f9... R060\tfiles/js/commit.js.coffee\tfiles/js/commit.coffee"
# To:
# "85bc2f9 R\tfiles/js/commit.js.coffee\tfiles/js/commit.coffee"
ARGF
.
each
do
|
line
|
_
,
_
,
old_blob_id
,
new_blob_id
,
rest
=
line
.
split
(
/\s/
,
5
)
old_blob_id
.
gsub!
(
/[^\h]/
,
''
)
new_blob_id
.
gsub!
(
/[^\h]/
,
''
)
# We can't pass '0000000...' to `git cat-file` given it will not return info about the deleted file
blob_id
=
new_blob_id
=~
/\A0+\z/
?
old_blob_id
:
new_blob_id
$stdout
.
puts
"
#{
blob_id
}
#{
rest
}
"
end
lib/gitlab/shell.rb
View file @
c770d2f9
...
...
@@ -74,17 +74,10 @@ module Gitlab
relative_path
=
name
.
dup
relative_path
<<
'.git'
unless
relative_path
.
end_with?
(
'.git'
)
gitaly_migrate
(
:create_repository
,
status:
Gitlab
::
GitalyClient
::
MigrationStatus
::
OPT_OUT
)
do
|
is_enabled
|
if
is_enabled
repository
=
Gitlab
::
Git
::
Repository
.
new
(
storage
,
relative_path
,
''
)
repository
.
gitaly_repository_client
.
create_repository
true
else
repo_path
=
File
.
join
(
Gitlab
.
config
.
repositories
.
storages
[
storage
].
legacy_disk_path
,
relative_path
)
Gitlab
::
Git
::
Repository
.
create
(
repo_path
,
bare:
true
,
symlink_hooks_to:
gitlab_shell_hooks_path
)
end
end
repository
=
Gitlab
::
Git
::
Repository
.
new
(
storage
,
relative_path
,
''
)
wrapped_gitaly_errors
{
repository
.
gitaly_repository_client
.
create_repository
}
true
rescue
=>
err
# Once the Rugged codes gets removes this can be improved
Rails
.
logger
.
error
(
"Failed to add repository
#{
storage
}
/
#{
name
}
:
#{
err
}
"
)
false
...
...
@@ -448,7 +441,11 @@ module Gitlab
end
def
gitaly_migrate
(
method
,
status:
Gitlab
::
GitalyClient
::
MigrationStatus
::
OPT_IN
,
&
block
)
Gitlab
::
GitalyClient
.
migrate
(
method
,
status:
status
,
&
block
)
wrapped_gitaly_errors
{
Gitlab
::
GitalyClient
.
migrate
(
method
,
status:
status
,
&
block
)
}
end
def
wrapped_gitaly_errors
yield
rescue
GRPC
::
NotFound
,
GRPC
::
BadStatus
=>
e
# Old Popen code returns [Error, output] to the caller, so we
# need to do the same here...
...
...
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