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
Boxiang Sun
gitlab-ce
Commits
58aa32bc
Commit
58aa32bc
authored
Jan 18, 2018
by
Kim "BKC" Carlbäcker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wrap Rugged-exceptions in Gitlab::Git::Repository#write_ref
parent
ceb2a768
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
18 deletions
+24
-18
app/models/repository.rb
app/models/repository.rb
+7
-5
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+17
-13
No files found.
app/models/repository.rb
View file @
58aa32bc
...
@@ -261,14 +261,16 @@ class Repository
...
@@ -261,14 +261,16 @@ class Repository
# This will still fail if the file is corrupted (e.g. 0 bytes)
# This will still fail if the file is corrupted (e.g. 0 bytes)
begin
begin
raw_repository
.
write_ref
(
keep_around_ref_name
(
sha
),
sha
,
shell:
false
)
raw_repository
.
write_ref
(
keep_around_ref_name
(
sha
),
sha
,
shell:
false
)
rescue
Rugged
::
ReferenceError
=>
ex
rescue
Gitlab
::
Git
::
CommandError
=>
ex
if
ex
.
message
.
start_with?
(
"ReferenceError: "
)
Rails
.
logger
.
error
"Unable to create
#{
REF_KEEP_AROUND
}
reference for repository
#{
path
}
:
#{
ex
}
"
Rails
.
logger
.
error
"Unable to create
#{
REF_KEEP_AROUND
}
reference for repository
#{
path
}
:
#{
ex
}
"
rescue
Rugged
::
OSError
=>
ex
elsif
ex
.
message
.
start_with?
(
"OSError: "
)
raise
unless
ex
.
message
=~
/Failed to create locked file/
&&
ex
.
message
=~
/File exists/
raise
unless
ex
.
message
=~
/Failed to create locked file/
&&
ex
.
message
=~
/File exists/
Rails
.
logger
.
error
"Unable to create
#{
REF_KEEP_AROUND
}
reference for repository
#{
path
}
:
#{
ex
}
"
Rails
.
logger
.
error
"Unable to create
#{
REF_KEEP_AROUND
}
reference for repository
#{
path
}
:
#{
ex
}
"
end
end
end
end
end
def
kept_around?
(
sha
)
def
kept_around?
(
sha
)
ref_exists?
(
keep_around_ref_name
(
sha
))
ref_exists?
(
keep_around_ref_name
(
sha
))
...
...
lib/gitlab/git/repository.rb
View file @
58aa32bc
...
@@ -1126,19 +1126,6 @@ module Gitlab
...
@@ -1126,19 +1126,6 @@ module Gitlab
end
end
end
end
def
shell_write_ref
(
ref_path
,
ref
,
old_ref
)
raise
ArgumentError
,
"invalid ref_path
#{
ref_path
.
inspect
}
"
if
ref_path
.
include?
(
' '
)
raise
ArgumentError
,
"invalid ref
#{
ref
.
inspect
}
"
if
ref
.
include?
(
"
\x00
"
)
raise
ArgumentError
,
"invalid old_ref
#{
old_ref
.
inspect
}
"
if
!
old_ref
.
nil?
&&
old_ref
.
include?
(
"
\x00
"
)
input
=
"update
#{
ref_path
}
\x00
#{
ref
}
\x00
#{
old_ref
}
\x00
"
run_git!
(
%w[update-ref --stdin -z]
)
{
|
stdin
|
stdin
.
write
(
input
)
}
end
def
rugged_write_ref
(
ref_path
,
ref
)
rugged
.
references
.
create
(
ref_path
,
ref
,
force:
true
)
end
def
fetch_ref
(
source_repository
,
source_ref
:,
target_ref
:)
def
fetch_ref
(
source_repository
,
source_ref
:,
target_ref
:)
Gitlab
::
Git
.
check_namespace!
(
source_repository
)
Gitlab
::
Git
.
check_namespace!
(
source_repository
)
source_repository
=
RemoteRepository
.
new
(
source_repository
)
unless
source_repository
.
is_a?
(
RemoteRepository
)
source_repository
=
RemoteRepository
.
new
(
source_repository
)
unless
source_repository
.
is_a?
(
RemoteRepository
)
...
@@ -1396,6 +1383,23 @@ module Gitlab
...
@@ -1396,6 +1383,23 @@ module Gitlab
private
private
def
shell_write_ref
(
ref_path
,
ref
,
old_ref
)
raise
ArgumentError
,
"invalid ref_path
#{
ref_path
.
inspect
}
"
if
ref_path
.
include?
(
' '
)
raise
ArgumentError
,
"invalid ref
#{
ref
.
inspect
}
"
if
ref
.
include?
(
"
\x00
"
)
raise
ArgumentError
,
"invalid old_ref
#{
old_ref
.
inspect
}
"
if
!
old_ref
.
nil?
&&
old_ref
.
include?
(
"
\x00
"
)
input
=
"update
#{
ref_path
}
\x00
#{
ref
}
\x00
#{
old_ref
}
\x00
"
run_git!
(
%w[update-ref --stdin -z]
)
{
|
stdin
|
stdin
.
write
(
input
)
}
end
def
rugged_write_ref
(
ref_path
,
ref
)
rugged
.
references
.
create
(
ref_path
,
ref
,
force:
true
)
rescue
Rugged
::
ReferenceError
=>
ex
raise
CommandError
,
"ReferenceError:
#{
ex
}
"
rescue
Rugged
::
OSError
=>
ex
raise
CommandError
,
"OSError:
#{
ex
}
"
end
def
fresh_worktree?
(
path
)
def
fresh_worktree?
(
path
)
File
.
exist?
(
path
)
&&
!
clean_stuck_worktree
(
path
)
File
.
exist?
(
path
)
&&
!
clean_stuck_worktree
(
path
)
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