Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
redmine-sync
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gerhard Gonter
redmine-sync
Compare revisions
be42544086b0a366b247f74008154aa84946ba9a to 9048e2200e590ff4e6d2775abbb3792036963bc1
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
gg/redmine-sync
Select target project
No results found
9048e2200e590ff4e6d2775abbb3792036963bc1
Select Git revision
Branches
master
1 result
Swap
Target
gg/redmine-sync
Select target project
gg/redmine-sync
1 result
be42544086b0a366b247f74008154aa84946ba9a
Select Git revision
Branches
master
1 result
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (4)
added command to download attachments
· 98215c5d
Gerhard Gonter
authored
2 years ago
98215c5d
allow other columns than "id" to be the primary key which is used for caching
· aa00521d
Gerhard Gonter
authored
10 months ago
aa00521d
ignore VIM's swap files
· 5c98a217
Gerhard Gonter
authored
10 months ago
5c98a217
allow selective download of several attachments, attached to one issue
· 9048e220
Gerhard Gonter
authored
10 months ago
9048e220
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
lib/Redmine/CLI.pm
+59
-5
59 additions, 5 deletions
lib/Redmine/CLI.pm
lib/Redmine/DB/MySQL.pm
+31
-7
31 additions, 7 deletions
lib/Redmine/DB/MySQL.pm
with
91 additions
and
12 deletions
.gitignore
View file @
9048e220
@*
ts.*
*.tsv
.*.swp
typescript
tmp/
export/
This diff is collapsed.
Click to expand it.
lib/Redmine/CLI.pm
View file @
9048e220
...
...
@@ -56,8 +56,12 @@ EOPOD
=head2 Overview
help [topic] (this overview)
list
show ticket
list ... list tickets in current project
show ticket ... show ticket with this number
att ticket nr ... download attachment nr <nr> from ticket <ticket>
instances ... list all instances
projects ... list all projects
=cut
EOPOD
...
...
@@ -277,6 +281,8 @@ sub interpret
return
undef
;
}
my
@res
;
if
(
$op_mode
eq
'
help
')
{
usage
('
help
',
(
@$pars
)
?
shift
(
@$pars
)
:
'
overview
');
}
elsif
(
$op_mode
eq
'
exit
')
{
return
0
;
}
elsif
(
$op_mode
eq
'
interact
'
||
$op_mode
eq
'
i
')
...
...
@@ -334,6 +340,7 @@ sub interpret
my
$out_tsv
=
$self
->
{
out_tsv
};
my
(
$proj_list
,
$csv
)
=
Redmine::CLI::
show_projects
(
$rm
,
$out_tsv
);
$self
->
{
project_list
}
=
$proj_list
;
push
(
@res
,
$proj_list
);
}
elsif
(
$op_mode
eq
'
wiki
')
{
...
...
@@ -371,7 +378,19 @@ sub interpret
push
(
@$pars
,
$self
->
{
ticket_number
})
if
(
!
@$pars
&&
exists
(
$self
->
{
ticket_number
}));
foreach
my
$ticket_number
(
@$pars
)
{
Redmine::CLI::
show_issue
(
$rm
,
$ticket_number
);
my
$issue
=
Redmine::CLI::
show_issue
(
$rm
,
$ticket_number
);
$self
->
{
ticket_number
}
=
$ticket_number
;
push
(
@res
,
$issue
);
}
}
elsif
(
$op_mode
eq
'
att
')
{
my
$rm
=
$mRM
->
attach
();
push
(
@$pars
,
$self
->
{
ticket_number
})
if
(
!
@$pars
&&
exists
(
$self
->
{
ticket_number
}));
my
$att_nr
=
$pars
->
[
1
];
foreach
my
$ticket_number
(
@$pars
)
{
Redmine::CLI::
download_attachment
(
$rm
,
$ticket_number
,
$att_nr
);
$self
->
{
ticket_number
}
=
$ticket_number
;
}
}
...
...
@@ -438,7 +457,7 @@ not needed?
=end comment
=cut
return
1
;
return
(
1
,
\
@res
)
;
}
sub
interact
...
...
@@ -459,7 +478,7 @@ sub interact
my
(
$op
,
@pars
)
=
split
('
',
$l
);
print
"
op=[
$op
]
\n
";
my
$continue
=
interpret
(
$self
,
$op
,
\
@pars
);
my
(
$continue
)
=
interpret
(
$self
,
$op
,
\
@pars
);
last
unless
(
$continue
);
}
}
...
...
@@ -726,6 +745,41 @@ sub show_issue
$issue
;
}
sub
download_attachment
{
my
$rm
=
shift
;
my
$ticket_number
=
shift
;
my
$number
=
shift
;
my
$ua
=
$rm
->
{
ua
};
return
undef
unless
(
defined
(
$ua
));
my
$issue
=
$rm
->
issue
(
$ticket_number
,
{
include
=>
'
attachments
'
}
);
my
$attachments
=
$issue
->
{
issue
}
->
{
attachments
};
# print "attachments: ", Dumper ($attachments);
return
undef
unless
(
defined
(
$attachments
));
my
@attachment_numbers
;
if
(
!
defined
(
$number
)
||
$number
eq
'
*
')
{
push
(
@attachment_numbers
,
0
..
$#$attachments
);
}
elsif
(
$number
=~
/^\d+$/
)
{
@attachment_numbers
=
$number
;
}
elsif
(
$number
=~
/^\d[\d,-]*\d$/
)
{
print
"
number ranges not yet implemented
\n
";
return
undef
;
}
print
__LINE__
,
"
attachment_numbers:
",
join
('
',
@attachment_numbers
),
"
\n
";
my
@dl_attachments
;
foreach
my
$num
(
@attachment_numbers
)
{
my
$attachment
=
$attachments
->
[
$num
];
next
unless
(
defined
(
$attachment
));
# print __LINE__, " attachment: ", Dumper ($attachment);
print
__LINE__
,
"
attachment num=[
$num
]
",
$attachment
->
{
filename
},
"
\n
";
$ua
->
get
(
$attachment
->
{
content_url
},
'
:content_file
'
=>
$attachment
->
{
filename
});
push
(
@dl_attachments
,
$attachment
);
}
return
(
wantarray
)
?
@dl_attachments
:
\
@dl_attachments
;
}
sub
usage
{
my
$pod
=
new
Pod::Simple::
Text
();
...
...
This diff is collapsed.
Click to expand it.
lib/Redmine/DB/MySQL.pm
View file @
9048e220
...
...
@@ -31,7 +31,8 @@ sub connect
# print "db_con=[$db_con]\n";
$dbh
=
DBI
->
connect
(
$db_con
,
map
{
$self
->
{
$_
}
}
qw(username password)
);
# print "dbh=[$dbh]\n";
print
join
('
',
__FILE__
,
__LINE__
,
'
caller
',
caller
(),
"
dbh=[
$dbh
]
\n
");
# exit;
if
(
exists
(
$self
->
{
encoding
}))
{
...
...
@@ -110,14 +111,14 @@ sub get_all_x
my
$t
=
$self
->
table
(
$table
);
my
$tt
=
{};
my
$pri
=
(
exists
(
$self
->
{
PRI
}
->
{
$table
}))
?
$self
->
{
PRI
}
->
{
$table
}
:
'
id
';
my
$pri
=
(
exists
(
$self
->
{
PRI
}
->
{
$table
}))
?
$self
->
{
PRI
}
->
{
$table
}
:
[
'
id
'
]
;
# print __LINE__, " pri=[$pri] ", main::Dumper ($self->{PRI});
# print __LINE__, " pri=[$pri]\n";
# print __LINE__, "
table=[$table]
pri=[$pri]\n";
while
(
defined
(
my
$x
=
$sth
->
fetchrow_hashref
()))
{
print
"
x:
",
Dumper
(
$x
)
if
(
$show_fetched
);
my
$i
=
$x
->
{
$pri
}
;
my
$i
=
join
('
,
',
map
{
$x
->
{
$_
}
}
@
$pri
)
;
$t
->
{
$i
}
=
$tt
->
{
$i
}
=
$x
;
}
...
...
@@ -224,6 +225,7 @@ sub desc
# my @desc_columns= qw(Field Type Null Key Default Extra);
my
@PRI
;
while
(
my
@x
=
$sth
->
fetchrow_array
())
{
last
unless
(
@x
);
...
...
@@ -232,10 +234,14 @@ sub desc
if
(
$x
[
3
]
eq
'
PRI
')
{
$self
->
{
PRI
}
->
{
$table
}
=
$x
[
0
];
push
(
@PRI
,
$x
[
0
]
)
;
}
}
my
$PRI
=
join
('
,
',
@PRI
);
$self
->
{
PRI
}
->
{
$table
}
=
\
@PRI
;
# print join(' ', __FILE__, __LINE__, 'table:', $table, 'PRI:', $PRI), "\n";
$td
;
}
...
...
@@ -299,13 +305,31 @@ sub update
push
(
@vars
,
$an
);
push
(
@vals
,
$updates
->
{
$an
});
}
push
(
@vals
,
$id
);
my
$pri
=
(
exists
(
$self
->
{
PRI
}
->
{
$table
}))
?
$self
->
{
PRI
}
->
{
$table
}
:
'
id
';
# print __LINE__, " pri=[$pri] ", main::Dumper ($self->{PRI});
# print __LINE__, " pri=[$pri]\n";
my
$ssu
=
"
UPDATE `
$table
` SET
"
.
join
('
,
',
map
{
$_
.
'
=?
'
}
@vars
)
.
"
WHERE `
$pri
`=?
";
# Hmm... WHERE ?=?
# ATTN: $pri is a array ref with the column names forming the primary key; there can be more than one!!
# TODO: currently only the first variable name is used with a value!
print
__LINE__
,
"
caller:
",
join
('
',
caller
()),
"
\n
";
my
@conditions
;
if
(
ref
(
$pri
)
eq
'
ARRAY
')
{
foreach
my
$attr_name
(
@$pri
)
{
push
(
@conditions
,
"
`
$attr_name
`=?
");
}
push
(
@vals
,
@$id
);
}
else
{
push
(
@conditions
,
"
`
$pri
`=?
");
push
(
@vals
,
$id
);
}
my
$ssu
=
"
UPDATE `
$table
` SET
"
.
join
('
,
',
map
{
$_
.
'
=?
'
}
@vars
)
.
"
WHERE
"
.
join
('
AND
',
@conditions
);
# Hmm... WHERE ?=?
if
(
$show_updates
)
{
...
...
This diff is collapsed.
Click to expand it.