aboutsummaryrefslogtreecommitdiffstats
path: root/commands/select/select.go
diff options
context:
space:
mode:
Diffstat (limited to 'commands/select/select.go')
-rw-r--r--commands/select/select.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/commands/select/select.go b/commands/select/select.go
index b080d277..fdc87154 100644
--- a/commands/select/select.go
+++ b/commands/select/select.go
@@ -7,11 +7,12 @@ import (
"os"
"path"
+ "github.com/pkg/errors"
+
"github.com/MichaelMure/git-bug/bug"
"github.com/MichaelMure/git-bug/cache"
+ "github.com/MichaelMure/git-bug/entity"
"github.com/MichaelMure/git-bug/repository"
- "github.com/MichaelMure/git-bug/util/git"
- "github.com/pkg/errors"
)
const selectFile = "select"
@@ -69,7 +70,7 @@ func ResolveBug(repo *cache.RepoCache, args []string) (*cache.BugCache, []string
}
// Select will select a bug for future use
-func Select(repo *cache.RepoCache, id string) error {
+func Select(repo *cache.RepoCache, id entity.Id) error {
selectPath := selectFilePath(repo)
f, err := os.OpenFile(selectPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
@@ -77,7 +78,7 @@ func Select(repo *cache.RepoCache, id string) error {
return err
}
- _, err = f.WriteString(id)
+ _, err = f.WriteString(id.String())
if err != nil {
return err
}
@@ -112,8 +113,8 @@ func selected(repo *cache.RepoCache) (*cache.BugCache, error) {
return nil, fmt.Errorf("the select file should be < 100 bytes")
}
- h := git.Hash(buf)
- if !h.IsValid() {
+ id := entity.Id(buf)
+ if err := id.Validate(); err != nil {
err = os.Remove(selectPath)
if err != nil {
return nil, errors.Wrap(err, "error while removing invalid select file")
@@ -122,7 +123,7 @@ func selected(repo *cache.RepoCache) (*cache.BugCache, error) {
return nil, fmt.Errorf("select file in invalid, removing it")
}
- b, err := repo.ResolveBug(string(h))
+ b, err := repo.ResolveBug(id)
if err != nil {
return nil, err
}