aboutsummaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
Diffstat (limited to 'commands')
-rw-r--r--commands/add.go2
-rw-r--r--commands/comment.go2
-rw-r--r--commands/ls-id.go6
-rw-r--r--commands/ls.go2
-rw-r--r--commands/pull.go6
-rw-r--r--commands/select.go2
-rw-r--r--commands/select/select.go9
-rw-r--r--commands/select/select_test.go6
-rw-r--r--commands/show.go6
-rw-r--r--commands/user.go2
-rw-r--r--commands/user_ls.go2
11 files changed, 23 insertions, 22 deletions
diff --git a/commands/add.go b/commands/add.go
index d199b4c7..ff4f9529 100644
--- a/commands/add.go
+++ b/commands/add.go
@@ -49,7 +49,7 @@ func runAddBug(cmd *cobra.Command, args []string) error {
return err
}
- fmt.Printf("%s created\n", b.HumanId())
+ fmt.Printf("%s created\n", b.Id().Human())
return nil
}
diff --git a/commands/comment.go b/commands/comment.go
index cb9f3691..33bae65d 100644
--- a/commands/comment.go
+++ b/commands/comment.go
@@ -39,7 +39,7 @@ func commentsTextOutput(comments []bug.Comment) {
}
fmt.Printf("Author: %s\n", colors.Magenta(comment.Author.DisplayName()))
- fmt.Printf("Id: %s\n", colors.Cyan(comment.HumanId()))
+ fmt.Printf("Id: %s\n", colors.Cyan(comment.Id().Human()))
fmt.Printf("Date: %s\n\n", comment.FormatTime())
fmt.Println(text.LeftPad(comment.Message, 4))
}
diff --git a/commands/ls-id.go b/commands/ls-id.go
index 47f29792..22357eb4 100644
--- a/commands/ls-id.go
+++ b/commands/ls-id.go
@@ -2,11 +2,11 @@ package commands
import (
"fmt"
- "strings"
+
+ "github.com/spf13/cobra"
"github.com/MichaelMure/git-bug/cache"
"github.com/MichaelMure/git-bug/util/interrupt"
- "github.com/spf13/cobra"
)
func runLsID(cmd *cobra.Command, args []string) error {
@@ -24,7 +24,7 @@ func runLsID(cmd *cobra.Command, args []string) error {
}
for _, id := range backend.AllBugsIds() {
- if prefix == "" || strings.HasPrefix(id, prefix) {
+ if prefix == "" || id.HasPrefix(prefix) {
fmt.Println(id)
}
}
diff --git a/commands/ls.go b/commands/ls.go
index 94f0d0d6..9c32642e 100644
--- a/commands/ls.go
+++ b/commands/ls.go
@@ -70,7 +70,7 @@ func runLsBug(cmd *cobra.Command, args []string) error {
authorFmt := text.LeftPadMaxLine(name, 15, 0)
fmt.Printf("%s %s\t%s\t%s\tC:%d L:%d\n",
- colors.Cyan(b.HumanId()),
+ colors.Cyan(b.Id.Human()),
colors.Yellow(b.Status),
titleFmt,
colors.Magenta(authorFmt),
diff --git a/commands/pull.go b/commands/pull.go
index 5df10dca..0439ab41 100644
--- a/commands/pull.go
+++ b/commands/pull.go
@@ -4,11 +4,11 @@ import (
"errors"
"fmt"
- "github.com/MichaelMure/git-bug/bug"
+ "github.com/spf13/cobra"
+
"github.com/MichaelMure/git-bug/cache"
"github.com/MichaelMure/git-bug/entity"
"github.com/MichaelMure/git-bug/util/interrupt"
- "github.com/spf13/cobra"
)
func runPull(cmd *cobra.Command, args []string) error {
@@ -45,7 +45,7 @@ func runPull(cmd *cobra.Command, args []string) error {
}
if result.Status != entity.MergeStatusNothing {
- fmt.Printf("%s: %s\n", bug.FormatHumanID(result.Id), result)
+ fmt.Printf("%s: %s\n", result.Id.Human(), result)
}
}
diff --git a/commands/select.go b/commands/select.go
index efe48b5e..7c40df5c 100644
--- a/commands/select.go
+++ b/commands/select.go
@@ -34,7 +34,7 @@ func runSelect(cmd *cobra.Command, args []string) error {
return err
}
- fmt.Printf("selected bug %s: %s\n", b.HumanId(), b.Snapshot().Title)
+ fmt.Printf("selected bug %s: %s\n", b.Id().Human(), b.Snapshot().Title)
return nil
}
diff --git a/commands/select/select.go b/commands/select/select.go
index 4ec3cb0e..fdc87154 100644
--- a/commands/select/select.go
+++ b/commands/select/select.go
@@ -11,6 +11,7 @@ import (
"github.com/MichaelMure/git-bug/bug"
"github.com/MichaelMure/git-bug/cache"
+ "github.com/MichaelMure/git-bug/entity"
"github.com/MichaelMure/git-bug/repository"
)
@@ -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")
}
- id := string(buf)
- if !bug.IDIsValid(id) {
+ 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")
diff --git a/commands/select/select_test.go b/commands/select/select_test.go
index 393ec88b..989d6b3c 100644
--- a/commands/select/select_test.go
+++ b/commands/select/select_test.go
@@ -52,12 +52,12 @@ func TestSelect(t *testing.T) {
require.Equal(t, b1.Id(), b3.Id())
// override selection with same id
- b4, _, err := ResolveBug(repoCache, []string{b1.Id()})
+ b4, _, err := ResolveBug(repoCache, []string{b1.Id().String()})
require.NoError(t, err)
require.Equal(t, b1.Id(), b4.Id())
// override selection with a prefix
- b5, _, err := ResolveBug(repoCache, []string{b1.HumanId()})
+ b5, _, err := ResolveBug(repoCache, []string{b1.Id().Human()})
require.NoError(t, err)
require.Equal(t, b1.Id(), b5.Id())
@@ -67,7 +67,7 @@ func TestSelect(t *testing.T) {
require.Equal(t, b1.Id(), b6.Id())
// override with a different id
- b7, _, err := ResolveBug(repoCache, []string{b2.Id()})
+ b7, _, err := ResolveBug(repoCache, []string{b2.Id().String()})
require.NoError(t, err)
require.Equal(t, b2.Id(), b7.Id())
diff --git a/commands/show.go b/commands/show.go
index 41dc5851..0bb3dc4a 100644
--- a/commands/show.go
+++ b/commands/show.go
@@ -46,7 +46,7 @@ func runShowBug(cmd *cobra.Command, args []string) error {
case "createTime":
fmt.Printf("%s\n", firstComment.FormatTime())
case "humanId":
- fmt.Printf("%s\n", snapshot.HumanId())
+ fmt.Printf("%s\n", snapshot.Id().Human())
case "id":
fmt.Printf("%s\n", snapshot.Id())
case "labels":
@@ -62,7 +62,7 @@ func runShowBug(cmd *cobra.Command, args []string) error {
fmt.Printf("%s\n", p.DisplayName())
}
case "shortId":
- fmt.Printf("%s\n", snapshot.HumanId())
+ fmt.Printf("%s\n", snapshot.Id().Human())
case "status":
fmt.Printf("%s\n", snapshot.Status)
case "title":
@@ -77,7 +77,7 @@ func runShowBug(cmd *cobra.Command, args []string) error {
// Header
fmt.Printf("[%s] %s %s\n\n",
colors.Yellow(snapshot.Status),
- colors.Cyan(snapshot.HumanId()),
+ colors.Cyan(snapshot.Id().Human()),
snapshot.Title,
)
diff --git a/commands/user.go b/commands/user.go
index 8cb64491..254abf2f 100644
--- a/commands/user.go
+++ b/commands/user.go
@@ -41,7 +41,7 @@ func runUser(cmd *cobra.Command, args []string) error {
case "email":
fmt.Printf("%s\n", id.Email())
case "humanId":
- fmt.Printf("%s\n", id.HumanId())
+ fmt.Printf("%s\n", id.Id().Human())
case "id":
fmt.Printf("%s\n", id.Id())
case "lastModification":
diff --git a/commands/user_ls.go b/commands/user_ls.go
index 23ecea73..609ff5a4 100644
--- a/commands/user_ls.go
+++ b/commands/user_ls.go
@@ -24,7 +24,7 @@ func runUserLs(cmd *cobra.Command, args []string) error {
}
fmt.Printf("%s %s\n",
- colors.Cyan(i.HumanId()),
+ colors.Cyan(i.Id.Human()),
i.DisplayName(),
)
}