GothenburgBitFactory / bugwarrior

Pull github, bitbucket, and trac issues into taskwarrior
http://pypi.python.org/pypi/bugwarrior
GNU General Public License v3.0
743 stars 208 forks source link

Map redmine start and due date to native scheduled and due fields. #1060

Open jahagirdar opened 2 months ago

jahagirdar commented 2 months ago

I am currently doing this via a hook, but it might be useful for bugwarrior to do this natively.

task['due'] = task['redmineduedate']
task['scheduled'] = task['redminestartdate']
ryneeverett commented 2 months ago

Per this comment, you should be able to implement this with without adding any feature to bugwarrior just using field templates.

jahagirdar commented 2 months ago

The problem with field templates is, The fields are not guaranteed to be in a redmine task, This results in

ERROR:bugwarrior.db:Unable to modify task: b"'None' is not a valid date in the 'Y-M-D' format."                                                                                                                              
 raceback (most recent call last):    

for the field template

 redmine.due_template= {{redmineduedate}}                                                                                                                                                                                     
 redmine.scheduled_template={{redminestartdate}}      
ryneeverett commented 2 months ago

Hmm, I'm surprised at that result because I thought that None values resulted in empty strings ("") and not "None".

jahagirdar commented 2 months ago

For reference, Sanitized full log for a failing task:

INFO:bugwarrior.db:Updating task 9a062c66-bba9-41ad-8b92-4cbef128befd, (bw)Is#98 - Update the XYZ functionality .. http://redmine.company.net/issues/98; due: None -> 'None'
ERROR:bugwarrior.db:Unable to modify task: b"'None' is not a valid date in the 'Y-M-D' format."
Traceback (most recent call last):
  File "/home/vijayvithal/.local/lib/python3.10/site-packages/bugwarrior/db.py", line 438, in synchronize
    _, updated_task = tw.task_update(issue)
  File "/home/vijayvithal/.local/lib/python3.10/site-packages/taskw/warrior.py", line 812, in task_update
    self._execute(task_uuid, 'modify', *modification)
  File "/home/vijayvithal/.local/lib/python3.10/site-packages/taskw/warrior.py", line 489, in _execute
    raise TaskwarriorError(command, stderr, stdout, proc.returncode)
taskw.exceptions.TaskwarriorError: [b'task', b'rc.verbose=new-uuid', b'rc.json.array=TRUE', b'rc.confirmation=no', b'rc.dependency.confirmation=no', b'rc.recurrence.confirmation=no', b'rc.uda.redmineurl.type=string', b'rc.uda.redmineurl.label="Redmine URL"', b'rc.uda.redminesubject.type=string', b'rc.uda.redminesubject.label="Redmine Subject"', b'rc.uda.redmineid.type=numeric', b'rc.uda.redmineid.label="Redmine ID"', b'rc.uda.redminedescription.type=string', b'rc.uda.redminedescription.label="Redmine Description"', b'rc.uda.redminetracker.type=string', b'rc.uda.redminetracker.label="Redmine Tracker"', b'rc.uda.redminestatus.type=string', b'rc.uda.redminestatus.label="Redmine Status"', b'rc.uda.redmineauthor.type=string', b'rc.uda.redmineauthor.label="Redmine Author"', b'rc.uda.redminecategory.type=string', b'rc.uda.redminecategory.label="Redmine Category"', b'rc.uda.redminestartdate.type=date', b'rc.uda.redminestartdate.label="Redmine Start Date"', b'rc.uda.redminespenthours.type=duration', b'rc.uda.redminespenthours.label="Redmine Spent Hours"', b'rc.uda.redmineestimatedhours.type=duration', b'rc.uda.redmineestimatedhours.label="Redmine Estimated Hours"', b'rc.uda.redminecreatedon.type=date', b'rc.uda.redminecreatedon.label="Redmine Created On"', b'rc.uda.redmineupdatedon.type=date', b'rc.uda.redmineupdatedon.label="Redmine Updated On"', b'rc.uda.redmineduedate.type=date', b'rc.uda.redmineduedate.label="Redmine Due Date"', b'rc.uda.redmineassignedto.type=string', b'rc.uda.redmineassignedto.label="Redmine Assigned To"', b'rc.uda.redmineprojectname.type=string', b'rc.uda.redmineprojectname.label="Redmine Project"', b'9a062c66-bba9-41ad-8b92-4cbef128befd', b'modify', b'due:"None"'] #2; stderr:"b"'None' is not a valid date in the 'Y-M-D' format.""; 

I removed my hooks folder to avoid any type conversion from that end. and It still generates this Error.