mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
TW-1441
- TW-1441 task import continues happily if filename doesn't exist.
This commit is contained in:
parent
18581a6ca4
commit
5275c0ce60
10 changed files with 44 additions and 3 deletions
|
@ -168,6 +168,7 @@
|
|||
Testing).
|
||||
- TW-1428 Add support for color.uda.<name>.<value> rules.
|
||||
- TW-1436 Parser hangs when multiple slashes are used.
|
||||
- TW-1441 task import continues happily if filename doesn't exist.
|
||||
- Removed deprecated 'echo.command' setting, in favor of the 'header' and
|
||||
'affected' verbosity tokens.
|
||||
- Removed deprecated 'edit.verbose' setting, in favor of the 'edit' verbosity
|
||||
|
|
|
@ -61,12 +61,15 @@ int CmdImport::execute (std::string& output)
|
|||
std::vector <std::string>::iterator word;
|
||||
for (word = words.begin (); word != words.end (); ++word)
|
||||
{
|
||||
std::string file = *word;
|
||||
std::cout << format (STRING_CMD_IMPORT_FILE, file) << "\n";
|
||||
File incoming (*word);
|
||||
if (! incoming.exists ())
|
||||
throw format (STRING_CMD_IMPORT_MISSING, *word);
|
||||
|
||||
std::cout << format (STRING_CMD_IMPORT_FILE, *word) << "\n";
|
||||
|
||||
// Load the file.
|
||||
std::vector <std::string> lines;
|
||||
File::read (file, lines);
|
||||
incoming.read (lines);
|
||||
|
||||
std::vector <std::string>::iterator line;
|
||||
for (line = lines.begin (); line != lines.end (); ++line)
|
||||
|
|
|
@ -460,6 +460,7 @@
|
|||
#define STRING_CMD_IMPORT_SUMMARY "Imported {1} tasks."
|
||||
#define STRING_CMD_IMPORT_NOFILE "You must specify a file to import."
|
||||
#define STRING_CMD_IMPORT_FILE "Importing '{1}'"
|
||||
#define STRING_CMD_IMPORT_MISSING "File '{1}' not found."
|
||||
#define STRING_TASK_NO_DESC "Annotation is missing a description: {1}"
|
||||
#define STRING_TASK_NO_ENTRY "Annotation is missing an entry date: {1}"
|
||||
#define STRING_CMD_SYNC_USAGE "Synchronizes data with the Taskserver"
|
||||
|
|
|
@ -460,6 +460,7 @@
|
|||
#define STRING_CMD_IMPORT_SUMMARY "Importis {1} taskojn."
|
||||
#define STRING_CMD_IMPORT_NOFILE "Vi devas specifi kiu dosieron import."
|
||||
#define STRING_CMD_IMPORT_FILE "Importanta '{1}'"
|
||||
#define STRING_CMD_IMPORT_MISSING "File '{1}' not found."
|
||||
#define STRING_TASK_NO_DESC "Komento havas mankon de priskribo: {1}"
|
||||
#define STRING_TASK_NO_ENTRY "Komento havas mankon de enskrib-dato: {1}"
|
||||
#define STRING_CMD_SYNC_USAGE "Sinkronigas datumojn kun la Taskserver"
|
||||
|
|
|
@ -468,6 +468,7 @@
|
|||
#define STRING_CMD_IMPORT_SUMMARY "Importadas {1} tareas."
|
||||
#define STRING_CMD_IMPORT_NOFILE "Debe especificar un archivo a importar."
|
||||
#define STRING_CMD_IMPORT_FILE "Importando '{1}'"
|
||||
#define STRING_CMD_IMPORT_MISSING "File '{1}' not found."
|
||||
#define STRING_TASK_NO_DESC "La anotación carece de descripción: {1}"
|
||||
#define STRING_TASK_NO_ENTRY "La anotación carece de fecha de entrada: {1}"
|
||||
|
||||
|
|
|
@ -459,6 +459,7 @@
|
|||
#define STRING_CMD_IMPORT_SUMMARY "Imported {1} tasks."
|
||||
#define STRING_CMD_IMPORT_NOFILE "You must specify a file to import."
|
||||
#define STRING_CMD_IMPORT_FILE "Importing '{1}'"
|
||||
#define STRING_CMD_IMPORT_MISSING "File '{1}' not found."
|
||||
#define STRING_TASK_NO_DESC "Annotation is missing a description: {1}"
|
||||
#define STRING_TASK_NO_ENTRY "Annotation is missing an entry date: {1}"
|
||||
#define STRING_CMD_SYNC_USAGE "Synchronizes data with the Taskserver"
|
||||
|
|
|
@ -460,6 +460,7 @@
|
|||
#define STRING_CMD_IMPORT_SUMMARY "Importati {1} task."
|
||||
#define STRING_CMD_IMPORT_NOFILE "Specificare il file da importare."
|
||||
#define STRING_CMD_IMPORT_FILE "Importazione di '{1}'"
|
||||
#define STRING_CMD_IMPORT_MISSING "File '{1}' not found."
|
||||
#define STRING_TASK_NO_DESC "Annotazione senza descrizione: {1}"
|
||||
#define STRING_TASK_NO_ENTRY "Annotazione senza data di immissione: {1}"
|
||||
#define STRING_CMD_SYNC_USAGE "Sincronizza i dati con il Taskserver"
|
||||
|
|
|
@ -460,6 +460,7 @@
|
|||
#define STRING_CMD_IMPORT_SUMMARY "Zaimportowano {1} zadań."
|
||||
#define STRING_CMD_IMPORT_NOFILE "Musisz podać plik do zaimportowania."
|
||||
#define STRING_CMD_IMPORT_FILE "Importowanie '{1}'"
|
||||
#define STRING_CMD_IMPORT_MISSING "File '{1}' not found."
|
||||
#define STRING_TASK_NO_DESC "Komentarz nie posiada treści: {1}"
|
||||
#define STRING_TASK_NO_ENTRY "Komentarz nie posiada daty utworzenia: {1}"
|
||||
#define STRING_CMD_SYNC_USAGE "Synchronizuje dane z serwerem zadań"
|
||||
|
|
|
@ -460,6 +460,7 @@
|
|||
#define STRING_CMD_IMPORT_SUMMARY "Importadas {1} tarefas."
|
||||
#define STRING_CMD_IMPORT_NOFILE "Necessita especificar o ficheiro a importar."
|
||||
#define STRING_CMD_IMPORT_FILE "A importar '{1}'"
|
||||
#define STRING_CMD_IMPORT_MISSING "File '{1}' not found."
|
||||
#define STRING_TASK_NO_DESC "Descrição da anotação em falta: {1}"
|
||||
#define STRING_TASK_NO_ENTRY "Data de entrada da anotação em falta: {1}"
|
||||
#define STRING_CMD_SYNC_USAGE "Sincroniza dados com o Taskserver"
|
||||
|
|
30
test/tw-1441.t
Executable file
30
test/tw-1441.t
Executable file
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env python2.7
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import os
|
||||
import unittest
|
||||
# Ensure python finds the local simpletap module
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
from basetest import Task, TestCase
|
||||
|
||||
|
||||
class TestBug1441(TestCase):
|
||||
def setUp(self):
|
||||
self.t = Task()
|
||||
|
||||
def test_import_filename(self):
|
||||
"""import fails if file doesn't exist"""
|
||||
command = ("import", "somefile", "otherfile")
|
||||
code, out, err = self.t.runError(command)
|
||||
|
||||
self.assertIn("File 'somefile' not found.", err)
|
||||
self.assertIn("File 'otherfile' not found.", err)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from simpletap import TAPTestRunner
|
||||
unittest.main(testRunner=TAPTestRunner())
|
||||
|
||||
# vim: ai sts=4 et sw=4
|
Loading…
Add table
Add a link
Reference in a new issue