mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Bug
- Fixed bug that required the '%YAML' prologue in a YAML import.
This commit is contained in:
parent
1d10370341
commit
73f72c54c1
3 changed files with 50 additions and 4 deletions
|
@ -82,6 +82,7 @@
|
||||||
not located (thanks to Christopher J. Pilkington).
|
not located (thanks to Christopher J. Pilkington).
|
||||||
|
|
||||||
# Untracked Bugs, biggest first.
|
# Untracked Bugs, biggest first.
|
||||||
|
+ Fixed bug that required the '%YAML' prologue in a YAML import.
|
||||||
|
|
||||||
------ old releases ------------------------------
|
------ old releases ------------------------------
|
||||||
|
|
||||||
|
|
|
@ -80,9 +80,15 @@ static fileType determineFileType (const std::vector <std::string>& lines)
|
||||||
return task_1_4_3;
|
return task_1_4_3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lines.size () > 2 &&
|
if ((lines.size () > 2 &&
|
||||||
lines[0] == "%YAML 1.1" &&
|
lines[0] == "%YAML 1.1" &&
|
||||||
lines[1] == "---")
|
lines[1] == "---")
|
||||||
|
||
|
||||||
|
(lines.size () > 3 &&
|
||||||
|
(lines[0].find ("task:") != std::string::npos ||
|
||||||
|
lines[1].find ("task:") != std::string::npos ||
|
||||||
|
lines[2].find ("task:") != std::string::npos ||
|
||||||
|
lines[3].find ("task:") != std::string::npos)))
|
||||||
{
|
{
|
||||||
return yaml;
|
return yaml;
|
||||||
}
|
}
|
||||||
|
@ -1249,6 +1255,23 @@ static std::string importYAML (const std::vector <std::string>& lines)
|
||||||
t.set (name, value);
|
t.set (name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (t.size ())
|
||||||
|
{
|
||||||
|
// Generate a UUID if not present.
|
||||||
|
if (t.get ("uuid") == "")
|
||||||
|
t.set ("uuid", uuid ());
|
||||||
|
|
||||||
|
// Add defaults.
|
||||||
|
decorateTask (t);
|
||||||
|
t.setStatus (status);
|
||||||
|
|
||||||
|
// TODO Fail on UUID collision.
|
||||||
|
|
||||||
|
context.tdb.add (t);
|
||||||
|
t.clear ();
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More tests => 15;
|
use Test::More tests => 18;
|
||||||
|
|
||||||
# Create the rc file.
|
# Create the rc file.
|
||||||
if (open my $fh, '>', 'import.rc')
|
if (open my $fh, '>', 'import.rc')
|
||||||
|
@ -100,10 +100,32 @@ like ($output, qr/2\/13\/2009.+two/, 't3 present');
|
||||||
$output = qx{../src/task rc:import.rc import import.txt};
|
$output = qx{../src/task rc:import.rc import import.txt};
|
||||||
like ($output, qr/Cannot add task because the uuid .+ is not unique\./, 'error on duplicate uuid');
|
like ($output, qr/Cannot add task because the uuid .+ is not unique\./, 'error on duplicate uuid');
|
||||||
|
|
||||||
|
# Create import file.
|
||||||
|
if (open my $fh, '>', 'import2.txt')
|
||||||
|
{
|
||||||
|
print $fh <<EOF;
|
||||||
|
task:
|
||||||
|
uuid: 44444444-4444-4444-4444-444444444444
|
||||||
|
description: three
|
||||||
|
status: pending
|
||||||
|
entry: 1234567889
|
||||||
|
EOF
|
||||||
|
|
||||||
|
close $fh;
|
||||||
|
ok (-r 'import2.txt', 'Created second sample import data');
|
||||||
|
}
|
||||||
|
|
||||||
|
$output = qx{../src/task rc:import.rc import import2.txt};
|
||||||
|
like ($output, qr/Imported 1 tasks successfully./, 'no errors');
|
||||||
|
# Imported 1 tasks successfully.
|
||||||
|
|
||||||
# Cleanup.
|
# Cleanup.
|
||||||
unlink 'import.txt';
|
unlink 'import.txt';
|
||||||
ok (!-r 'import.txt', 'Removed import.txt');
|
ok (!-r 'import.txt', 'Removed import.txt');
|
||||||
|
|
||||||
|
unlink 'import2.txt';
|
||||||
|
ok (!-r 'import2.txt', 'Removed import2.txt');
|
||||||
|
|
||||||
unlink 'pending.data';
|
unlink 'pending.data';
|
||||||
ok (!-r 'pending.data', 'Removed pending.data');
|
ok (!-r 'pending.data', 'Removed pending.data');
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue