diff options
author | Michael Muré <batolettre@gmail.com> | 2024-08-25 20:40:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-25 18:40:23 +0000 |
commit | 3a4b8805dfd794cc25f57e99c73ddec651805af1 (patch) | |
tree | b6af67c761c96b323400d061db22ceed73fb0bb0 /commands | |
parent | c3ff05f95bdfad6c2ea4cb899024fd47ac503b5f (diff) | |
download | git-bug-3a4b8805dfd794cc25f57e99c73ddec651805af1.tar.gz |
core: make label a common type, in a similar fashion as for status (#1252)
This will be useful for Board, and likely code review support later
Diffstat (limited to 'commands')
-rw-r--r-- | commands/bug/bug.go | 3 | ||||
-rw-r--r-- | commands/bug/completion.go | 12 | ||||
-rw-r--r-- | commands/cmdjson/bug.go | 35 |
3 files changed, 25 insertions, 25 deletions
diff --git a/commands/bug/bug.go b/commands/bug/bug.go index 4cf18ab9..4e696a49 100644 --- a/commands/bug/bug.go +++ b/commands/bug/bug.go @@ -13,7 +13,6 @@ import ( "github.com/git-bug/git-bug/commands/cmdjson" "github.com/git-bug/git-bug/commands/completion" "github.com/git-bug/git-bug/commands/execenv" - "github.com/git-bug/git-bug/entities/bug" "github.com/git-bug/git-bug/entities/common" "github.com/git-bug/git-bug/entity" "github.com/git-bug/git-bug/query" @@ -280,7 +279,7 @@ func bugsPlainFormatter(env *execenv.Env, excerpts []*cache.BugExcerpt) error { func bugsOrgmodeFormatter(env *execenv.Env, excerpts []*cache.BugExcerpt) error { // see https://orgmode.org/manual/Tags.html orgTagRe := regexp.MustCompile("[^[:alpha:]_@]") - formatTag := func(l bug.Label) string { + formatTag := func(l common.Label) string { return orgTagRe.ReplaceAllString(l.String(), "_") } diff --git a/commands/bug/completion.go b/commands/bug/completion.go index d313ef37..4329829e 100644 --- a/commands/bug/completion.go +++ b/commands/bug/completion.go @@ -9,7 +9,7 @@ import ( "github.com/git-bug/git-bug/commands/completion" "github.com/git-bug/git-bug/commands/execenv" _select "github.com/git-bug/git-bug/commands/select" - "github.com/git-bug/git-bug/entities/bug" + "github.com/git-bug/git-bug/entities/common" ) // BugCompletion complete a bug id @@ -61,26 +61,26 @@ func BugAndLabelsCompletion(env *execenv.Env, addOrRemove bool) completion.Valid snap := b.Snapshot() - seenLabels := map[bug.Label]bool{} + seenLabels := map[common.Label]bool{} for _, label := range cleanArgs { - seenLabels[bug.Label(label)] = addOrRemove + seenLabels[common.Label(label)] = addOrRemove } - var labels []bug.Label + var labels []common.Label if addOrRemove { for _, label := range snap.Labels { seenLabels[label] = true } allLabels := env.Backend.Bugs().ValidLabels() - labels = make([]bug.Label, 0, len(allLabels)) + labels = make([]common.Label, 0, len(allLabels)) for _, label := range allLabels { if !seenLabels[label] { labels = append(labels, label) } } } else { - labels = make([]bug.Label, 0, len(snap.Labels)) + labels = make([]common.Label, 0, len(snap.Labels)) for _, label := range snap.Labels { if seenLabels[label] { labels = append(labels, label) diff --git a/commands/cmdjson/bug.go b/commands/cmdjson/bug.go index a7f894ed..62eae92b 100644 --- a/commands/cmdjson/bug.go +++ b/commands/cmdjson/bug.go @@ -3,20 +3,21 @@ package cmdjson import ( "github.com/git-bug/git-bug/cache" "github.com/git-bug/git-bug/entities/bug" + "github.com/git-bug/git-bug/entities/common" ) type BugSnapshot struct { - Id string `json:"id"` - HumanId string `json:"human_id"` - CreateTime Time `json:"create_time"` - EditTime Time `json:"edit_time"` - Status string `json:"status"` - Labels []bug.Label `json:"labels"` - Title string `json:"title"` - Author Identity `json:"author"` - Actors []Identity `json:"actors"` - Participants []Identity `json:"participants"` - Comments []BugComment `json:"comments"` + Id string `json:"id"` + HumanId string `json:"human_id"` + CreateTime Time `json:"create_time"` + EditTime Time `json:"edit_time"` + Status string `json:"status"` + Labels []common.Label `json:"labels"` + Title string `json:"title"` + Author Identity `json:"author"` + Actors []Identity `json:"actors"` + Participants []Identity `json:"participants"` + Comments []BugComment `json:"comments"` } func NewBugSnapshot(snap *bug.Snapshot) BugSnapshot { @@ -71,12 +72,12 @@ type BugExcerpt struct { CreateTime Time `json:"create_time"` EditTime Time `json:"edit_time"` - Status string `json:"status"` - Labels []bug.Label `json:"labels"` - Title string `json:"title"` - Actors []Identity `json:"actors"` - Participants []Identity `json:"participants"` - Author Identity `json:"author"` + Status string `json:"status"` + Labels []common.Label `json:"labels"` + Title string `json:"title"` + Actors []Identity `json:"actors"` + Participants []Identity `json:"participants"` + Author Identity `json:"author"` Comments int `json:"comments"` Metadata map[string]string `json:"metadata"` |