Update state field when changing an issue's state.

This commit is contained in:
Jonathan Bernard 2023-03-21 10:17:43 -05:00
parent 171adbb59d
commit fee4ba70a6
3 changed files with 9 additions and 2 deletions

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

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

@ -41,6 +41,7 @@ type
isFromCompletion*: bool isFromCompletion*: bool
const DONE_FOLDER_FORMAT* = "yyyy-MM" const DONE_FOLDER_FORMAT* = "yyyy-MM"
const ISO8601_MS = "yyyy-MM-dd'T'HH:mm:ss'.'fffzzz"
let ISSUE_FILE_PATTERN = re"[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}\.txt" let ISSUE_FILE_PATTERN = re"[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}\.txt"
let RECURRENCE_PATTERN = re"(every|after) ((\d+) )?((hour|day|week|month|year)s?)(, ([0-9a-fA-F]+))?" let RECURRENCE_PATTERN = re"(every|after) ((\d+) )?((hour|day|week|month|year)s?)(, ([0-9a-fA-F]+))?"
@ -219,12 +220,17 @@ proc fromStorageFormat*(id: string, issueTxt: string): Issue =
proc toStorageFormat*(issue: Issue, withComments = false): string = proc toStorageFormat*(issue: Issue, withComments = false): string =
var lines: seq[string] = @[] var lines: seq[string] = @[]
if withComments: lines.add("# Summary (one line):") if withComments: lines.add("# Summary (one line):")
lines.add(issue.summary) lines.add(issue.summary)
if withComments: lines.add("# Properties (\"key:value\" per line):") if withComments: lines.add("# Properties (\"key:value\" per line):")
issue.properties["last-updated"] = now().format(ISO8601_MS)
for key, val in issue.properties: for key, val in issue.properties:
if not val.isEmptyOrWhitespace: lines.add(key & ": " & val) if not val.isEmptyOrWhitespace: lines.add(key & ": " & val)
if issue.tags.len > 0: lines.add("tags: " & issue.tags.join(",")) if issue.tags.len > 0: lines.add("tags: " & issue.tags.join(","))
if not isEmptyOrWhitespace(issue.details) or withComments: if not isEmptyOrWhitespace(issue.details) or withComments:
if withComments: lines.add("# Details go below the \"--------\"") if withComments: lines.add("# Details go below the \"--------\"")
lines.add("--------") lines.add("--------")
@ -326,6 +332,7 @@ proc changeState*(issue: Issue, tasksDir: string, newState: IssueState) =
if newState == Done: issue.setDateTime("completed", getTime().local) if newState == Done: issue.setDateTime("completed", getTime().local)
tasksDir.store(issue, newState) tasksDir.store(issue, newState)
if oldFilePath != issue.filepath: removeFile(oldFilepath) if oldFilePath != issue.filepath: removeFile(oldFilepath)
issue.state = newState
proc delete*(issue: Issue) = removeFile(issue.filepath) proc delete*(issue: Issue) = removeFile(issue.filepath)