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
081e2fce
Commit
081e2fce
authored
Aug 25, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Try to make reserved ref names more obvious
So that whenever we want to reserve more, we're aware, and don't mess it up.
parent
d1054bd3
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
10 deletions
+19
-10
environment.rb
app/models/environment.rb
+1
-1
merge_request.rb
app/models/merge_request.rb
+1
-1
repository.rb
app/models/repository.rb
+15
-3
after_import_service.rb
app/services/projects/after_import_service.rb
+1
-4
after_import_service_spec.rb
spec/services/projects/after_import_service_spec.rb
+1
-1
No files found.
app/models/environment.rb
View file @
081e2fce
...
...
@@ -114,7 +114,7 @@ class Environment < ActiveRecord::Base
end
def
ref_path
"refs/
environments
/
#{
Shellwords
.
shellescape
(
name
)
}
"
"refs/
#{
Repository
::
REF_ENVIRONMENTS
}
/
#{
Shellwords
.
shellescape
(
name
)
}
"
end
def
formatted_external_url
...
...
app/models/merge_request.rb
View file @
081e2fce
...
...
@@ -797,7 +797,7 @@ class MergeRequest < ActiveRecord::Base
end
def
ref_path
"refs/
merge-requests
/
#{
iid
}
/head"
"refs/
#{
Repository
::
REF_MERGE_REQUEST
}
/
#{
iid
}
/head"
end
def
ref_fetched?
...
...
app/models/repository.rb
View file @
081e2fce
require
'securerandom'
class
Repository
REF_MERGE_REQUEST
=
'merge-requests'
REF_KEEP_AROUND
=
'keep-around'
REF_ENVIRONMENTS
=
'environments'
RESERVED_REFS_NAMES
=
%W[
heads
tags
#{
REF_ENVIRONMENTS
}
#{
REF_KEEP_AROUND
}
#{
REF_ENVIRONMENTS
}
]
.
freeze
include
Gitlab
::
ShellAdapter
include
RepositoryMirroring
...
...
@@ -228,10 +240,10 @@ class Repository
begin
write_ref
(
keep_around_ref_name
(
sha
),
sha
)
rescue
Rugged
::
ReferenceError
=>
ex
Rails
.
logger
.
error
"Unable to create
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
raise
unless
ex
.
message
=~
/Failed to create locked file/
&&
ex
.
message
=~
/File exists/
Rails
.
logger
.
error
"Unable to create
keep-around
reference for repository
#{
path
}
:
#{
ex
}
"
Rails
.
logger
.
error
"Unable to create
#{
REF_KEEP_AROUND
}
reference for repository
#{
path
}
:
#{
ex
}
"
end
end
...
...
@@ -1152,7 +1164,7 @@ class Repository
end
def
keep_around_ref_name
(
sha
)
"refs/
keep-around
/
#{
sha
}
"
"refs/
#{
REF_KEEP_AROUND
}
/
#{
sha
}
"
end
def
repository_event
(
event
,
tags
=
{})
...
...
app/services/projects/after_import_service.rb
View file @
081e2fce
module
Projects
class
AfterImportService
RESERVED_REFS_NAMES
=
%w[heads tags merge-requests keep-around environments]
.
freeze
RESERVED_REFS_REGEXP
=
%r{
\A
refs/(?:
#{
Regexp
.
union
(
*
RESERVED_REFS_NAMES
)
}
)/}
%r{
\A
refs/(?:
#{
Regexp
.
union
(
*
R
epository
::
R
ESERVED_REFS_NAMES
)
}
)/}
def
initialize
(
project
)
@project
=
project
...
...
spec/services/projects/after_import_service_spec.rb
View file @
081e2fce
...
...
@@ -37,7 +37,7 @@ describe Projects::AfterImportService do
end
end
described_class
::
RESERVED_REFS_NAMES
.
each
do
|
name
|
Repository
::
RESERVED_REFS_NAMES
.
each
do
|
name
|
context
"with a ref in refs/
#{
name
}
/tmp"
do
before
do
repository
.
write_ref
(
"refs/
#{
name
}
/tmp"
,
sha
)
...
...
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