Add debug logging when changing the state of an issue.

This commit is contained in:
Jonathan Bernard 2024-08-12 10:52:51 -05:00
parent 9a0bf35882
commit 0c3d73dc2b
3 changed files with 7 additions and 2 deletions

View File

@ -1,6 +1,6 @@
# Package
version = "4.25.1"
version = "4.25.2"
author = "Jonathan Bernard"
description = "Personal issue tracker."
license = "MIT"

View File

@ -1,4 +1,4 @@
const PIT_VERSION* = "4.25.1"
const PIT_VERSION* = "4.25.2"
const USAGE* = """Usage:
pit ( new | add) <summary> [<state>] [options]

View File

@ -328,11 +328,16 @@ proc loadAllIssues*(tasksDir: string): TableRef[IssueState, seq[Issue]] =
for state in IssueState: result[state] = tasksDir.loadIssues(state)
proc changeState*(issue: Issue, tasksDir: string, newState: IssueState) =
var dbgInfo = "[$#] changing state: $#$#" %
[ ($issue.id)[0..<6], $issue.state, $newState ]
let oldFilepath = issue.filepath
if newState == Done: issue.setDateTime("completed", getTime().local)
tasksDir.store(issue, newState)
if oldFilePath != issue.filepath: removeFile(oldFilepath)
dbgInfo &= "\n\told path: $#\n\tnew path: $#" % [oldFilePath, issue.filepath]
issue.state = newState
debug dbgInfo
proc delete*(issue: Issue) = removeFile(issue.filepath)