-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdump-jira.pl
executable file
·53 lines (44 loc) · 1.33 KB
/
dump-jira.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env perl
use 5.010;
use strict;
use warnings;
use XML::LibXML;
use YAML::PP;
my $dom = XML::LibXML->load_xml(location => 'entities.xml');
my $y = YAML::PP->new();
#say ($dom->to_literal());
my $issues = {};
foreach my $issue ($dom->findnodes('/entity-engine-xml/Issue')) {
my $i;
foreach my $attr ($issue->attributes) {
$i->{ $attr->nodeName } = $attr->nodeValue;
}
my $desc = $issue->to_literal();
$desc =~ s/^\s+//;
$desc =~ s/\s+$//;
$i->{description} = $desc;
$issues->{$i->{id}} = $i;
}
foreach my $action ($dom->findnodes('/entity-engine-xml/Action')) {
my $a;
foreach my $attr ($action->attributes) {
$a->{ $attr->nodeName } = $attr->nodeValue;
}
my $body = $a->{body} || $action->to_literal();
$body =~ s/^\s+//;
$body =~ s/\s+$//;
$a->{body} = $body;
push @{$issues->{ $a->{issue} }->{actions}}, $a;
}
foreach my $id (keys %$issues) {
open (FILE, ">", "browse/".$issues->{$id}->{key}) || die $!;
binmode FILE, ":utf8";
my $actions = delete $issues->{$id}->{actions};
for my $key (qw(summary)) {
print FILE $y->dump_string({ $key => $issues->{$id}->{$key} });
delete $issues->{$id}->{$key};
}
print FILE $y->dump_string($issues->{$id});
print FILE $y->dump_string({ actions => $actions });
close (FILE);
}