Feature #1256 Follow-up

- Extended unit tests to cover 'add' failures.
- Removed whitespace at EOL.
- Updated ChangeLog, AUTHORS, NEWS.
- Updated taskrc.5.in.
- Updated CmdShow to allow new config settings.
This commit is contained in:
Paul Beckingham 2013-05-07 16:20:47 -04:00
parent 56eab7da0d
commit 157699cbde
8 changed files with 33 additions and 18 deletions

View file

@ -86,6 +86,7 @@ The following submitted code, packages or analysis, and deserve special thanks:
Russell Steicke Russell Steicke
YBSAR YBSAR
Tullio Facchinetti Tullio Facchinetti
Thomas Sullivan
Thanks to the following, who submitted detailed bug reports and excellent Thanks to the following, who submitted detailed bug reports and excellent
suggestions: suggestions:

View file

@ -11,6 +11,7 @@ Features
+ #1227 A new 'verify_l10n' utility ensures the localizations are in sync (thanks to + #1227 A new 'verify_l10n' utility ensures the localizations are in sync (thanks to
Wim Schuermann). Wim Schuermann).
+ #1250 Support out-of-tree test runs (thanks to Jakub Wilk). + #1250 Support out-of-tree test runs (thanks to Jakub Wilk).
+ #1256 Supports default values for UDA fields (thanks to Thomas Sullivan).
+ Stores un-synched transactions in <data.location>/backlog.data. + Stores un-synched transactions in <data.location>/backlog.data.
+ Adds a new 'synchronize' command to sync data with a task server. + Adds a new 'synchronize' command to sync data with a task server.
+ Adds a new 'sync' verbosity token, which will reminds when a backlog builds + Adds a new 'sync' verbosity token, which will reminds when a backlog builds

1
NEWS
View file

@ -5,6 +5,7 @@ New Features in taskwarrior 2.3.0
- New shell with Readline support. - New shell with Readline support.
- The 'dateformat' settings now default to the ISO-8601 standard of 'Y-M-D'. - The 'dateformat' settings now default to the ISO-8601 standard of 'Y-M-D'.
- Italian translation. - Italian translation.
- UDA fields now allow default values.
New commands in taskwarrior 2.3.0 New commands in taskwarrior 2.3.0

View file

@ -1139,6 +1139,13 @@ Provides a default due date for the
.I task add .I task add
command, if you don't specify one. The default is blank. command, if you don't specify one. The default is blank.
.TP
.B
uda.<name>.default=...
Provides default values for UDA fields when using the
.I task add
command, if you don't specify values. The default is blank.
.TP .TP
.B .B
default.command=next default.command=next

View file

@ -1260,14 +1260,15 @@ void Task::validate (bool applyDefault /* = true */)
context.columns["due"]->validate (defaultDue)) context.columns["due"]->validate (defaultDue))
set ("due", Date (defaultDue).toEpoch ()); set ("due", Date (defaultDue).toEpoch ());
} }
// If a UDA has a default value in the configuration, // If a UDA has a default value in the configuration,
// override with uda.(uda).default, if not specified // override with uda.(uda).default, if not specified.
if (applyDefault) if (applyDefault)
{ // Gather a list of all UDAs with a .default value {
// Gather a list of all UDAs with a .default value
std::vector <std::string> names; std::vector <std::string> names;
context.config.all (names); context.config.all (names);
std::vector <std::string> udas; std::vector <std::string> udas;
std::vector <std::string>::iterator name; std::vector <std::string>::iterator name;
for (name = names.begin (); name != names.end (); ++name) for (name = names.begin (); name != names.end (); ++name)
@ -1280,9 +1281,10 @@ void Task::validate (bool applyDefault /* = true */)
udas.push_back (name->substr (4, period - 4)); udas.push_back (name->substr (4, period - 4));
} }
} }
if (udas.size ()) if (udas.size ())
{ // For each of those, setup the default value on the task now, {
// For each of those, setup the default value on the task now,
// of course only if we don't have one on the command line already // of course only if we don't have one on the command line already
std::vector <std::string>::iterator uda; std::vector <std::string>::iterator uda;
for (uda = udas.begin (); uda != udas.end (); ++uda) for (uda = udas.begin (); uda != udas.end (); ++uda)
@ -1291,12 +1293,11 @@ void Task::validate (bool applyDefault /* = true */)
std::string defVal = context.config.get ("uda." + *uda + ".default"); std::string defVal = context.config.get ("uda." + *uda + ".default");
// If the default is empty, and we already have a value, skip it // If the default is empty, and we already have a value, skip it
if (defVal != "" && get (*uda) == "") if (defVal != "" && get (*uda) == "")
set(*uda,defVal); set (*uda, defVal);
} }
} }
} }
// 2) To provide suitable warnings about odd states // 2) To provide suitable warnings about odd states
@ -1457,7 +1458,7 @@ float Task::urgency_c () const
value += fabsf (urgencyBlockingCoefficient) > epsilon ? (urgency_blocking () * urgencyBlockingCoefficient) : 0.0; value += fabsf (urgencyBlockingCoefficient) > epsilon ? (urgency_blocking () * urgencyBlockingCoefficient) : 0.0;
value += fabsf (urgencyAgeCoefficient) > epsilon ? (urgency_age () * urgencyAgeCoefficient) : 0.0; value += fabsf (urgencyAgeCoefficient) > epsilon ? (urgency_age () * urgencyAgeCoefficient) : 0.0;
/* /*
// Very useful for debugging urgency problems. // Very useful for debugging urgency problems.
std::cout << "# Urgency for " << get ("uuid") << ":\n" std::cout << "# Urgency for " << get ("uuid") << ":\n"
<< "# pri " << (urgency_priority () * urgencyPriorityCoefficient) << "\n" << "# pri " << (urgency_priority () * urgencyPriorityCoefficient) << "\n"

View file

@ -238,6 +238,7 @@ int CmdShow::execute (std::string& output)
i->substr (0, 5) != "pull." && i->substr (0, 5) != "pull." &&
i->substr (0, 6) != "merge." && i->substr (0, 6) != "merge." &&
i->substr (0, 4) != "uda." && i->substr (0, 4) != "uda." &&
i->substr (0, 4) != "default." &&
i->substr (0, 21) != "urgency.user.project." && i->substr (0, 21) != "urgency.user.project." &&
i->substr (0, 17) != "urgency.user.tag." && i->substr (0, 17) != "urgency.user.tag." &&
i->substr (0, 12) != "urgency.uda.") i->substr (0, 12) != "urgency.uda.")

View file

@ -85,7 +85,7 @@ int CmdUDAs::execute (std::string& output)
view.add (Column::factory ("string", STRING_COLUMN_LABEL_TYPE)); view.add (Column::factory ("string", STRING_COLUMN_LABEL_TYPE));
view.add (Column::factory ("string", STRING_COLUMN_LABEL_LABEL)); view.add (Column::factory ("string", STRING_COLUMN_LABEL_LABEL));
view.add (Column::factory ("string", STRING_COLUMN_LABEL_VALUES)); view.add (Column::factory ("string", STRING_COLUMN_LABEL_VALUES));
view.add (Column::factory ("string", STRING_COLUMN_LABEL_DEFAULT)); view.add (Column::factory ("string", STRING_COLUMN_LABEL_DEFAULT));
view.add (Column::factory ("string", STRING_COLUMN_LABEL_UDACOUNT)); view.add (Column::factory ("string", STRING_COLUMN_LABEL_UDACOUNT));
std::vector <std::string>::iterator uda; std::vector <std::string>::iterator uda;

View file

@ -28,7 +28,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 5; use Test::More tests => 8;
# Create the rc file. # Create the rc file.
if (open my $fh, '>', 'uda.rc') if (open my $fh, '>', 'uda.rc')
@ -50,15 +50,18 @@ if (open my $fh, '>', 'uda.rc')
} }
# Add task with nondefault UDA # Add task with nondefault UDA
qx{../src/task rc:uda.rc add one smell:strong 2>&1}; my $output = qx{../src/task rc:uda.rc add one smell:strong 2>&1};
like ($output, qr/Created task 1/, 'Add 1 - no errors');
# Add task without a UDA value, checking for usage of the default # Add task without a UDA value, checking for usage of the default
qx{../src/task rc:uda.rc add two 2>&1}; $output = qx{../src/task rc:uda.rc add two 2>&1};
like ($output, qr/Created task 2/, 'Add 2 - no errors');
# Add a task with a UDA that has no default, ensure it is entered fine # Add a task with a UDA that has no default, ensure it is entered fine
qx{../src/task rc:uda.rc add three size:10 2>&1}; $output = qx{../src/task rc:uda.rc add three size:10 2>&1};
like ($output, qr/Created task 3/, 'Add 3 - no errors');
my $output = qx{../src/task rc:uda.rc uda 2>&1}; $output = qx{../src/task rc:uda.rc uda 2>&1};
like ($output, qr/1\s+strong\s+one/, 'UDA nondefault stored'); like ($output, qr/1\s+strong\s+one/, 'UDA nondefault stored');
like ($output, qr/2\s+weak\s+two/, 'UDA default stored'); like ($output, qr/2\s+weak\s+two/, 'UDA default stored');
like ($output, qr/3\s+weak\s+10\s+three/, 'UDA without default stored'); like ($output, qr/3\s+weak\s+10\s+three/, 'UDA without default stored');