Change summary
cache/repo_cache_bug.go | 12 ++++--------
cache/repo_cache_test.go | 2 +-
commands/rm.go | 12 +++++++++++-
3 files changed, 16 insertions(+), 10 deletions(-)
Detailed changes
@@ -363,21 +363,17 @@ func (c *RepoCache) NewBugRaw(author *IdentityCache, unixTime int64, title strin
// RemoveBug removes a bug from the cache and repo
// args[0] specifies the bug prefix to remove
// args[1] (if present) specifies the remote the bug was imported from
-func (c *RepoCache) RemoveBug(args []string) error {
- if len(args) == 0 {
- return fmt.Errorf("you must provide a bug prefix to remove")
- }
-
- b, err := c.ResolveBugPrefix(args[0])
+func (c *RepoCache) RemoveBug(prefix string, remote string) error {
+ b, err := c.ResolveBugPrefix(prefix)
if err != nil {
return err
}
- if len(args) == 1 {
+ if remote == "" {
err = bug.RemoveLocalBug(c.repo, b.Id())
} else {
- err = bug.RemoveRemoteBug(c.repo, args[1], b.Id())
+ err = bug.RemoveRemoteBug(c.repo, remote, b.Id())
}
if err != nil {
return err
@@ -103,7 +103,7 @@ func TestCache(t *testing.T) {
require.NoError(t, err)
// Possible to delete a bug
- err = cache.RemoveBug([]string{bug1.Id().Human()})
+ err = cache.RemoveBug(bug1.Id().Human(), "")
require.NoError(t, err)
require.Equal(t, len(cache.AllBugsIds()), 1)
}
@@ -1,6 +1,8 @@
package commands
import (
+ "errors"
+
"github.com/spf13/cobra"
)
@@ -25,7 +27,15 @@ func newRmCommand() *cobra.Command {
}
func runRm(env *Env, args []string) (err error) {
- err = env.backend.RemoveBug(args)
+ switch len(args) {
+ case 1:
+ err = env.backend.RemoveBug(args[0], "")
+ break
+ case 2:
+ err = env.backend.RemoveBug(args[0], args[1])
+ default:
+ return errors.New("invalid number of arguments for rm command")
+ }
if err != nil {
return