From c68b2a149ff528c34965f2419d00c8b128ba05eb Mon Sep 17 00:00:00 2001 From: Scott Kostyshak Date: Mon, 18 Feb 2013 06:24:47 -0500 Subject: [PATCH] Bug - The bash completion script no longer expands IDs after 'depends:'. (Such expansion required running gc() which is not correct.) - The unit tests for expanding 'depends:' were commented out (and not removed) in the case that someday we implement a command to list IDs without running gc(). - Unit tests to check that gc() is not run after 'depends:' were added. --- ChangeLog | 1 + NEWS | 3 ++- scripts/bash/task.sh | 18 +------------- test/bash_completion.t | 56 +++++++++++++++++++++++++++--------------- 4 files changed, 40 insertions(+), 38 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0d9e8393a..3b9200613 100644 --- a/ChangeLog +++ b/ChangeLog @@ -95,6 +95,7 @@ Bugs + Integrated latest UTF8 character width calculations from Markus Kuhn. + Fixed bug where localized UTF8 strings were not properly substr'd (thanks to Fidel Mato). + + Fixed a bug where the bash completion script was causing gc() to be run. ------ old releases ------------------------------ diff --git a/NEWS b/NEWS index 3f595bdb7..e910e8e88 100644 --- a/NEWS +++ b/NEWS @@ -24,7 +24,8 @@ New configuration options in taskwarrior 2.2.0 Newly deprecated features in taskwarrior 2.2.0 - - + - The bash completion script no longer expands IDs after 'depends:'. + (Such expansion required running gc() which is not correct.) --- diff --git a/scripts/bash/task.sh b/scripts/bash/task.sh index 1a8197c1b..6518ec184 100644 --- a/scripts/bash/task.sh +++ b/scripts/bash/task.sh @@ -62,10 +62,6 @@ _task_get_config() { $taskcommand _config } -_task_offer_dependencies() { - COMPREPLY=( $(compgen -W "$($taskcommand _ids)" -- ${cur/*:/}) ) -} - _task_offer_priorities() { COMPREPLY=( $(compgen -W "L M H" -- ${cur/*:/}) ) } @@ -94,17 +90,11 @@ _task() abbrev_min=$($taskcommand show | grep "abbreviation.minimum" | awk {'print $2'}) commands_aliases=$(echo $($taskcommand _commands; $taskcommand _aliases) | tr " " "\n"|sort|tr "\n" " ") - opts="$commands_aliases $($taskcommand _ids) $($taskcommand _columns)" + opts="$commands_aliases $($taskcommand _columns)" case "${prev}" in :) case "${prev2}" in - dep|depe|depen|depend|depends) - if [ ${#prev2} -ge $abbrev_min ]; then - _task_offer_dependencies - fi - return 0 - ;; pri|prior|priori|priorit|priority) if [ ${#prev2} -ge $abbrev_min ]; then _task_offer_priorities @@ -136,12 +126,6 @@ _task() ;; :) case "${prev}" in - dep|depe|depen|depend|depends) - if [ ${#prev} -ge $abbrev_min ]; then - _task_offer_dependencies - fi - return 0 - ;; pri|prior|priori|priorit|priority) if [ ${#prev} -ge $abbrev_min ]; then _task_offer_priorities diff --git a/test/bash_completion.t b/test/bash_completion.t index 45d377c0d..d83aff6c3 100755 --- a/test/bash_completion.t +++ b/test/bash_completion.t @@ -102,31 +102,47 @@ $output = qx{bash ./task.sh task proj : to 2>&1}; ok ($? == 0, 'Exit status check'); unlike ($output, qr/todd/, '\'proj:\' does not expand if abbreviation.minimum is 5'); -# "priority:" should be expanded correctly and dependent on abbreviation.minimum -$output = qx{bash ./task.sh task priorABC : 2>&1}; -ok ($? == 0, 'Exit status check'); -unlike ($output, qr/H/, '\'priorABC:\' does not expand'); +# The following tests were removed because we no longer expand task IDs after +# depends. This expansion was stopped because it was using the _ids command +# which runs _ids and can lead to confusing behavior for the user. See: +# https://groups.google.com/forum/#!topic/taskwarrior-dev/KwHnb9MOOqA -$output = qx{bash ./task.sh task prior : 2>&1}; -ok ($? == 0, 'Exit status check'); -like ($output, qr/H/, '\'prior:\' does expand'); +## "priority:" should be expanded correctly and dependent on abbreviation.minimum +#$output = qx{bash ./task.sh task priorABC : 2>&1}; +#ok ($? == 0, 'Exit status check'); +#unlike ($output, qr/H/, '\'priorABC:\' does not expand'); +# +#$output = qx{bash ./task.sh task prior : 2>&1}; +#ok ($? == 0, 'Exit status check'); +#like ($output, qr/H/, '\'prior:\' does expand'); +# +#$output = qx{bash ./task.sh task prio : 2>&1}; +#ok ($? == 0, 'Exit status check'); +#unlike ($output, qr/H/, '\'prio:\' does not expand if abbreviation.minimum is 5'); +# +## "depends:" should be expanded correctly and dependent on abbreviation.minimum +#$output = qx{bash ./task.sh task depenABC : 2>&1}; +#ok ($? == 0, 'Exit status check'); +#unlike ($output, qr/1/, '\'depenABC:\' does not expand'); +# +#$output = qx{bash ./task.sh task depen : 2>&1}; +#ok ($? == 0, 'Exit status check'); +#like ($output, qr/1/, '\'depen:\' does expand'); +# +#$output = qx{bash ./task.sh task depe : 2>&1}; +#ok ($? == 0, 'Exit status check'); +#unlike ($output, qr/1/, '\'depe:\' does not expand if abbreviation.minimum is 5'); -$output = qx{bash ./task.sh task prio : 2>&1}; +# there should be no gc coming from bash completion +qx{../src/task rc:bug.rc add this task should be number 2 and stay number 2 2>&1}; ok ($? == 0, 'Exit status check'); -unlike ($output, qr/H/, '\'prio:\' does not expand if abbreviation.minimum is 5'); - -# "depends:" should be expanded correctly and dependent on abbreviation.minimum -$output = qx{bash ./task.sh task depenABC : 2>&1}; +qx{../src/task rc:bug.rc rc.confirmation:off 1 delete 2>&1}; ok ($? == 0, 'Exit status check'); -unlike ($output, qr/1/, '\'depenABC:\' does not expand'); - -$output = qx{bash ./task.sh task depen : 2>&1}; +qx{bash ./task.sh task depends : 2>&1}; ok ($? == 0, 'Exit status check'); -like ($output, qr/1/, '\'depen:\' does expand'); - -$output = qx{bash ./task.sh task depe : 2>&1}; -ok ($? == 0, 'Exit status check'); -unlike ($output, qr/1/, '\'depe:\' does not expand if abbreviation.minimum is 5'); +$output = qx{../src/task rc:bug.rc rc.confirmation:off 2 modify shouldreplacetext 2>&1}; +ok ($? == 0, 'Should exit with 0 because task should exist'); +like ($output, qr/shouldreplacetext/, 'no gc was run'); # Cleanup. unlink qw(pending.data completed.data undo.data backlog.data synch.key bug.rc task.sh);