BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
2e20a71d
Commit
2e20a71d
authored
Jan 04, 2017
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure internal Gitlab::Git references use the namespace
parent
a00578ce
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
27 additions
and
27 deletions
+27
-27
blob.rb
lib/gitlab/git/blob.rb
+8
-8
commit.rb
lib/gitlab/git/commit.rb
+3
-3
ref.rb
lib/gitlab/git/ref.rb
+1
-1
repository.rb
lib/gitlab/git/repository.rb
+11
-11
tree.rb
lib/gitlab/git/tree.rb
+2
-2
encoding_helper_spec.rb
spec/lib/gitlab/git/encoding_helper_spec.rb
+1
-1
repository_spec.rb
spec/lib/gitlab/git/repository_spec.rb
+1
-1
No files found.
lib/gitlab/git/blob.rb
View file @
2e20a71d
...
...
@@ -30,7 +30,7 @@ module Gitlab
blob
=
repository
.
lookup
(
blob_entry
[
:oid
])
if
blob
Blob
.
new
(
new
(
id:
blob
.
oid
,
name:
blob_entry
[
:name
],
size:
blob
.
size
,
...
...
@@ -47,7 +47,7 @@ module Gitlab
def
raw
(
repository
,
sha
)
blob
=
repository
.
lookup
(
sha
)
Blob
.
new
(
new
(
id:
blob
.
oid
,
size:
blob
.
size
,
data:
blob
.
content
(
MAX_DATA_DISPLAY_SIZE
),
...
...
@@ -88,7 +88,7 @@ module Gitlab
end
def
submodule_blob
(
blob_entry
,
path
,
sha
)
Blob
.
new
(
new
(
id:
blob_entry
[
:oid
],
name:
blob_entry
[
:name
],
data:
''
,
...
...
@@ -140,16 +140,16 @@ module Gitlab
ref
=
'refs/heads/'
+
ref
end
path_name
=
PathHelper
.
normalize_path
(
file
[
:path
])
path_name
=
Gitlab
::
Git
::
PathHelper
.
normalize_path
(
file
[
:path
])
# Abort if any invalid characters remain (e.g. ../foo)
raise
Repository
::
InvalidBlobName
.
new
(
"Invalid path"
)
if
path_name
.
each_filename
.
to_a
.
include?
(
'..'
)
raise
Gitlab
::
Git
::
Repository
::
InvalidBlobName
.
new
(
"Invalid path"
)
if
path_name
.
each_filename
.
to_a
.
include?
(
'..'
)
filename
=
path_name
.
to_s
index
=
repo
.
index
unless
repo
.
empty?
rugged_ref
=
repo
.
references
[
ref
]
raise
Repository
::
InvalidRef
.
new
(
"Invalid branch name"
)
unless
rugged_ref
raise
Gitlab
::
Git
::
Repository
::
InvalidRef
.
new
(
"Invalid branch name"
)
unless
rugged_ref
last_commit
=
rugged_ref
.
target
index
.
read_tree
(
last_commit
.
tree
)
parents
=
[
last_commit
]
...
...
@@ -161,14 +161,14 @@ module Gitlab
file_entry
=
index
.
get
(
filename
)
if
action
==
:rename
old_path_name
=
PathHelper
.
normalize_path
(
file
[
:previous_path
])
old_path_name
=
Gitlab
::
Git
::
PathHelper
.
normalize_path
(
file
[
:previous_path
])
old_filename
=
old_path_name
.
to_s
file_entry
=
index
.
get
(
old_filename
)
index
.
remove
(
old_filename
)
unless
file_entry
.
blank?
end
if
file_entry
raise
Repository
::
InvalidBlobName
.
new
(
"Filename already exists; update not allowed"
)
unless
update
raise
Gitlab
::
Git
::
Repository
::
InvalidBlobName
.
new
(
"Filename already exists; update not allowed"
)
unless
update
# Preserve the current file mode if one is available
mode
=
file_entry
[
:mode
]
if
file_entry
[
:mode
]
...
...
lib/gitlab/git/commit.rb
View file @
2e20a71d
...
...
@@ -58,7 +58,7 @@ module Gitlab
obj
=
if
commit_id
.
is_a?
(
String
)
repo
.
rev_parse_target
(
commit_id
)
else
Ref
.
dereference_object
(
commit_id
)
Gitlab
::
Git
::
Ref
.
dereference_object
(
commit_id
)
end
return
nil
unless
obj
.
is_a?
(
Rugged
::
Commit
)
...
...
@@ -123,7 +123,7 @@ module Gitlab
def
diff_from_parent
(
rugged_commit
,
options
=
{})
options
||=
{}
break_rewrites
=
options
[
:break_rewrites
]
actual_options
=
Diff
.
filter_diff_options
(
options
)
actual_options
=
Gitlab
::
Git
::
Diff
.
filter_diff_options
(
options
)
diff
=
if
rugged_commit
.
parents
.
empty?
rugged_commit
.
diff
(
actual_options
.
merge
(
reverse:
true
))
...
...
@@ -211,7 +211,7 @@ module Gitlab
end
def
diffs
(
options
=
{})
DiffCollection
.
new
(
diff_from_parent
(
options
),
options
)
Gitlab
::
Git
::
DiffCollection
.
new
(
diff_from_parent
(
options
),
options
)
end
def
parents
...
...
lib/gitlab/git/ref.rb
View file @
2e20a71d
...
...
@@ -33,7 +33,7 @@ module Gitlab
def
initialize
(
repository
,
name
,
target
)
encode!
name
@name
=
name
.
gsub
(
/\Arefs\/(tags|heads)\//
,
''
)
@dereferenced_target
=
Commit
.
find
(
repository
,
target
)
@dereferenced_target
=
Gitlab
::
Git
::
Commit
.
find
(
repository
,
target
)
@target
=
if
target
.
respond_to?
(
:oid
)
target
.
oid
elsif
target
.
respond_to?
(
:name
)
...
...
lib/gitlab/git/repository.rb
View file @
2e20a71d
...
...
@@ -32,7 +32,7 @@ module Gitlab
def
initialize
(
path
)
@path
=
path
@name
=
path
.
split
(
"/"
).
last
@attributes
=
Attributes
.
new
(
path
)
@attributes
=
Gitlab
::
Git
::
Attributes
.
new
(
path
)
end
# Default branch in the repository
...
...
@@ -61,7 +61,7 @@ module Gitlab
def
branches
rugged
.
branches
.
map
do
|
rugged_ref
|
begin
Branch
.
new
(
self
,
rugged_ref
.
name
,
rugged_ref
.
target
)
Gitlab
::
Git
::
Branch
.
new
(
self
,
rugged_ref
.
name
,
rugged_ref
.
target
)
rescue
Rugged
::
ReferenceError
# Omit invalid branch
end
...
...
@@ -83,12 +83,12 @@ module Gitlab
reload_rugged
if
force_reload
rugged_ref
=
rugged
.
branches
[
name
]
Branch
.
new
(
self
,
rugged_ref
.
name
,
rugged_ref
.
target
)
if
rugged_ref
Gitlab
::
Git
::
Branch
.
new
(
self
,
rugged_ref
.
name
,
rugged_ref
.
target
)
if
rugged_ref
end
def
local_branches
rugged
.
branches
.
each
(
:local
).
map
do
|
branch
|
Branch
.
new
(
self
,
branch
.
name
,
branch
.
target
)
Gitlab
::
Git
::
Branch
.
new
(
self
,
branch
.
name
,
branch
.
target
)
end
end
...
...
@@ -123,7 +123,7 @@ module Gitlab
end
end
Tag
.
new
(
self
,
ref
.
name
,
ref
.
target
,
message
)
Gitlab
::
Git
::
Tag
.
new
(
self
,
ref
.
name
,
ref
.
target
,
message
)
end
.
sort_by
(
&
:name
)
end
...
...
@@ -260,7 +260,7 @@ module Gitlab
# Discard submodules
next
if
submodule?
(
entry
)
blob
=
Blob
.
raw
(
self
,
entry
[
:oid
])
blob
=
Gitlab
::
Git
::
Blob
.
raw
(
self
,
entry
[
:oid
])
# Skip binary files
next
if
blob
.
data
.
encoding
==
Encoding
::
ASCII_8BIT
...
...
@@ -397,7 +397,7 @@ module Gitlab
# diff options. The +options+ hash can also include :break_rewrites to
# split larger rewrites into delete/add pairs.
def
diff
(
from
,
to
,
options
=
{},
*
paths
)
DiffCollection
.
new
(
diff_patches
(
from
,
to
,
options
,
*
paths
),
options
)
Gitlab
::
Git
::
DiffCollection
.
new
(
diff_patches
(
from
,
to
,
options
,
*
paths
),
options
)
end
# Returns commits collection
...
...
@@ -755,7 +755,7 @@ module Gitlab
# create_branch("other-feature", "master")
def
create_branch
(
ref
,
start_point
=
"HEAD"
)
rugged_ref
=
rugged
.
branches
.
create
(
ref
,
start_point
)
Branch
.
new
(
self
,
rugged_ref
.
name
,
rugged_ref
.
target
)
Gitlab
::
Git
::
Branch
.
new
(
self
,
rugged_ref
.
name
,
rugged_ref
.
target
)
rescue
Rugged
::
ReferenceError
=>
e
raise
InvalidRef
.
new
(
"Branch
#{
ref
}
already exists"
)
if
e
.
to_s
=~
/'refs\/heads\/
#{
ref
}
'/
raise
InvalidRef
.
new
(
"Invalid reference
#{
start_point
}
"
)
...
...
@@ -870,7 +870,7 @@ module Gitlab
# Check if this directory exists; if it does, then don't bother
# adding .gitkeep file.
ref
=
options
[
:commit
][
:branch
]
path
=
PathHelper
.
normalize_path
(
path
).
to_s
path
=
Gitlab
::
Git
::
PathHelper
.
normalize_path
(
path
).
to_s
rugged_ref
=
rugged
.
ref
(
ref
)
raise
InvalidRef
.
new
(
"Invalid ref"
)
if
rugged_ref
.
nil?
...
...
@@ -895,7 +895,7 @@ module Gitlab
update:
true
}
Blob
.
commit
(
self
,
options
)
Gitlab
::
Git
::
Blob
.
commit
(
self
,
options
)
end
# Returns result like "git ls-files" , recursive and full file path
...
...
@@ -1242,7 +1242,7 @@ module Gitlab
def
diff_patches
(
from
,
to
,
options
=
{},
*
paths
)
options
||=
{}
break_rewrites
=
options
[
:break_rewrites
]
actual_options
=
Diff
.
filter_diff_options
(
options
.
merge
(
paths:
paths
))
actual_options
=
Gitlab
::
Git
::
Diff
.
filter_diff_options
(
options
.
merge
(
paths:
paths
))
diff
=
rugged
.
diff
(
from
,
to
,
actual_options
)
diff
.
find_similar!
(
break_rewrites:
break_rewrites
)
...
...
lib/gitlab/git/tree.rb
View file @
2e20a71d
...
...
@@ -17,7 +17,7 @@ module Gitlab
root_tree
=
commit
.
tree
tree
=
if
path
id
=
Tree
.
find_id_by_path
(
repository
,
root_tree
.
oid
,
path
)
id
=
find_id_by_path
(
repository
,
root_tree
.
oid
,
path
)
if
id
repository
.
lookup
(
id
)
else
...
...
@@ -28,7 +28,7 @@ module Gitlab
end
tree
.
map
do
|
entry
|
Tree
.
new
(
new
(
id:
entry
[
:oid
],
root_id:
root_tree
.
oid
,
name:
entry
[
:name
],
...
...
spec/lib/gitlab/git/encoding_helper_spec.rb
View file @
2e20a71d
require
"spec_helper"
describe
Gitlab
::
Git
::
EncodingHelper
do
let
(
:ext_class
)
{
Class
.
new
{
extend
EncodingHelper
}
}
let
(
:ext_class
)
{
Class
.
new
{
extend
Gitlab
::
Git
::
EncodingHelper
}
}
let
(
:binary_string
)
{
File
.
join
(
SEED_REPOSITORY_PATH
,
'gitlab_logo.png'
)
}
describe
'#encode!'
do
...
...
spec/lib/gitlab/git/repository_spec.rb
View file @
2e20a71d
require
"spec_helper"
describe
Gitlab
::
Git
::
Repository
,
seed_helper:
true
do
include
EncodingHelper
include
Gitlab
::
Git
::
EncodingHelper
let
(
:repository
)
{
Gitlab
::
Git
::
Repository
.
new
(
TEST_REPO_PATH
)
}
...
...
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