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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
8bac6e41
Commit
8bac6e41
authored
Sep 29, 2017
by
Lin Jen-Shin (godfat)
Committed by
Rémy Coutable
Sep 29, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix notes type created from import
parent
ccfe6860
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
155 additions
and
37 deletions
+155
-37
changelogs/unreleased/38432-fix-notes-type-for-import.yml
changelogs/unreleased/38432-fix-notes-type-for-import.yml
+6
-0
db/post_migrate/20170927112318_update_legacy_diff_notes_type_for_import.rb
...0170927112318_update_legacy_diff_notes_type_for_import.rb
+16
-0
db/post_migrate/20170927112319_update_notes_type_for_import.rb
...st_migrate/20170927112319_update_notes_type_for_import.rb
+16
-0
lib/github/import.rb
lib/github/import.rb
+4
-37
lib/github/import/issue.rb
lib/github/import/issue.rb
+13
-0
lib/github/import/legacy_diff_note.rb
lib/github/import/legacy_diff_note.rb
+12
-0
lib/github/import/merge_request.rb
lib/github/import/merge_request.rb
+13
-0
lib/github/import/note.rb
lib/github/import/note.rb
+13
-0
spec/lib/github/import/legacy_diff_note_spec.rb
spec/lib/github/import/legacy_diff_note_spec.rb
+9
-0
spec/lib/github/import/note_spec.rb
spec/lib/github/import/note_spec.rb
+9
-0
spec/migrations/update_legacy_diff_notes_type_for_import_spec.rb
...grations/update_legacy_diff_notes_type_for_import_spec.rb
+22
-0
spec/migrations/update_notes_type_for_import_spec.rb
spec/migrations/update_notes_type_for_import_spec.rb
+22
-0
No files found.
changelogs/unreleased/38432-fix-notes-type-for-import.yml
0 → 100644
View file @
8bac6e41
---
title
:
Fix notes type created from import. This should fix some missing notes issues
from imported projects
merge_request
:
14524
author
:
type
:
fixed
db/post_migrate/20170927112318_update_legacy_diff_notes_type_for_import.rb
0 → 100644
View file @
8bac6e41
class
UpdateLegacyDiffNotesTypeForImport
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
up
update_column_in_batches
(
:notes
,
:type
,
'LegacyDiffNote'
)
do
|
table
,
query
|
query
.
where
(
table
[
:type
].
eq
(
'Github::Import::LegacyDiffNote'
))
end
end
def
down
end
end
db/post_migrate/20170927112319_update_notes_type_for_import.rb
0 → 100644
View file @
8bac6e41
class
UpdateNotesTypeForImport
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
up
update_column_in_batches
(
:notes
,
:type
,
'Note'
)
do
|
table
,
query
|
query
.
where
(
table
[
:type
].
eq
(
'Github::Import::Note'
))
end
end
def
down
end
end
lib/github/import.rb
View file @
8bac6e41
require_relative
'error'
require_relative
'import/issue'
require_relative
'import/legacy_diff_note'
require_relative
'import/merge_request'
require_relative
'import/note'
module
Github
class
Import
include
Gitlab
::
ShellAdapter
class
MergeRequest
<
::
MergeRequest
self
.
table_name
=
'merge_requests'
self
.
reset_callbacks
:create
self
.
reset_callbacks
:save
self
.
reset_callbacks
:commit
self
.
reset_callbacks
:update
self
.
reset_callbacks
:validate
end
class
Issue
<
::
Issue
self
.
table_name
=
'issues'
self
.
reset_callbacks
:save
self
.
reset_callbacks
:create
self
.
reset_callbacks
:commit
self
.
reset_callbacks
:update
self
.
reset_callbacks
:validate
end
class
Note
<
::
Note
self
.
table_name
=
'notes'
self
.
reset_callbacks
:save
self
.
reset_callbacks
:commit
self
.
reset_callbacks
:update
self
.
reset_callbacks
:validate
end
class
LegacyDiffNote
<
::
LegacyDiffNote
self
.
table_name
=
'notes'
self
.
reset_callbacks
:commit
self
.
reset_callbacks
:update
self
.
reset_callbacks
:validate
end
attr_reader
:project
,
:repository
,
:repo
,
:repo_url
,
:wiki_url
,
:options
,
:errors
,
:cached
,
:verbose
...
...
lib/github/import/issue.rb
0 → 100644
View file @
8bac6e41
module
Github
class
Import
class
Issue
<
::
Issue
self
.
table_name
=
'issues'
self
.
reset_callbacks
:save
self
.
reset_callbacks
:create
self
.
reset_callbacks
:commit
self
.
reset_callbacks
:update
self
.
reset_callbacks
:validate
end
end
end
lib/github/import/legacy_diff_note.rb
0 → 100644
View file @
8bac6e41
module
Github
class
Import
class
LegacyDiffNote
<
::
LegacyDiffNote
self
.
table_name
=
'notes'
self
.
store_full_sti_class
=
false
self
.
reset_callbacks
:commit
self
.
reset_callbacks
:update
self
.
reset_callbacks
:validate
end
end
end
lib/github/import/merge_request.rb
0 → 100644
View file @
8bac6e41
module
Github
class
Import
class
MergeRequest
<
::
MergeRequest
self
.
table_name
=
'merge_requests'
self
.
reset_callbacks
:create
self
.
reset_callbacks
:save
self
.
reset_callbacks
:commit
self
.
reset_callbacks
:update
self
.
reset_callbacks
:validate
end
end
end
lib/github/import/note.rb
0 → 100644
View file @
8bac6e41
module
Github
class
Import
class
Note
<
::
Note
self
.
table_name
=
'notes'
self
.
store_full_sti_class
=
false
self
.
reset_callbacks
:save
self
.
reset_callbacks
:commit
self
.
reset_callbacks
:update
self
.
reset_callbacks
:validate
end
end
end
spec/lib/github/import/legacy_diff_note_spec.rb
0 → 100644
View file @
8bac6e41
require
'spec_helper'
describe
Github
::
Import
::
LegacyDiffNote
do
describe
'#type'
do
it
'returns the original note type'
do
expect
(
described_class
.
new
.
type
).
to
eq
(
'LegacyDiffNote'
)
end
end
end
spec/lib/github/import/note_spec.rb
0 → 100644
View file @
8bac6e41
require
'spec_helper'
describe
Github
::
Import
::
Note
do
describe
'#type'
do
it
'returns the original note type'
do
expect
(
described_class
.
new
.
type
).
to
eq
(
'Note'
)
end
end
end
spec/migrations/update_legacy_diff_notes_type_for_import_spec.rb
0 → 100644
View file @
8bac6e41
require
'spec_helper'
require
Rails
.
root
.
join
(
'db'
,
'post_migrate'
,
'20170927112318_update_legacy_diff_notes_type_for_import.rb'
)
describe
UpdateLegacyDiffNotesTypeForImport
,
:migration
do
let
(
:notes
)
{
table
(
:notes
)
}
before
do
notes
.
inheritance_column
=
nil
notes
.
create
(
type:
'Note'
)
notes
.
create
(
type:
'LegacyDiffNote'
)
notes
.
create
(
type:
'Github::Import::Note'
)
notes
.
create
(
type:
'Github::Import::LegacyDiffNote'
)
end
it
'updates the notes type'
do
migrate!
expect
(
notes
.
pluck
(
:type
))
.
to
contain_exactly
(
'Note'
,
'Github::Import::Note'
,
'LegacyDiffNote'
,
'LegacyDiffNote'
)
end
end
spec/migrations/update_notes_type_for_import_spec.rb
0 → 100644
View file @
8bac6e41
require
'spec_helper'
require
Rails
.
root
.
join
(
'db'
,
'post_migrate'
,
'20170927112319_update_notes_type_for_import.rb'
)
describe
UpdateNotesTypeForImport
,
:migration
do
let
(
:notes
)
{
table
(
:notes
)
}
before
do
notes
.
inheritance_column
=
nil
notes
.
create
(
type:
'Note'
)
notes
.
create
(
type:
'LegacyDiffNote'
)
notes
.
create
(
type:
'Github::Import::Note'
)
notes
.
create
(
type:
'Github::Import::LegacyDiffNote'
)
end
it
'updates the notes type'
do
migrate!
expect
(
notes
.
pluck
(
:type
))
.
to
contain_exactly
(
'Note'
,
'Note'
,
'LegacyDiffNote'
,
'Github::Import::LegacyDiffNote'
)
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