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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
2c7565ec
Commit
2c7565ec
authored
Mar 11, 2015
by
Marin Jankovski
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'release/7-8-4' into '7-8-stable'
Release/7 8 4 See merge request !1678
parents
abea0701
956a392a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
32 deletions
+48
-32
app/controllers/import/base_controller.rb
app/controllers/import/base_controller.rb
+8
-10
app/models/project_services/issue_tracker_service.rb
app/models/project_services/issue_tracker_service.rb
+6
-18
db/migrate/20150306023106_fix_namespace_duplication.rb
db/migrate/20150306023106_fix_namespace_duplication.rb
+21
-0
db/migrate/20150306023112_add_unique_index_to_namespace.rb
db/migrate/20150306023112_add_unique_index_to_namespace.rb
+9
-0
db/schema.rb
db/schema.rb
+4
-4
No files found.
app/controllers/import/base_controller.rb
View file @
2c7565ec
...
...
@@ -3,19 +3,17 @@ class Import::BaseController < ApplicationController
private
def
get_or_create_namespace
existing_namespace
=
Namespace
.
find_by_path_or_name
(
@target_namespace
)
if
existing_namespace
if
existing_namespace
.
owner
==
current_user
namespace
=
existing_namespace
else
begin
namespace
=
Group
.
create!
(
name:
@target_namespace
,
path:
@target_namespace
,
owner:
current_user
)
namespace
.
add_owner
(
current_user
)
rescue
ActiveRecord
::
RecordNotUnique
,
ActiveRecord
::
RecordInvalid
namespace
=
Namespace
.
find_by_path_or_name
(
@target_namespace
)
unless
namespace
.
owner
==
current_user
@already_been_taken
=
true
return
false
end
else
namespace
=
Group
.
create
(
name:
@target_namespace
,
path:
@target_namespace
,
owner:
current_user
)
namespace
.
add_owner
(
current_user
)
namespace
end
namespace
end
end
app/models/project_services/issue_tracker_service.rb
View file @
2c7565ec
...
...
@@ -25,18 +25,6 @@ class IssueTrackerService < Service
false
end
def
project_url
# implement inside child
end
def
issues_url
# implement inside child
end
def
new_issue_url
# implement inside child
end
def
issue_url
(
iid
)
self
.
issues_url
.
gsub
(
':id'
,
iid
.
to_s
)
end
...
...
@@ -55,9 +43,9 @@ class IssueTrackerService < Service
if
enabled_in_gitlab_config
self
.
properties
=
{
title:
issues_tracker
[
'title'
],
project_url:
set_project_url
,
issues_url:
issues_tracker
[
'issues_url'
]
,
new_issue_url:
issues_tracker
[
'new_issue_url'
]
project_url:
add_issues_tracker_id
(
issues_tracker
[
'project_url'
])
,
issues_url:
add_issues_tracker_id
(
issues_tracker
[
'issues_url'
])
,
new_issue_url:
add_issues_tracker_id
(
issues_tracker
[
'new_issue_url'
])
}
else
self
.
properties
=
{}
...
...
@@ -100,15 +88,15 @@ class IssueTrackerService < Service
Gitlab
.
config
.
issues_tracker
[
to_param
]
end
def
set_project_url
def
add_issues_tracker_id
(
url
)
if
self
.
project
id
=
self
.
project
.
issues_tracker_id
if
id
issues_tracker
[
'project_url'
]
.
gsub
(
":issues_tracker_id"
,
id
)
url
=
url
.
gsub
(
":issues_tracker_id"
,
id
)
end
end
issues_tracker
[
'project_url'
]
url
end
end
db/migrate/20150306023106_fix_namespace_duplication.rb
0 → 100644
View file @
2c7565ec
class
FixNamespaceDuplication
<
ActiveRecord
::
Migration
def
up
#fixes path duplication
select_all
(
'SELECT MAX(id) max, COUNT(id) cnt, path FROM namespaces GROUP BY path HAVING COUNT(id) > 1'
).
each
do
|
nms
|
bad_nms_ids
=
select_all
(
"SELECT id FROM namespaces WHERE path = '
#{
nms
[
'path'
]
}
' AND id <>
#{
nms
[
'max'
]
}
"
).
map
{
|
x
|
x
[
"id"
]}
execute
(
"UPDATE projects SET namespace_id =
#{
nms
[
"max"
]
}
WHERE namespace_id IN(
#{
bad_nms_ids
.
join
(
', '
)
}
)"
)
execute
(
"DELETE FROM namespaces WHERE id IN(
#{
bad_nms_ids
.
join
(
', '
)
}
)"
)
end
#fixes name duplication
select_all
(
'SELECT MAX(id) max, COUNT(id) cnt, name FROM namespaces GROUP BY name HAVING COUNT(id) > 1'
).
each
do
|
nms
|
bad_nms_ids
=
select_all
(
"SELECT id FROM namespaces WHERE name = '
#{
nms
[
'name'
]
}
' AND id <>
#{
nms
[
'max'
]
}
"
).
map
{
|
x
|
x
[
"id"
]}
execute
(
"UPDATE projects SET namespace_id =
#{
nms
[
"max"
]
}
WHERE namespace_id IN(
#{
bad_nms_ids
.
join
(
', '
)
}
)"
)
execute
(
"DELETE FROM namespaces WHERE id IN(
#{
bad_nms_ids
.
join
(
', '
)
}
)"
)
end
end
def
down
# not implemented
end
end
db/migrate/20150306023112_add_unique_index_to_namespace.rb
0 → 100644
View file @
2c7565ec
class
AddUniqueIndexToNamespace
<
ActiveRecord
::
Migration
def
change
remove_index
:namespaces
,
column: :name
if
index_exists?
(
:namespaces
,
:name
)
remove_index
:namespaces
,
column: :path
if
index_exists?
(
:namespaces
,
:path
)
add_index
:namespaces
,
:name
,
unique:
true
add_index
:namespaces
,
:path
,
unique:
true
end
end
db/schema.rb
View file @
2c7565ec
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
20150
21312104
2
)
do
ActiveRecord
::
Schema
.
define
(
version:
20150
30602311
2
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
@@ -242,9 +242,9 @@ ActiveRecord::Schema.define(version: 20150213121042) do
end
add_index
"namespaces"
,
[
"created_at"
,
"id"
],
name:
"index_namespaces_on_created_at_and_id"
,
using: :btree
add_index
"namespaces"
,
[
"name"
],
name:
"index_namespaces_on_name"
,
using: :btree
add_index
"namespaces"
,
[
"name"
],
name:
"index_namespaces_on_name"
,
u
nique:
true
,
u
sing: :btree
add_index
"namespaces"
,
[
"owner_id"
],
name:
"index_namespaces_on_owner_id"
,
using: :btree
add_index
"namespaces"
,
[
"path"
],
name:
"index_namespaces_on_path"
,
using: :btree
add_index
"namespaces"
,
[
"path"
],
name:
"index_namespaces_on_path"
,
u
nique:
true
,
u
sing: :btree
add_index
"namespaces"
,
[
"type"
],
name:
"index_namespaces_on_type"
,
using: :btree
create_table
"notes"
,
force:
true
do
|
t
|
...
...
@@ -334,12 +334,12 @@ ActiveRecord::Schema.define(version: 20150213121042) do
t
.
string
"import_url"
t
.
integer
"visibility_level"
,
default:
0
,
null:
false
t
.
boolean
"archived"
,
default:
false
,
null:
false
t
.
string
"avatar"
t
.
string
"import_status"
t
.
float
"repository_size"
,
default:
0.0
t
.
integer
"star_count"
,
default:
0
,
null:
false
t
.
string
"import_type"
t
.
string
"import_source"
t
.
string
"avatar"
end
add_index
"projects"
,
[
"created_at"
,
"id"
],
name:
"index_projects_on_created_at_and_id"
,
using: :btree
...
...
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