From d44e5926358180a949718cde75e50675a7b43e1c Mon Sep 17 00:00:00 2001 From: Johannes Schlatow Date: Thu, 23 Dec 2010 22:15:11 +0100 Subject: [PATCH] Bug #580 - reuse merge uri for autopush --- src/command.cpp | 10 +--- src/tests/bug.580.t | 108 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+), 8 deletions(-) create mode 100755 src/tests/bug.580.t diff --git a/src/command.cpp b/src/command.cpp index 830f254e8..5e03cd235 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -590,13 +590,6 @@ void handleMerge (std::string& outs) Uri uri (file, "merge"); uri.parse(); - if (sAutopush == "ask") - { - // expand uri - Uri push (file, "push"); - pushfile = push.data; - } - if (uri.data.length ()) { Directory location (context.config.get ("data.location")); @@ -627,10 +620,11 @@ void handleMerge (std::string& outs) if (tmpfile != "") remove (tmpfile.c_str ()); - if ( ((sAutopush == "ask") && (confirm ("Would you like to push the merged changes to \'" + pushfile + "\'?")) ) + if ( ((sAutopush == "ask") && (confirm ("Would you like to push the merged changes to \'" + uri.data + "\'?")) ) || (bAutopush) ) { std::string out; + context.task.set ("description", uri.data); handlePush (out); } } diff --git a/src/tests/bug.580.t b/src/tests/bug.580.t new file mode 100755 index 000000000..c5db8d279 --- /dev/null +++ b/src/tests/bug.580.t @@ -0,0 +1,108 @@ +#! /usr/bin/perl +################################################################################ +## taskwarrior - a command line task list manager. +## +## Copyright 2006 - 2010, Paul Beckingham, Federico Hernandez. +## All rights reserved. +## +## This program is free software; you can redistribute it and/or modify it under +## the terms of the GNU General Public License as published by the Free Software +## Foundation; either version 2 of the License, or (at your option) any later +## version. +## +## This program is distributed in the hope that it will be useful, but WITHOUT +## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +## details. +## +## You should have received a copy of the GNU General Public License along with +## this program; if not, write to the +## +## Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, +## Boston, MA +## 02110-1301 +## USA +## +################################################################################ + +use strict; +use warnings; +use Test::More tests => 16; +use File::Copy; + +use constant false => 0; +use constant true => 1; + +# Create data locations +mkdir("local", 0755); +ok(-e 'local', "Created directory local"); +mkdir("remote", 0755); +ok(-e 'remote', "Created directory remote"); + +# Create the rc files. +if (open my $fh, '>', 'local.rc') +{ + print $fh "data.location=./local\n", + "confirmation=no\n", + "merge.default.uri=remote/\n", + "merge.autopush=yes\n"; + close $fh; + ok (-r 'local.rc', 'Created local.rc'); +} + +if (open my $fh, '>', 'remote.rc') +{ + print $fh "data.location=./remote\n", + "confirmation=no\n", + "merge.autopush=no\n"; + close $fh; + ok (-r 'remote.rc', 'Created remote.rc'); +} + +# add a remote task +qx{../task rc:remote.rc add remote task}; + +# add a local task +qx(../task rc:local.rc add local task); + +# merge and autopush +qx{../task rc:local.rc merge}; + +my $output = qx{../task rc:remote.rc ls}; +like ($output, qr/local task/, "autopush failed"); + +# Cleanup. +unlink 'local/pending.data'; +ok (!-r 'local/pending.data', 'Removed local/pending.data'); + +unlink 'local/completed.data'; +ok (!-r 'local/completed.data', 'Removed local/completed.data'); + +unlink 'local/undo.data'; +ok (!-r 'local/undo.data', 'Removed local/undo.data'); + +unlink 'local/undo.save'; +ok (!-r 'local/undo.save', 'Removed local/undo.save'); + +unlink 'local.rc'; +ok (!-r 'local.rc', 'Removed local.rc'); + +unlink 'remote/pending.data'; +ok (!-r 'remote/pending.data', 'Removed remote/pending.data'); + +unlink 'remote/completed.data'; +ok (!-r 'remote/completed.data', 'Removed remote/completed.data'); + +unlink 'remote/undo.data'; +ok (!-r 'remote/undo.data', 'Removed remote/undo.data'); + +unlink 'remote.rc'; +ok (!-r 'remote.rc', 'Removed remote.rc'); + +rmdir("remote"); +ok (!-e "remote", "Removed dir remote"); +rmdir("local"); +ok (!-e "local", "Removed dir local"); + +exit 0;