Allow filtering by issue tags.
This commit is contained in:
parent
ef16eafd48
commit
f8fed9d937
@ -1,6 +1,6 @@
|
|||||||
# Package
|
# Package
|
||||||
|
|
||||||
version = "4.9.4"
|
version = "4.10.0"
|
||||||
author = "Jonathan Bernard"
|
author = "Jonathan Bernard"
|
||||||
description = "Personal issue tracker."
|
description = "Personal issue tracker."
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
@ -22,4 +22,4 @@ requires @[
|
|||||||
]
|
]
|
||||||
|
|
||||||
task updateVersion, "Update the version of this package.":
|
task updateVersion, "Update the version of this package.":
|
||||||
exec "update_nim_package_version pit 'src/pitpkg/version.nim'"
|
exec "update_nim_package_version pit 'src/pitpkg/version.nim'"
|
@ -466,6 +466,10 @@ Options:
|
|||||||
filter.properties["context"] = ctx.defaultContext.get
|
filter.properties["context"] = ctx.defaultContext.get
|
||||||
filterOption = some(filter)
|
filterOption = some(filter)
|
||||||
|
|
||||||
|
if args["--tags"]:
|
||||||
|
filter.hasTags = ($args["--tags"]).split(',')
|
||||||
|
filterOption = some(filter)
|
||||||
|
|
||||||
# Finally, if the "context" is "all", don't filter on context
|
# Finally, if the "context" is "all", don't filter on context
|
||||||
if filter.properties.hasKey("context") and
|
if filter.properties.hasKey("context") and
|
||||||
filter.properties["context"] == "all":
|
filter.properties["context"] == "all":
|
||||||
|
@ -22,6 +22,7 @@ type
|
|||||||
IssueFilter* = ref object
|
IssueFilter* = ref object
|
||||||
completedRange*: Option[tuple[b, e: DateTime]]
|
completedRange*: Option[tuple[b, e: DateTime]]
|
||||||
fullMatch*, summaryMatch*: Option[Regex]
|
fullMatch*, summaryMatch*: Option[Regex]
|
||||||
|
hasTags*: seq[string]
|
||||||
properties*: TableRef[string, string]
|
properties*: TableRef[string, string]
|
||||||
|
|
||||||
PitConfig* = ref object
|
PitConfig* = ref object
|
||||||
@ -69,6 +70,7 @@ proc initFilter*(): IssueFilter =
|
|||||||
completedRange: none(tuple[b, e: DateTime]),
|
completedRange: none(tuple[b, e: DateTime]),
|
||||||
fullMatch: none(Regex),
|
fullMatch: none(Regex),
|
||||||
summaryMatch: none(Regex),
|
summaryMatch: none(Regex),
|
||||||
|
hasTags: @[],
|
||||||
properties: newTable[string, string]())
|
properties: newTable[string, string]())
|
||||||
|
|
||||||
proc propsFilter*(props: TableRef[string, string]): IssueFilter =
|
proc propsFilter*(props: TableRef[string, string]): IssueFilter =
|
||||||
@ -91,6 +93,10 @@ proc fullMatchFilter*(pattern: string): IssueFilter =
|
|||||||
result = initFilter()
|
result = initFilter()
|
||||||
result.fullMatch = some(re("(?i)" & pattern))
|
result.fullMatch = some(re("(?i)" & pattern))
|
||||||
|
|
||||||
|
proc hasTagsFilter*(tags: seq[string]): IssueFilter =
|
||||||
|
result = initFilter()
|
||||||
|
result.hasTags = tags
|
||||||
|
|
||||||
proc groupBy*(issues: seq[Issue], propertyKey: string): TableRef[string, seq[Issue]] =
|
proc groupBy*(issues: seq[Issue], propertyKey: string): TableRef[string, seq[Issue]] =
|
||||||
result = newTable[string, seq[Issue]]()
|
result = newTable[string, seq[Issue]]()
|
||||||
for i in issues:
|
for i in issues:
|
||||||
@ -259,6 +265,9 @@ proc filter*(issues: seq[Issue], filter: IssueFilter): seq[Issue] =
|
|||||||
let p = filter.fullMatch.get
|
let p = filter.fullMatch.get
|
||||||
result = result.filterIt( it.summary.find(p).isSome or it.details.find(p).isSome)
|
result = result.filterIt( it.summary.find(p).isSome or it.details.find(p).isSome)
|
||||||
|
|
||||||
|
for tag in filter.hasTags:
|
||||||
|
result = result.filterIt(it.tags.find(tag) >= 0)
|
||||||
|
|
||||||
### Configuration utilities
|
### Configuration utilities
|
||||||
proc loadConfig*(args: Table[string, Value] = initTable[string, Value]()): PitConfig =
|
proc loadConfig*(args: Table[string, Value] = initTable[string, Value]()): PitConfig =
|
||||||
let pitrcLocations = @[
|
let pitrcLocations = @[
|
||||||
|
@ -1 +1 @@
|
|||||||
const PIT_VERSION* = "4.9.4"
|
const PIT_VERSION* = "4.10.0"
|
Loading…
x
Reference in New Issue
Block a user