Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
933fe724
Commit
933fe724
authored
Jan 15, 2016
by
rojanu
Committed by
Gervase Markham
Jan 15, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 922549: Bugzilla::Migrate.pm should provide hook in load function. r=gerv.
parent
a0c3ade6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
152 additions
and
4 deletions
+152
-4
Hook.pm
Bugzilla/Hook.pm
+28
-0
Migrate.pm
Bugzilla/Migrate.pm
+16
-4
Extension.pm
extensions/Example/Extension.pm
+6
-0
ImportBugs.pm
extensions/Example/lib/Migrate/ImportBugs.pm
+102
-0
No files found.
Bugzilla/Hook.pm
View file @
933fe724
...
@@ -1083,6 +1083,34 @@ A hashref. The set of named parameters passed to C<create>.
...
@@ -1083,6 +1083,34 @@ A hashref. The set of named parameters passed to C<create>.
=back
=back
=head2 migrate_modules
This hook allows you to add modules to Migrate to support additional systems
to be imported into Bugzilla
Params:
=over
=item C<modules> - An hashref containing data to be returned to L<Bugzilla::Migrate>.
This hashref contains the path and prefix for the modules to be used.
=over
=item C<path> - Path to where the modules are kept, on a typical extension this
would be the lib folder of the extension.
=item C<prefix> - Package prefix of the module to be loaded
=back
The definition is structured as:
$modules = { path => $path, prefix => $prefix };
=back
=head2 object_before_delete
=head2 object_before_delete
This happens in L<Bugzilla::Object/remove_from_db>, after we've confirmed
This happens in L<Bugzilla::Object/remove_from_db>, after we've confirmed
...
...
Bugzilla/Migrate.pm
View file @
933fe724
...
@@ -199,12 +199,24 @@ sub load {
...
@@ -199,12 +199,24 @@ sub load {
my
@migration_modules
=
glob
(
"$libdir/Bugzilla/Migrate/*"
);
my
@migration_modules
=
glob
(
"$libdir/Bugzilla/Migrate/*"
);
my
(
$module
)
=
grep
{
basename
(
$_
)
=~
/^\Q$from\E\.pm$/i
}
my
(
$module
)
=
grep
{
basename
(
$_
)
=~
/^\Q$from\E\.pm$/i
}
@migration_modules
;
@migration_modules
;
if
(
!
$module
)
{
if
(
$module
)
{
require
$module
;
my
$canonical_name
=
_canonical_name
(
$module
);
return
"Bugzilla::Migrate::$canonical_name"
->
new
;
}
else
{
my
$migrate_module
=
{};
Bugzilla::Hook::
process
(
'migrate_modules'
,
$migrate_module
);
@migration_modules
=
glob
(
$migrate_module
->
{
path
}
.
"/*"
);
(
$module
)
=
grep
{
basename
(
$_
)
=~
/^\Q$from\E\.pm$/i
}
@migration_modules
;
if
(
!
$module
)
{
ThrowUserError
(
'migrate_from_invalid'
,
{
from
=>
$from
});
ThrowUserError
(
'migrate_from_invalid'
,
{
from
=>
$from
});
}
require
$module
;
my
$canonical_name
=
_canonical_name
(
$module
);
return
"$migrate_module->{prefix}::$canonical_name"
->
new
;
}
}
require
$module
;
my
$canonical_name
=
_canonical_name
(
$module
);
return
"Bugzilla::Migrate::$canonical_name"
->
new
;
}
}
#############
#############
...
...
extensions/Example/Extension.pm
View file @
933fe724
...
@@ -635,6 +635,12 @@ sub mailer_before_send {
...
@@ -635,6 +635,12 @@ sub mailer_before_send {
$email
->
header_set
(
'X-Bugzilla-Example-Header'
,
'Example'
);
$email
->
header_set
(
'X-Bugzilla-Example-Header'
,
'Example'
);
}
}
sub
migrate_modules
{
my
(
$self
,
$args
)
=
@_
;
$args
->
{
path
}
=
bz_locations
->
{
'extensionsdir'
}
.
"/Example/lib/Migrate"
;
$args
->
{
prefix
}
=
"Bugzilla::Extension::Example:Migrate"
;
}
sub
object_before_create
{
sub
object_before_create
{
my
(
$self
,
$args
)
=
@_
;
my
(
$self
,
$args
)
=
@_
;
...
...
extensions/Example/lib/Migrate/ImportBugs.pm
0 → 100644
View file @
933fe724
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This Source Code Form is "Incompatible With Secondary Licenses", as
# defined by the Mozilla Public License, v. 2.0.
=head1 NAME
Bugzilla::Extension::Example::Migrate::ImportBugs - Bugzilla example bug importer
=head1 DESCRIPTION
This is not a complete implementation of a Import module. For a working
implementation see L<Bugzilla::Migrate::Gnats>.
=cut
package
Bugzilla::Extension::Example::Migrate::
ImportBugs
;
use
strict
;
use
base
qw(Bugzilla::Migrate)
;
use
Bugzilla::
Constants
;
use
Bugzilla::Install::
Util
qw(indicate_progress)
;
use
Bugzilla::
Util
qw(format_time trim generate_random_password)
;
use
constant
REQUIRED_MODULES
=>
[
{
package
=>
'Email-Simple-FromHandle'
,
module
=>
'Email::Simple::FromHandle'
,
version
=>
0.050
,
},
];
use
constant
FIELD_MAP
=>
{
'Number'
=>
'bug_id'
,
'Category'
=>
'product'
,
};
use
constant
VALUE_MAP
=>
{
bug_severity
=>
{
'serious'
=>
'major'
,
'non-critical'
=>
'normal'
,
},
bug_status
=>
{
'feedback'
=>
'RESOLVED'
,
'released'
=>
'VERIFIED'
,
},
};
use
constant
IMPORTBUGS_CONFIG_VARS
=>
(
{
name
=>
'default_email_domain'
,
default
=>
'example.com'
,
desc
=>
<<
'END'
,
# Some users do not have full email addresses, but Bugzilla requires
# every user to have an email address. What domain should be appended to
# usernames that don't have emails, to make them into email addresses?
# (For example, if you leave this at the default, "unknown" would become
# "unknown@example.com".)
END
},
);
#########
# Hooks #
#########
sub
before_insert
{
my
$self
=
shift
;
}
#########
# Users #
#########
sub
_read_users
{
my
$self
=
shift
;
}
############
# Products #
############
sub
_read_products
{
my
$self
=
shift
;
}
################
# Reading Bugs #
################
sub
_read_bugs
{
my
$self
=
shift
;
}
sub
_parse_project
{
my
(
$self
,
$directory
)
=
@_
;
}
1
;
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