aboutsummaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2022-12-23 01:48:14 +0100
committerGitHub <noreply@github.com>2022-12-23 01:48:14 +0100
commit0a5a0ec1ef4ad98bc2116a953e201f96474941ab (patch)
tree660a9b17b5247fe2f954bfa814cce3193c5afa23 /commands
parent108518530e822e3bdf59c8bfc333ad0bbe2d5fc8 (diff)
parent95911100823b5c809225d664de74ad2d64e91972 (diff)
downloadgit-bug-0a5a0ec1ef4ad98bc2116a953e201f96474941ab.tar.gz
Merge pull request #938 from MichaelMure/cache-reorg
Generic cache layer
Diffstat (limited to 'commands')
-rw-r--r--commands/bridge/bridge_auth_addtoken.go2
-rw-r--r--commands/bug/bug.go38
-rw-r--r--commands/bug/bug_comment_edit.go2
-rw-r--r--commands/bug/bug_new.go2
-rw-r--r--commands/bug/bug_rm.go2
-rw-r--r--commands/bug/bug_select.go2
-rw-r--r--commands/bug/select/select.go11
-rw-r--r--commands/bug/select/select_test.go10
-rw-r--r--commands/bug/testenv/testenv.go6
-rw-r--r--commands/cmdjson/json_common.go4
-rw-r--r--commands/completion/helper_completion.go24
-rw-r--r--commands/execenv/env.go19
-rw-r--r--commands/execenv/env_testing.go6
-rw-r--r--commands/label.go2
-rw-r--r--commands/root.go2
-rw-r--r--commands/user/user.go6
-rw-r--r--commands/user/user_adopt.go2
-rw-r--r--commands/user/user_new.go2
-rw-r--r--commands/user/user_show.go2
-rw-r--r--commands/webui.go18
20 files changed, 98 insertions, 64 deletions
diff --git a/commands/bridge/bridge_auth_addtoken.go b/commands/bridge/bridge_auth_addtoken.go
index bcab7fc3..2992fa63 100644
--- a/commands/bridge/bridge_auth_addtoken.go
+++ b/commands/bridge/bridge_auth_addtoken.go
@@ -94,7 +94,7 @@ func runBridgeAuthAddToken(env *execenv.Env, opts bridgeAuthAddTokenOptions, arg
if opts.user == "" {
user, err = env.Backend.GetUserIdentity()
} else {
- user, err = env.Backend.ResolveIdentityPrefix(opts.user)
+ user, err = env.Backend.Identities().ResolvePrefix(opts.user)
}
if err != nil {
return err
diff --git a/commands/bug/bug.go b/commands/bug/bug.go
index 04bf8980..bab040d8 100644
--- a/commands/bug/bug.go
+++ b/commands/bug/bug.go
@@ -142,14 +142,14 @@ func runBug(env *execenv.Env, opts bugOptions, args []string) error {
return err
}
- allIds, err := env.Backend.QueryBugs(q)
+ allIds, err := env.Backend.Bugs().Query(q)
if err != nil {
return err
}
bugExcerpt := make([]*cache.BugExcerpt, len(allIds))
for i, id := range allIds {
- b, err := env.Backend.ResolveBugExcerpt(id)
+ b, err := env.Backend.Bugs().ResolveExcerpt(id)
if err != nil {
return err
}
@@ -208,8 +208,8 @@ func bugsJsonFormatter(env *execenv.Env, bugExcerpts []*cache.BugExcerpt) error
jsonBugs := make([]JSONBugExcerpt, len(bugExcerpts))
for i, b := range bugExcerpts {
jsonBug := JSONBugExcerpt{
- Id: b.Id.String(),
- HumanId: b.Id.Human(),
+ Id: b.Id().String(),
+ HumanId: b.Id().Human(),
CreateTime: cmdjson.NewTime(b.CreateTime(), b.CreateLamportTime),
EditTime: cmdjson.NewTime(b.EditTime(), b.EditLamportTime),
Status: b.Status.String(),
@@ -219,7 +219,7 @@ func bugsJsonFormatter(env *execenv.Env, bugExcerpts []*cache.BugExcerpt) error
Metadata: b.CreateMetadata,
}
- author, err := env.Backend.ResolveIdentityExcerpt(b.AuthorId)
+ author, err := env.Backend.Identities().ResolveExcerpt(b.AuthorId)
if err != nil {
return err
}
@@ -227,7 +227,7 @@ func bugsJsonFormatter(env *execenv.Env, bugExcerpts []*cache.BugExcerpt) error
jsonBug.Actors = make([]cmdjson.Identity, len(b.Actors))
for i, element := range b.Actors {
- actor, err := env.Backend.ResolveIdentityExcerpt(element)
+ actor, err := env.Backend.Identities().ResolveExcerpt(element)
if err != nil {
return err
}
@@ -236,7 +236,7 @@ func bugsJsonFormatter(env *execenv.Env, bugExcerpts []*cache.BugExcerpt) error
jsonBug.Participants = make([]cmdjson.Identity, len(b.Participants))
for i, element := range b.Participants {
- participant, err := env.Backend.ResolveIdentityExcerpt(element)
+ participant, err := env.Backend.Identities().ResolveExcerpt(element)
if err != nil {
return err
}
@@ -252,7 +252,7 @@ func bugsJsonFormatter(env *execenv.Env, bugExcerpts []*cache.BugExcerpt) error
func bugsCompactFormatter(env *execenv.Env, bugExcerpts []*cache.BugExcerpt) error {
for _, b := range bugExcerpts {
- author, err := env.Backend.ResolveIdentityExcerpt(b.AuthorId)
+ author, err := env.Backend.Identities().ResolveExcerpt(b.AuthorId)
if err != nil {
return err
}
@@ -266,7 +266,7 @@ func bugsCompactFormatter(env *execenv.Env, bugExcerpts []*cache.BugExcerpt) err
}
env.Out.Printf("%s %s %s %s %s\n",
- colors.Cyan(b.Id.Human()),
+ colors.Cyan(b.Id().Human()),
colors.Yellow(b.Status),
text.LeftPadMaxLine(strings.TrimSpace(b.Title), 40, 0),
text.LeftPadMaxLine(labelsTxt.String(), 5, 0),
@@ -278,7 +278,7 @@ func bugsCompactFormatter(env *execenv.Env, bugExcerpts []*cache.BugExcerpt) err
func bugsIDFormatter(env *execenv.Env, bugExcerpts []*cache.BugExcerpt) error {
for _, b := range bugExcerpts {
- env.Out.Println(b.Id.String())
+ env.Out.Println(b.Id().String())
}
return nil
@@ -286,7 +286,7 @@ func bugsIDFormatter(env *execenv.Env, bugExcerpts []*cache.BugExcerpt) error {
func bugsDefaultFormatter(env *execenv.Env, bugExcerpts []*cache.BugExcerpt) error {
for _, b := range bugExcerpts {
- author, err := env.Backend.ResolveIdentityExcerpt(b.AuthorId)
+ author, err := env.Backend.Identities().ResolveExcerpt(b.AuthorId)
if err != nil {
return err
}
@@ -313,7 +313,7 @@ func bugsDefaultFormatter(env *execenv.Env, bugExcerpts []*cache.BugExcerpt) err
}
env.Out.Printf("%s\t%s\t%s\t%s\t%s\n",
- colors.Cyan(b.Id.Human()),
+ colors.Cyan(b.Id().Human()),
colors.Yellow(b.Status),
titleFmt+labelsFmt,
colors.Magenta(authorFmt),
@@ -325,7 +325,7 @@ func bugsDefaultFormatter(env *execenv.Env, bugExcerpts []*cache.BugExcerpt) err
func bugsPlainFormatter(env *execenv.Env, bugExcerpts []*cache.BugExcerpt) error {
for _, b := range bugExcerpts {
- env.Out.Printf("%s [%s] %s\n", b.Id.Human(), b.Status, strings.TrimSpace(b.Title))
+ env.Out.Printf("%s [%s] %s\n", b.Id().Human(), b.Status, strings.TrimSpace(b.Title))
}
return nil
}
@@ -353,7 +353,7 @@ func bugsOrgmodeFormatter(env *execenv.Env, bugExcerpts []*cache.BugExcerpt) err
title = b.Title
}
- author, err := env.Backend.ResolveIdentityExcerpt(b.AuthorId)
+ author, err := env.Backend.Identities().ResolveExcerpt(b.AuthorId)
if err != nil {
return err
}
@@ -370,7 +370,7 @@ func bugsOrgmodeFormatter(env *execenv.Env, bugExcerpts []*cache.BugExcerpt) err
env.Out.Printf("* %-6s %s %s %s: %s %s\n",
status,
- b.Id.Human(),
+ b.Id().Human(),
formatTime(b.CreateTime()),
author.DisplayName(),
title,
@@ -381,26 +381,26 @@ func bugsOrgmodeFormatter(env *execenv.Env, bugExcerpts []*cache.BugExcerpt) err
env.Out.Printf("** Actors:\n")
for _, element := range b.Actors {
- actor, err := env.Backend.ResolveIdentityExcerpt(element)
+ actor, err := env.Backend.Identities().ResolveExcerpt(element)
if err != nil {
return err
}
env.Out.Printf(": %s %s\n",
- actor.Id.Human(),
+ actor.Id().Human(),
actor.DisplayName(),
)
}
env.Out.Printf("** Participants:\n")
for _, element := range b.Participants {
- participant, err := env.Backend.ResolveIdentityExcerpt(element)
+ participant, err := env.Backend.Identities().ResolveExcerpt(element)
if err != nil {
return err
}
env.Out.Printf(": %s %s\n",
- participant.Id.Human(),
+ participant.Id().Human(),
participant.DisplayName(),
)
}
diff --git a/commands/bug/bug_comment_edit.go b/commands/bug/bug_comment_edit.go
index 8be7cb80..2a0289f5 100644
--- a/commands/bug/bug_comment_edit.go
+++ b/commands/bug/bug_comment_edit.go
@@ -41,7 +41,7 @@ func newBugCommentEditCommand() *cobra.Command {
}
func runBugCommentEdit(env *execenv.Env, opts bugCommentEditOptions, args []string) error {
- b, commentId, err := env.Backend.ResolveComment(args[0])
+ b, commentId, err := env.Backend.Bugs().ResolveComment(args[0])
if err != nil {
return err
}
diff --git a/commands/bug/bug_new.go b/commands/bug/bug_new.go
index 4f73a09c..fbfb9def 100644
--- a/commands/bug/bug_new.go
+++ b/commands/bug/bug_new.go
@@ -63,7 +63,7 @@ func runBugNew(env *execenv.Env, opts bugNewOptions) error {
}
}
- b, _, err := env.Backend.NewBug(
+ b, _, err := env.Backend.Bugs().New(
text.CleanupOneLine(opts.title),
text.Cleanup(opts.message),
)
diff --git a/commands/bug/bug_rm.go b/commands/bug/bug_rm.go
index 1d2a7524..04881d54 100644
--- a/commands/bug/bug_rm.go
+++ b/commands/bug/bug_rm.go
@@ -34,7 +34,7 @@ func runBugRm(env *execenv.Env, args []string) (err error) {
return errors.New("you must provide a bug prefix to remove")
}
- err = env.Backend.RemoveBug(args[0])
+ err = env.Backend.Bugs().Remove(args[0])
if err != nil {
return
diff --git a/commands/bug/bug_select.go b/commands/bug/bug_select.go
index 0b1cb15c..2a4d1201 100644
--- a/commands/bug/bug_select.go
+++ b/commands/bug/bug_select.go
@@ -46,7 +46,7 @@ func runBugSelect(env *execenv.Env, args []string) error {
prefix := args[0]
- b, err := env.Backend.ResolveBugPrefix(prefix)
+ b, err := env.Backend.Bugs().ResolvePrefix(prefix)
if err != nil {
return err
}
diff --git a/commands/bug/select/select.go b/commands/bug/select/select.go
index 908ad58c..7096dde4 100644
--- a/commands/bug/select/select.go
+++ b/commands/bug/select/select.go
@@ -9,7 +9,6 @@ import (
"github.com/pkg/errors"
"github.com/MichaelMure/git-bug/cache"
- "github.com/MichaelMure/git-bug/entities/bug"
"github.com/MichaelMure/git-bug/entity"
)
@@ -18,7 +17,7 @@ const selectFile = "select"
var ErrNoValidId = errors.New("you must provide a bug id or use the \"select\" command first")
// ResolveBug first try to resolve a bug using the first argument of the command
-// line. If it fails, it fallback to the select mechanism.
+// line. If it fails, it falls back to the select mechanism.
//
// Returns:
// - the bug if any
@@ -28,13 +27,13 @@ var ErrNoValidId = errors.New("you must provide a bug id or use the \"select\" c
func ResolveBug(repo *cache.RepoCache, args []string) (*cache.BugCache, []string, error) {
// At first, try to use the first argument as a bug prefix
if len(args) > 0 {
- b, err := repo.ResolveBugPrefix(args[0])
+ b, err := repo.Bugs().ResolvePrefix(args[0])
if err == nil {
return b, args[1:], nil
}
- if err != bug.ErrBugNotExist {
+ if !entity.IsErrNotFound(err) {
return nil, nil, err
}
}
@@ -44,7 +43,7 @@ func ResolveBug(repo *cache.RepoCache, args []string) (*cache.BugCache, []string
b, err := selected(repo)
// selected bug is invalid
- if err == bug.ErrBugNotExist {
+ if entity.IsErrNotFound(err) {
// we clear the selected bug
err = Clear(repo)
if err != nil {
@@ -115,7 +114,7 @@ func selected(repo *cache.RepoCache) (*cache.BugCache, error) {
return nil, fmt.Errorf("select file in invalid, removing it")
}
- b, err := repo.ResolveBug(id)
+ b, err := repo.Bugs().Resolve(id)
if err != nil {
return nil, err
}
diff --git a/commands/bug/select/select_test.go b/commands/bug/select/select_test.go
index 702700f4..83ca6643 100644
--- a/commands/bug/select/select_test.go
+++ b/commands/bug/select/select_test.go
@@ -13,7 +13,7 @@ import (
func TestSelect(t *testing.T) {
repo := repository.CreateGoGitTestRepo(t, false)
- repoCache, err := cache.NewRepoCache(repo)
+ repoCache, err := cache.NewRepoCacheNoEvents(repo)
require.NoError(t, err)
_, _, err = ResolveBug(repoCache, []string{})
@@ -28,18 +28,18 @@ func TestSelect(t *testing.T) {
// generate a bunch of bugs
- rene, err := repoCache.NewIdentity("René Descartes", "rene@descartes.fr")
+ rene, err := repoCache.Identities().New("René Descartes", "rene@descartes.fr")
require.NoError(t, err)
for i := 0; i < 10; i++ {
- _, _, err := repoCache.NewBugRaw(rene, time.Now().Unix(), "title", "message", nil, nil)
+ _, _, err := repoCache.Bugs().NewRaw(rene, time.Now().Unix(), "title", "message", nil, nil)
require.NoError(t, err)
}
// and two more for testing
- b1, _, err := repoCache.NewBugRaw(rene, time.Now().Unix(), "title", "message", nil, nil)
+ b1, _, err := repoCache.Bugs().NewRaw(rene, time.Now().Unix(), "title", "message", nil, nil)
require.NoError(t, err)
- b2, _, err := repoCache.NewBugRaw(rene, time.Now().Unix(), "title", "message", nil, nil)
+ b2, _, err := repoCache.Bugs().NewRaw(rene, time.Now().Unix(), "title", "message", nil, nil)
require.NoError(t, err)
err = Select(repoCache, b1.Id())
diff --git a/commands/bug/testenv/testenv.go b/commands/bug/testenv/testenv.go
index 10f20950..acd1f389 100644
--- a/commands/bug/testenv/testenv.go
+++ b/commands/bug/testenv/testenv.go
@@ -19,7 +19,7 @@ func NewTestEnvAndUser(t *testing.T) (*execenv.Env, entity.Id) {
testEnv := execenv.NewTestEnv(t)
- i, err := testEnv.Backend.NewIdentity(testUserName, testUserEmail)
+ i, err := testEnv.Backend.Identities().New(testUserName, testUserEmail)
require.NoError(t, err)
err = testEnv.Backend.SetUserIdentity(i)
@@ -38,7 +38,7 @@ func NewTestEnvAndBug(t *testing.T) (*execenv.Env, entity.Id) {
testEnv, _ := NewTestEnvAndUser(t)
- b, _, err := testEnv.Backend.NewBug(testBugTitle, testBugMessage)
+ b, _, err := testEnv.Backend.Bugs().New(testBugTitle, testBugMessage)
require.NoError(t, err)
return testEnv, b.Id()
@@ -53,7 +53,7 @@ func NewTestEnvAndBugWithComment(t *testing.T) (*execenv.Env, entity.Id, entity.
env, bugID := NewTestEnvAndBug(t)
- b, err := env.Backend.ResolveBug(bugID)
+ b, err := env.Backend.Bugs().Resolve(bugID)
require.NoError(t, err)
commentId, _, err := b.AddComment(testCommentMessage)
diff --git a/commands/cmdjson/json_common.go b/commands/cmdjson/json_common.go
index 60e6e751..34077915 100644
--- a/commands/cmdjson/json_common.go
+++ b/commands/cmdjson/json_common.go
@@ -26,8 +26,8 @@ func NewIdentity(i identity.Interface) Identity {
func NewIdentityFromExcerpt(excerpt *cache.IdentityExcerpt) Identity {
return Identity{
- Id: excerpt.Id.String(),
- HumanId: excerpt.Id.Human(),
+ Id: excerpt.Id().String(),
+ HumanId: excerpt.Id().Human(),
Name: excerpt.Name,
Login: excerpt.Login,
}
diff --git a/commands/completion/helper_completion.go b/commands/completion/helper_completion.go
index 27fbd615..691f0895 100644
--- a/commands/completion/helper_completion.go
+++ b/commands/completion/helper_completion.go
@@ -88,11 +88,11 @@ func Bug(env *execenv.Env) ValidArgsFunction {
}
func bugWithBackend(backend *cache.RepoCache, toComplete string) (completions []string, directives cobra.ShellCompDirective) {
- allIds := backend.AllBugsIds()
+ allIds := backend.Bugs().AllIds()
bugExcerpt := make([]*cache.BugExcerpt, len(allIds))
for i, id := range allIds {
var err error
- bugExcerpt[i], err = backend.ResolveBugExcerpt(id)
+ bugExcerpt[i], err = backend.Bugs().ResolveExcerpt(id)
if err != nil {
return handleError(err)
}
@@ -138,7 +138,7 @@ func BugAndLabels(env *execenv.Env, addOrRemove bool) ValidArgsFunction {
seenLabels[label] = true
}
- allLabels := env.Backend.ValidLabels()
+ allLabels := env.Backend.Bugs().ValidLabels()
labels = make([]bug.Label, 0, len(allLabels))
for _, label := range allLabels {
if !seenLabels[label] {
@@ -200,7 +200,7 @@ func Label(env *execenv.Env) ValidArgsFunction {
_ = env.Backend.Close()
}()
- labels := env.Backend.ValidLabels()
+ labels := env.Backend.Bugs().ValidLabels()
completions = make([]string, len(labels))
for i, label := range labels {
if strings.Contains(label.String(), " ") {
@@ -243,10 +243,10 @@ func Ls(env *execenv.Env) ValidArgsFunction {
if !strings.HasPrefix(toComplete, key) {
continue
}
- ids := env.Backend.AllIdentityIds()
+ ids := env.Backend.Identities().AllIds()
completions = make([]string, len(ids))
for i, id := range ids {
- user, err := env.Backend.ResolveIdentityExcerpt(id)
+ user, err := env.Backend.Identities().ResolveExcerpt(id)
if err != nil {
return handleError(err)
}
@@ -266,7 +266,7 @@ func Ls(env *execenv.Env) ValidArgsFunction {
if !strings.HasPrefix(toComplete, key) {
continue
}
- labels := env.Backend.ValidLabels()
+ labels := env.Backend.Bugs().ValidLabels()
completions = make([]string, len(labels))
for i, label := range labels {
if strings.Contains(label.String(), " ") {
@@ -300,14 +300,14 @@ func User(env *execenv.Env) ValidArgsFunction {
_ = env.Backend.Close()
}()
- ids := env.Backend.AllIdentityIds()
+ ids := env.Backend.Identities().AllIds()
completions = make([]string, len(ids))
for i, id := range ids {
- user, err := env.Backend.ResolveIdentityExcerpt(id)
+ user, err := env.Backend.Identities().ResolveExcerpt(id)
if err != nil {
return handleError(err)
}
- completions[i] = user.Id.Human() + "\t" + user.DisplayName()
+ completions[i] = user.Id().Human() + "\t" + user.DisplayName()
}
return completions, cobra.ShellCompDirectiveNoFileComp
}
@@ -322,10 +322,10 @@ func UserForQuery(env *execenv.Env) ValidArgsFunction {
_ = env.Backend.Close()
}()
- ids := env.Backend.AllIdentityIds()
+ ids := env.Backend.Identities().AllIds()
completions = make([]string, len(ids))
for i, id := range ids {
- user, err := env.Backend.ResolveIdentityExcerpt(id)
+ user, err := env.Backend.Identities().ResolveExcerpt(id)
if err != nil {
return handleError(err)
}
diff --git a/commands/execenv/env.go b/commands/execenv/env.go
index a63f835a..4c6ce204 100644
--- a/commands/execenv/env.go
+++ b/commands/execenv/env.go
@@ -128,11 +128,28 @@ func LoadBackend(env *Env) func(*cobra.Command, []string) error {
return err
}
- env.Backend, err = cache.NewRepoCache(env.Repo)
+ var events chan cache.BuildEvent
+ env.Backend, events, err = cache.NewRepoCache(env.Repo)
if err != nil {
return err
}
+ if events != nil {
+ env.Err.Println("Building cache... ")
+ for event := range events {
+ if event.Err != nil {
+ env.Err.Printf("Cache building error [%s]: %v\n", event.Typename, event.Err)
+ continue
+ }
+ switch event.Event {
+ case cache.BuildEventStarted:
+ env.Err.Printf("[%s] started\n", event.Typename)
+ case cache.BuildEventFinished:
+ env.Err.Printf("[%s] done\n", event.Typename)
+ }
+ }
+ }
+
cleaner := func(env *Env) interrupt.CleanerFunc {
return func() error {
if env.Backend != nil {
diff --git a/commands/execenv/env_testing.go b/commands/execenv/env_testing.go
index 7d9fbd60..5761b410 100644
--- a/commands/execenv/env_testing.go
+++ b/commands/execenv/env_testing.go
@@ -5,9 +5,10 @@ import (
"fmt"
"testing"
+ "github.com/stretchr/testify/require"
+
"github.com/MichaelMure/git-bug/cache"
"github.com/MichaelMure/git-bug/repository"
- "github.com/stretchr/testify/require"
)
type TestOut struct {
@@ -33,8 +34,9 @@ func NewTestEnv(t *testing.T) *Env {
buf := new(bytes.Buffer)
- backend, err := cache.NewRepoCache(repo)
+ backend, err := cache.NewRepoCacheNoEvents(repo)
require.NoError(t, err)
+
t.Cleanup(func() {
backend.Close()
})
diff --git a/commands/label.go b/commands/label.go
index 70090d26..08b9e31f 100644
--- a/commands/label.go
+++ b/commands/label.go
@@ -25,7 +25,7 @@ Note: in the future, a proper label policy could be implemented where valid labe
}
func runLabel(env *execenv.Env) error {
- labels := env.Backend.ValidLabels()
+ labels := env.Backend.Bugs().ValidLabels()
for _, l := range labels {
env.Out.Println(l)
diff --git a/commands/root.go b/commands/root.go
index b28b77b8..d98f9448 100644
--- a/commands/root.go
+++ b/commands/root.go
@@ -61,7 +61,7 @@ the same git remote you are already using to collaborate with other people.
const remoteGroup = "remote"
cmd.AddGroup(&cobra.Group{ID: entityGroup, Title: "Entities"})
- cmd.AddGroup(&cobra.Group{ID: uiGroup, Title: "User interfaces"})
+ cmd.AddGroup(&cobra.Group{ID: uiGroup, Title: "Interactive interfaces"})
cmd.AddGroup(&cobra.Group{ID: remoteGroup, Title: "Interaction with the outside world"})
addCmdWithGroup := func(child *cobra.Command, groupID string) {
diff --git a/commands/user/user.go b/commands/user/user.go
index 191fb828..9a1e477c 100644
--- a/commands/user/user.go
+++ b/commands/user/user.go
@@ -46,10 +46,10 @@ func NewUserCommand() *cobra.Command {
}
func runUser(env *execenv.Env, opts userOptions) error {
- ids := env.Backend.AllIdentityIds()
+ ids := env.Backend.Identities().AllIds()
var users []*cache.IdentityExcerpt
for _, id := range ids {
- user, err := env.Backend.ResolveIdentityExcerpt(id)
+ user, err := env.Backend.Identities().ResolveExcerpt(id)
if err != nil {
return err
}
@@ -69,7 +69,7 @@ func runUser(env *execenv.Env, opts userOptions) error {
func userDefaultFormatter(env *execenv.Env, users []*cache.IdentityExcerpt) error {
for _, user := range users {
env.Out.Printf("%s %s\n",
- colors.Cyan(user.Id.Human()),
+ colors.Cyan(user.Id().Human()),
user.DisplayName(),
)
}
diff --git a/commands/user/user_adopt.go b/commands/user/user_adopt.go
index f5944053..30fdb442 100644
--- a/commands/user/user_adopt.go
+++ b/commands/user/user_adopt.go
@@ -27,7 +27,7 @@ func newUserAdoptCommand() *cobra.Command {
func runUserAdopt(env *execenv.Env, args []string) error {
prefix := args[0]
- i, err := env.Backend.ResolveIdentityPrefix(prefix)
+ i, err := env.Backend.Identities().ResolvePrefix(prefix)
if err != nil {
return err
}
diff --git a/commands/user/user_new.go b/commands/user/user_new.go
index d7224512..7b287492 100644
--- a/commands/user/user_new.go
+++ b/commands/user/user_new.go
@@ -69,7 +69,7 @@ func runUserNew(env *execenv.Env, opts userNewOptions) error {
}
}
- id, err := env.Backend.NewIdentityRaw(opts.name, opts.email, "", opts.avatarURL, nil, nil)
+ id, err := env.Backend.Identities().NewRaw(opts.name, opts.email, "", opts.avatarURL, nil, nil)
if err != nil {
return err
}
diff --git a/commands/user/user_show.go b/commands/user/user_show.go
index 36c09e8e..225d0ef4 100644
--- a/commands/user/user_show.go
+++ b/commands/user/user_show.go
@@ -49,7 +49,7 @@ func runUserShow(env *execenv.Env, opts userShowOptions, args []string) error {
var id *cache.IdentityCache
var err error
if len(args) == 1 {
- id, err = env.Backend.ResolveIdentityPrefix(args[0])
+ id, err = env.Backend.Identities().ResolvePrefix(args[0])
} else {
id, err = env.Backend.GetUserIdentity()
}
diff --git a/commands/webui.go b/commands/webui.go
index 5fe66aa7..6cbaff78 100644
--- a/commands/webui.go
+++ b/commands/webui.go
@@ -105,11 +105,27 @@ func runWebUI(env *execenv.Env, opts webUIOptions) error {
}
mrc := cache.NewMultiRepoCache()
- _, err := mrc.RegisterDefaultRepository(env.Repo)
+ _, events, err := mrc.RegisterDefaultRepository(env.Repo)
if err != nil {
return err
}
+ if events != nil {
+ env.Err.Println("Building cache... ")
+ for event := range events {
+ if event.Err != nil {
+ env.Err.Printf("Cache building error [%s]: %v\n", event.Typename, event.Err)
+ continue
+ }
+ switch event.Event {
+ case cache.BuildEventStarted:
+ env.Err.Printf("[%s] started\n", event.Typename)
+ case cache.BuildEventFinished:
+ env.Err.Printf("[%s] done\n", event.Typename)
+ }
+ }
+ }
+
var errOut io.Writer
if opts.logErrors {
errOut = env.Err