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
Jérome Perrin
gitlab-ce
Commits
e99444bb
Commit
e99444bb
authored
Aug 07, 2017
by
vanadium23
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix CI_PROJECT_PATH_SLUG slugify
parent
ae81bfd3
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
7 deletions
+39
-7
app/models/ci/build.rb
app/models/ci/build.rb
+1
-4
app/models/project.rb
app/models/project.rb
+5
-1
changelogs/unreleased/34643-fix-project-path-slugify.yml
changelogs/unreleased/34643-fix-project-path-slugify.yml
+4
-0
lib/gitlab/utils.rb
lib/gitlab/utils.rb
+13
-0
spec/lib/gitlab/utils_spec.rb
spec/lib/gitlab/utils_spec.rb
+15
-1
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+1
-1
No files found.
app/models/ci/build.rb
View file @
e99444bb
...
...
@@ -194,10 +194,7 @@ module Ci
# * Maximum length is 63 bytes
# * First/Last Character is not a hyphen
def
ref_slug
ref
.
to_s
.
downcase
.
gsub
(
/[^a-z0-9]/
,
'-'
)[
0
..
62
]
.
gsub
(
/(\A-+|-+\z)/
,
''
)
Gitlab
::
Utils
.
slugify
(
ref
.
to_s
)
end
# Variables whose value does not depend on environment
...
...
app/models/project.rb
View file @
e99444bb
...
...
@@ -1283,12 +1283,16 @@ class Project < ActiveRecord::Base
status
.
zero?
end
def
full_path_slug
Gitlab
::
Utils
.
slugify
(
full_path
.
to_s
)
end
def
predefined_variables
[
{
key:
'CI_PROJECT_ID'
,
value:
id
.
to_s
,
public:
true
},
{
key:
'CI_PROJECT_NAME'
,
value:
path
,
public:
true
},
{
key:
'CI_PROJECT_PATH'
,
value:
full_path
,
public:
true
},
{
key:
'CI_PROJECT_PATH_SLUG'
,
value:
full_path
.
parameterize
,
public:
true
},
{
key:
'CI_PROJECT_PATH_SLUG'
,
value:
full_path
_slug
,
public:
true
},
{
key:
'CI_PROJECT_NAMESPACE'
,
value:
namespace
.
full_path
,
public:
true
},
{
key:
'CI_PROJECT_URL'
,
value:
web_url
,
public:
true
}
]
...
...
changelogs/unreleased/34643-fix-project-path-slugify.yml
0 → 100644
View file @
e99444bb
---
title
:
Fix CI_PROJECT_PATH_SLUG slugify
merge_request
:
13350
author
:
Ivan Chernov
lib/gitlab/utils.rb
View file @
e99444bb
...
...
@@ -14,6 +14,19 @@ module Gitlab
str
.
force_encoding
(
Encoding
::
UTF_8
)
end
# A slugified version of the string, suitable for inclusion in URLs and
# domain names. Rules:
#
# * Lowercased
# * Anything not matching [a-z0-9-] is replaced with a -
# * Maximum length is 63 bytes
# * First/Last Character is not a hyphen
def
slugify
(
str
)
return
str
.
downcase
.
gsub
(
/[^a-z0-9]/
,
'-'
)[
0
..
62
]
.
gsub
(
/(\A-+|-+\z)/
,
''
)
end
def
to_boolean
(
value
)
return
value
if
[
true
,
false
].
include?
(
value
)
return
true
if
value
=~
/^(true|t|yes|y|1|on)$/i
...
...
spec/lib/gitlab/utils_spec.rb
View file @
e99444bb
require
'spec_helper'
describe
Gitlab
::
Utils
do
delegate
:to_boolean
,
:boolean_to_yes_no
,
to: :described_class
delegate
:to_boolean
,
:boolean_to_yes_no
,
:slugify
,
to: :described_class
describe
'.slugify'
do
{
'TEST'
=>
'test'
,
'project_with_underscores'
=>
'project-with-underscores'
,
'namespace/project'
=>
'namespace-project'
,
'a'
*
70
=>
'a'
*
63
,
'test_trailing_'
=>
'test-trailing'
}.
each
do
|
original
,
expected
|
it
"slugifies
#{
original
}
to
#{
expected
}
"
do
expect
(
slugify
(
original
)).
to
eq
(
expected
)
end
end
end
describe
'.to_boolean'
do
it
'accepts booleans'
do
...
...
spec/models/ci/build_spec.rb
View file @
e99444bb
...
...
@@ -1220,7 +1220,7 @@ describe Ci::Build do
{
key:
'CI_PROJECT_ID'
,
value:
project
.
id
.
to_s
,
public:
true
},
{
key:
'CI_PROJECT_NAME'
,
value:
project
.
path
,
public:
true
},
{
key:
'CI_PROJECT_PATH'
,
value:
project
.
full_path
,
public:
true
},
{
key:
'CI_PROJECT_PATH_SLUG'
,
value:
project
.
full_path
.
parameterize
,
public:
true
},
{
key:
'CI_PROJECT_PATH_SLUG'
,
value:
project
.
full_path
_slug
,
public:
true
},
{
key:
'CI_PROJECT_NAMESPACE'
,
value:
project
.
namespace
.
full_path
,
public:
true
},
{
key:
'CI_PROJECT_URL'
,
value:
project
.
web_url
,
public:
true
},
{
key:
'CI_PIPELINE_ID'
,
value:
pipeline
.
id
.
to_s
,
public:
true
},
...
...
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