aboutsummaryrefslogtreecommitdiffstats
path: root/bug
diff options
context:
space:
mode:
authorVincent Tiu <46623413+Invincibot@users.noreply.github.com>2020-07-09 20:40:44 +0800
committerGitHub <noreply@github.com>2020-07-09 14:40:44 +0200
commitf3304bdc1c215e733b9a2ee6a228e64f663c2b09 (patch)
tree44e21d3922b270dfe92a49361567775e684a292a /bug
parentde062a78ece6a33cc44d8bd3372d814b288ce916 (diff)
downloadgit-bug-f3304bdc1c215e733b9a2ee6a228e64f663c2b09.tar.gz
Add functionality to remove bugs from a local repository. (#423)
Add functionality to remove bugs from a local repository. This adds a function to remove git references in the repo and another one to remove bugs.
Diffstat (limited to 'bug')
-rw-r--r--bug/bug.go5
-rw-r--r--bug/bug_test.go15
2 files changed, 18 insertions, 2 deletions
diff --git a/bug/bug.go b/bug/bug.go
index 24f0dcd5..04bd5996 100644
--- a/bug/bug.go
+++ b/bug/bug.go
@@ -242,6 +242,11 @@ func readBug(repo repository.ClockedRepo, ref string) (*Bug, error) {
return &bug, nil
}
+func RemoveLocalBug(repo repository.ClockedRepo, id entity.Id) error {
+ ref := bugsRefPattern + id.String()
+ return repo.RemoveRef(ref)
+}
+
type StreamedBug struct {
Bug *Bug
Err error
diff --git a/bug/bug_test.go b/bug/bug_test.go
index 480d312e..43e760af 100644
--- a/bug/bug_test.go
+++ b/bug/bug_test.go
@@ -4,9 +4,10 @@ import (
"testing"
"time"
+ "github.com/stretchr/testify/assert"
+
"github.com/MichaelMure/git-bug/identity"
"github.com/MichaelMure/git-bug/repository"
- "github.com/stretchr/testify/assert"
)
func TestBugId(t *testing.T) {
@@ -63,7 +64,7 @@ func TestBugValidity(t *testing.T) {
}
}
-func TestBugCommitLoad(t *testing.T) {
+func TestBugCommitLoadRemove(t *testing.T) {
bug1 := NewBug()
rene := identity.NewIdentity("René Descartes", "rene@descartes.fr")
@@ -99,6 +100,16 @@ func TestBugCommitLoad(t *testing.T) {
bug3, err := ReadLocalBug(repo, bug1.Id())
assert.NoError(t, err)
equivalentBug(t, bug1, bug3)
+
+ err = RemoveLocalBug(repo, bug1.Id())
+ assert.NoError(t, err)
+
+ streamedBugs := ReadAllLocalBugs(repo)
+ count := 0
+ for range streamedBugs {
+ count++
+ }
+ assert.Equal(t, 0, count)
}
func equivalentBug(t *testing.T, expected, actual *Bug) {