aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/go.yml4
-rw-r--r--cache/repo_cache_bug.go6
-rw-r--r--commands/label.go3
-rw-r--r--commands/label_ls.go33
-rw-r--r--commands/ls-id.go7
-rw-r--r--commands/ls-labels.go18
-rw-r--r--commands/ls.go14
-rw-r--r--commands/ls_test.go1
-rw-r--r--doc/man/git-bug-label-ls.1 (renamed from doc/man/git-bug-ls-label.1)8
-rw-r--r--doc/man/git-bug-label.12
-rw-r--r--doc/man/git-bug-ls-id.127
-rw-r--r--doc/man/git-bug-ls.12
-rw-r--r--doc/man/git-bug.12
-rw-r--r--doc/md/git-bug.md2
-rw-r--r--doc/md/git-bug_label.md1
-rw-r--r--doc/md/git-bug_label_ls.md (renamed from doc/md/git-bug_ls-label.md)8
-rw-r--r--doc/md/git-bug_ls-id.md18
-rw-r--r--doc/md/git-bug_ls.md2
18 files changed, 83 insertions, 75 deletions
diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml
index 8d41852c..776165d5 100644
--- a/.github/workflows/go.yml
+++ b/.github/workflows/go.yml
@@ -54,5 +54,5 @@ jobs:
- name: Check Code Formatting
run: find . -name "*.go" | while read line; do [ -z "$(gofmt -d "$line" | head)" ] || exit 1; done
- - name: Check Security (vulnerable dependencies and insecure practices)
- run: make secure
+ - name: Check Security (insecure practices)
+ run: make secure-practices
diff --git a/cache/repo_cache_bug.go b/cache/repo_cache_bug.go
index dc2b271c..2992421c 100644
--- a/cache/repo_cache_bug.go
+++ b/cache/repo_cache_bug.go
@@ -501,7 +501,13 @@ func (c *RepoCache) RemoveBug(prefix string) error {
}
c.muBug.Lock()
+
err = bug.Remove(c.repo, b.Id())
+ if err != nil {
+ c.muBug.Unlock()
+
+ return err
+ }
delete(c.bugs, b.Id())
delete(c.bugExcerpts, b.Id())
diff --git a/commands/label.go b/commands/label.go
index 906974a5..ff4d0151 100644
--- a/commands/label.go
+++ b/commands/label.go
@@ -20,13 +20,14 @@ func newLabelCommand() *cobra.Command {
}
cmd.AddCommand(newLabelAddCommand())
+ cmd.AddCommand(newLabelLsCommand())
cmd.AddCommand(newLabelRmCommand())
return cmd
}
func runLabel(env *Env, args []string) error {
- b, args, err := _select.ResolveBug(env.backend, args)
+ b, _, err := _select.ResolveBug(env.backend, args)
if err != nil {
return err
}
diff --git a/commands/label_ls.go b/commands/label_ls.go
new file mode 100644
index 00000000..242eb00c
--- /dev/null
+++ b/commands/label_ls.go
@@ -0,0 +1,33 @@
+package commands
+
+import (
+ "github.com/spf13/cobra"
+)
+
+func newLabelLsCommand() *cobra.Command {
+ env := newEnv()
+
+ cmd := &cobra.Command{
+ Use: "ls",
+ Short: "List valid labels.",
+ Long: `List valid labels.
+
+Note: in the future, a proper label policy could be implemented where valid labels are defined in a configuration file. Until that, the default behavior is to return the list of labels already used.`,
+ PreRunE: loadBackend(env),
+ RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
+ return runLabelLs(env)
+ }),
+ }
+
+ return cmd
+}
+
+func runLabelLs(env *Env) error {
+ labels := env.backend.ValidLabels()
+
+ for _, l := range labels {
+ env.out.Println(l)
+ }
+
+ return nil
+}
diff --git a/commands/ls-id.go b/commands/ls-id.go
index 41f017e8..31107e87 100644
--- a/commands/ls-id.go
+++ b/commands/ls-id.go
@@ -14,6 +14,13 @@ func newLsIdCommand() *cobra.Command {
RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
return runLsId(env, args)
}),
+ Deprecated: `and will be removed in v1.0.
+
+Please use the "ls" command which allows filtering and sorting of the resulting
+list of ids. The following example would print a new-line separated list containing
+the ids of all open bugs:
+git-bug ls --format id --status open
+`,
}
return cmd
diff --git a/commands/ls-labels.go b/commands/ls-labels.go
index 086943a9..00fc3fe6 100644
--- a/commands/ls-labels.go
+++ b/commands/ls-labels.go
@@ -15,19 +15,15 @@ func newLsLabelCommand() *cobra.Command {
Note: in the future, a proper label policy could be implemented where valid labels are defined in a configuration file. Until that, the default behavior is to return the list of labels already used.`,
PreRunE: loadBackend(env),
RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
- return runLsLabel(env)
+ return runLabelLs(env)
}),
- }
-
- return cmd
-}
-
-func runLsLabel(env *Env) error {
- labels := env.backend.ValidLabels()
+ Deprecated: ` and will be removed in v1.0.
- for _, l := range labels {
- env.out.Println(l)
+The functionality provided by this command is now provided by
+the following (equivalent) command:
+git-bug label ls
+`,
}
- return nil
+ return cmd
}
diff --git a/commands/ls.go b/commands/ls.go
index 6ec06f39..7ed897fa 100644
--- a/commands/ls.go
+++ b/commands/ls.go
@@ -92,9 +92,9 @@ git bug ls status:open --by creation "foo bar" baz
"Select the sorting direction. Valid values are [asc,desc]")
cmd.RegisterFlagCompletionFunc("direction", completeFrom([]string{"asc", "desc"}))
flags.StringVarP(&options.outputFormat, "format", "f", "default",
- "Select the output formatting style. Valid values are [default,plain,compact,json,org-mode]")
+ "Select the output formatting style. Valid values are [default,plain,compact,id,json,org-mode]")
cmd.RegisterFlagCompletionFunc("format",
- completeFrom([]string{"default", "plain", "compact", "json", "org-mode"}))
+ completeFrom([]string{"default", "plain", "compact", "id", "json", "org-mode"}))
return cmd
}
@@ -143,6 +143,8 @@ func runLs(env *Env, opts lsOptions, args []string) error {
return lsJsonFormatter(env, bugExcerpt)
case "compact":
return lsCompactFormatter(env, bugExcerpt)
+ case "id":
+ return lsIDFormatter(env, bugExcerpt)
case "default":
return lsDefaultFormatter(env, bugExcerpt)
default:
@@ -252,6 +254,14 @@ func lsCompactFormatter(env *Env, bugExcerpts []*cache.BugExcerpt) error {
return nil
}
+func lsIDFormatter(env *Env, bugExcerpts []*cache.BugExcerpt) error {
+ for _, b := range bugExcerpts {
+ env.out.Println(b.Id.String())
+ }
+
+ return nil
+}
+
func lsDefaultFormatter(env *Env, bugExcerpts []*cache.BugExcerpt) error {
for _, b := range bugExcerpts {
author, err := env.backend.ResolveIdentityExcerpt(b.AuthorId)
diff --git a/commands/ls_test.go b/commands/ls_test.go
index 5759f9d0..22adc1ce 100644
--- a/commands/ls_test.go
+++ b/commands/ls_test.go
@@ -61,6 +61,7 @@ $`
{"default", "^[0-9a-f]{7}\topen\tthis is a bug title \tJohn Doe \t\n$"},
{"plain", "^[0-9a-f]{7} \\[open\\] this is a bug title\n$"},
{"compact", "^[0-9a-f]{7} open this is a bug title John Doe\n$"},
+ {"id", "^[0-9a-f]{64}\n$"},
{"org-mode", expOrgMode},
}
diff --git a/doc/man/git-bug-ls-label.1 b/doc/man/git-bug-label-ls.1
index 65857083..67ee7dd1 100644
--- a/doc/man/git-bug-ls-label.1
+++ b/doc/man/git-bug-label-ls.1
@@ -3,12 +3,12 @@
.SH NAME
.PP
-git-bug-ls-label - List valid labels.
+git-bug-label-ls - List valid labels.
.SH SYNOPSIS
.PP
-\fBgit-bug ls-label [flags]\fP
+\fBgit-bug label ls [flags]\fP
.SH DESCRIPTION
@@ -22,9 +22,9 @@ Note: in the future, a proper label policy could be implemented where valid labe
.SH OPTIONS
.PP
\fB-h\fP, \fB--help\fP[=false]
- help for ls-label
+ help for ls
.SH SEE ALSO
.PP
-\fBgit-bug(1)\fP
+\fBgit-bug-label(1)\fP
diff --git a/doc/man/git-bug-label.1 b/doc/man/git-bug-label.1
index 9dfc5c89..69a5c217 100644
--- a/doc/man/git-bug-label.1
+++ b/doc/man/git-bug-label.1
@@ -24,4 +24,4 @@ Display, add or remove labels to/from a bug.
.SH SEE ALSO
.PP
-\fBgit-bug(1)\fP, \fBgit-bug-label-add(1)\fP, \fBgit-bug-label-rm(1)\fP
+\fBgit-bug(1)\fP, \fBgit-bug-label-add(1)\fP, \fBgit-bug-label-ls(1)\fP, \fBgit-bug-label-rm(1)\fP
diff --git a/doc/man/git-bug-ls-id.1 b/doc/man/git-bug-ls-id.1
deleted file mode 100644
index eebdf421..00000000
--- a/doc/man/git-bug-ls-id.1
+++ /dev/null
@@ -1,27 +0,0 @@
-.nh
-.TH "GIT-BUG" "1" "Apr 2019" "Generated from git-bug's source code" ""
-
-.SH NAME
-.PP
-git-bug-ls-id - List bug identifiers.
-
-
-.SH SYNOPSIS
-.PP
-\fBgit-bug ls-id [PREFIX] [flags]\fP
-
-
-.SH DESCRIPTION
-.PP
-List bug identifiers.
-
-
-.SH OPTIONS
-.PP
-\fB-h\fP, \fB--help\fP[=false]
- help for ls-id
-
-
-.SH SEE ALSO
-.PP
-\fBgit-bug(1)\fP
diff --git a/doc/man/git-bug-ls.1 b/doc/man/git-bug-ls.1
index 873cf68c..e58177de 100644
--- a/doc/man/git-bug-ls.1
+++ b/doc/man/git-bug-ls.1
@@ -62,7 +62,7 @@ You can pass an additional query to filter and order the list. This query can be
.PP
\fB-f\fP, \fB--format\fP="default"
- Select the output formatting style. Valid values are [default,plain,compact,json,org-mode]
+ Select the output formatting style. Valid values are [default,plain,compact,id,json,org-mode]
.PP
\fB-h\fP, \fB--help\fP[=false]
diff --git a/doc/man/git-bug.1 b/doc/man/git-bug.1
index 47e433ae..b982c7f4 100644
--- a/doc/man/git-bug.1
+++ b/doc/man/git-bug.1
@@ -29,4 +29,4 @@ the same git remote you are already using to collaborate with other people.
.SH SEE ALSO
.PP
-\fBgit-bug-add(1)\fP, \fBgit-bug-bridge(1)\fP, \fBgit-bug-commands(1)\fP, \fBgit-bug-comment(1)\fP, \fBgit-bug-deselect(1)\fP, \fBgit-bug-label(1)\fP, \fBgit-bug-ls(1)\fP, \fBgit-bug-ls-id(1)\fP, \fBgit-bug-ls-label(1)\fP, \fBgit-bug-pull(1)\fP, \fBgit-bug-push(1)\fP, \fBgit-bug-rm(1)\fP, \fBgit-bug-select(1)\fP, \fBgit-bug-show(1)\fP, \fBgit-bug-status(1)\fP, \fBgit-bug-termui(1)\fP, \fBgit-bug-title(1)\fP, \fBgit-bug-user(1)\fP, \fBgit-bug-version(1)\fP, \fBgit-bug-webui(1)\fP
+\fBgit-bug-add(1)\fP, \fBgit-bug-bridge(1)\fP, \fBgit-bug-commands(1)\fP, \fBgit-bug-comment(1)\fP, \fBgit-bug-deselect(1)\fP, \fBgit-bug-label(1)\fP, \fBgit-bug-ls(1)\fP, \fBgit-bug-pull(1)\fP, \fBgit-bug-push(1)\fP, \fBgit-bug-rm(1)\fP, \fBgit-bug-select(1)\fP, \fBgit-bug-show(1)\fP, \fBgit-bug-status(1)\fP, \fBgit-bug-termui(1)\fP, \fBgit-bug-title(1)\fP, \fBgit-bug-user(1)\fP, \fBgit-bug-version(1)\fP, \fBgit-bug-webui(1)\fP
diff --git a/doc/md/git-bug.md b/doc/md/git-bug.md
index 99b554e2..c47f8484 100644
--- a/doc/md/git-bug.md
+++ b/doc/md/git-bug.md
@@ -31,8 +31,6 @@ git-bug [flags]
* [git-bug deselect](git-bug_deselect.md) - Clear the implicitly selected bug.
* [git-bug label](git-bug_label.md) - Display, add or remove labels to/from a bug.
* [git-bug ls](git-bug_ls.md) - List bugs.
-* [git-bug ls-id](git-bug_ls-id.md) - List bug identifiers.
-* [git-bug ls-label](git-bug_ls-label.md) - List valid labels.
* [git-bug pull](git-bug_pull.md) - Pull bugs update from a git remote.
* [git-bug push](git-bug_push.md) - Push bugs update to a git remote.
* [git-bug rm](git-bug_rm.md) - Remove an existing bug.
diff --git a/doc/md/git-bug_label.md b/doc/md/git-bug_label.md
index dd597b69..caeebe89 100644
--- a/doc/md/git-bug_label.md
+++ b/doc/md/git-bug_label.md
@@ -16,5 +16,6 @@ git-bug label [ID] [flags]
* [git-bug](git-bug.md) - A bug tracker embedded in Git.
* [git-bug label add](git-bug_label_add.md) - Add a label to a bug.
+* [git-bug label ls](git-bug_label_ls.md) - List valid labels.
* [git-bug label rm](git-bug_label_rm.md) - Remove a label from a bug.
diff --git a/doc/md/git-bug_ls-label.md b/doc/md/git-bug_label_ls.md
index 9ee6fa8c..cda6ebba 100644
--- a/doc/md/git-bug_ls-label.md
+++ b/doc/md/git-bug_label_ls.md
@@ -1,4 +1,4 @@
-## git-bug ls-label
+## git-bug label ls
List valid labels.
@@ -9,16 +9,16 @@ List valid labels.
Note: in the future, a proper label policy could be implemented where valid labels are defined in a configuration file. Until that, the default behavior is to return the list of labels already used.
```
-git-bug ls-label [flags]
+git-bug label ls [flags]
```
### Options
```
- -h, --help help for ls-label
+ -h, --help help for ls
```
### SEE ALSO
-* [git-bug](git-bug.md) - A bug tracker embedded in Git.
+* [git-bug label](git-bug_label.md) - Display, add or remove labels to/from a bug.
diff --git a/doc/md/git-bug_ls-id.md b/doc/md/git-bug_ls-id.md
deleted file mode 100644
index 493a1829..00000000
--- a/doc/md/git-bug_ls-id.md
+++ /dev/null
@@ -1,18 +0,0 @@
-## git-bug ls-id
-
-List bug identifiers.
-
-```
-git-bug ls-id [PREFIX] [flags]
-```
-
-### Options
-
-```
- -h, --help help for ls-id
-```
-
-### SEE ALSO
-
-* [git-bug](git-bug.md) - A bug tracker embedded in Git.
-
diff --git a/doc/md/git-bug_ls.md b/doc/md/git-bug_ls.md
index a40b3fd9..5aec0fbc 100644
--- a/doc/md/git-bug_ls.md
+++ b/doc/md/git-bug_ls.md
@@ -42,7 +42,7 @@ git bug ls status:open --by creation "foo bar" baz
-n, --no strings Filter by absence of something. Valid values are [label]
-b, --by string Sort the results by a characteristic. Valid values are [id,creation,edit] (default "creation")
-d, --direction string Select the sorting direction. Valid values are [asc,desc] (default "asc")
- -f, --format string Select the output formatting style. Valid values are [default,plain,compact,json,org-mode] (default "default")
+ -f, --format string Select the output formatting style. Valid values are [default,plain,compact,id,json,org-mode] (default "default")
-h, --help help for ls
```