aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bug/comment.go3
-rw-r--r--bug/op_add_comment.go3
-rw-r--r--bug/op_create.go3
-rw-r--r--bug/op_create_test.go3
-rw-r--r--bug/op_edit_comment.go3
-rw-r--r--bug/op_label_change.go5
-rw-r--r--bug/op_noop.go2
-rw-r--r--bug/op_set_metadata.go5
-rw-r--r--bug/op_set_status.go5
-rw-r--r--bug/op_set_title.go5
-rw-r--r--bug/timeline.go7
-rw-r--r--commands/user.go3
-rw-r--r--doc/man/git-bug-user-ls.14
-rw-r--r--doc/md/git-bug_user_ls.md3
-rw-r--r--identity/bare.go11
-rw-r--r--identity/identity.go30
-rw-r--r--identity/identity_stub.go9
-rw-r--r--identity/interface.go7
-rw-r--r--misc/bash_completion/git-bug3
-rw-r--r--misc/zsh_completion/git-bug18
-rw-r--r--util/timestamp/timestamp.go (renamed from bug/time.go)2
21 files changed, 91 insertions, 43 deletions
diff --git a/bug/comment.go b/bug/comment.go
index 84d34299..f7a6eada 100644
--- a/bug/comment.go
+++ b/bug/comment.go
@@ -3,6 +3,7 @@ package bug
import (
"github.com/MichaelMure/git-bug/identity"
"github.com/MichaelMure/git-bug/util/git"
+ "github.com/MichaelMure/git-bug/util/timestamp"
"github.com/dustin/go-humanize"
)
@@ -14,7 +15,7 @@ type Comment struct {
// Creation time of the comment.
// Should be used only for human display, never for ordering as we can't rely on it in a distributed system.
- UnixTime Timestamp
+ UnixTime timestamp.Timestamp
}
// FormatTimeRel format the UnixTime of the comment for human consumption
diff --git a/bug/op_add_comment.go b/bug/op_add_comment.go
index ba5d611e..9ecef941 100644
--- a/bug/op_add_comment.go
+++ b/bug/op_add_comment.go
@@ -7,6 +7,7 @@ import (
"github.com/MichaelMure/git-bug/identity"
"github.com/MichaelMure/git-bug/util/git"
"github.com/MichaelMure/git-bug/util/text"
+ "github.com/MichaelMure/git-bug/util/timestamp"
)
var _ Operation = &AddCommentOperation{}
@@ -32,7 +33,7 @@ func (op *AddCommentOperation) Apply(snapshot *Snapshot) {
Message: op.Message,
Author: op.Author,
Files: op.Files,
- UnixTime: Timestamp(op.UnixTime),
+ UnixTime: timestamp.Timestamp(op.UnixTime),
}
snapshot.Comments = append(snapshot.Comments, comment)
diff --git a/bug/op_create.go b/bug/op_create.go
index 1d157e67..42d40f71 100644
--- a/bug/op_create.go
+++ b/bug/op_create.go
@@ -8,6 +8,7 @@ import (
"github.com/MichaelMure/git-bug/identity"
"github.com/MichaelMure/git-bug/util/git"
"github.com/MichaelMure/git-bug/util/text"
+ "github.com/MichaelMure/git-bug/util/timestamp"
)
var _ Operation = &CreateOperation{}
@@ -34,7 +35,7 @@ func (op *CreateOperation) Apply(snapshot *Snapshot) {
comment := Comment{
Message: op.Message,
Author: op.Author,
- UnixTime: Timestamp(op.UnixTime),
+ UnixTime: timestamp.Timestamp(op.UnixTime),
}
snapshot.Comments = []Comment{comment}
diff --git a/bug/op_create_test.go b/bug/op_create_test.go
index c41c5687..92ac191d 100644
--- a/bug/op_create_test.go
+++ b/bug/op_create_test.go
@@ -6,6 +6,7 @@ import (
"time"
"github.com/MichaelMure/git-bug/identity"
+ "github.com/MichaelMure/git-bug/util/timestamp"
"github.com/stretchr/testify/assert"
)
@@ -22,7 +23,7 @@ func TestCreate(t *testing.T) {
hash, err := create.Hash()
assert.NoError(t, err)
- comment := Comment{Author: rene, Message: "message", UnixTime: Timestamp(create.UnixTime)}
+ comment := Comment{Author: rene, Message: "message", UnixTime: timestamp.Timestamp(create.UnixTime)}
expected := Snapshot{
Title: "title",
diff --git a/bug/op_edit_comment.go b/bug/op_edit_comment.go
index 3ff16653..527b7440 100644
--- a/bug/op_edit_comment.go
+++ b/bug/op_edit_comment.go
@@ -5,6 +5,7 @@ import (
"fmt"
"github.com/MichaelMure/git-bug/identity"
+ "github.com/MichaelMure/git-bug/util/timestamp"
"github.com/MichaelMure/git-bug/util/git"
"github.com/MichaelMure/git-bug/util/text"
@@ -58,7 +59,7 @@ func (op *EditCommentOperation) Apply(snapshot *Snapshot) {
comment := Comment{
Message: op.Message,
Files: op.Files,
- UnixTime: Timestamp(op.UnixTime),
+ UnixTime: timestamp.Timestamp(op.UnixTime),
}
switch target.(type) {
diff --git a/bug/op_label_change.go b/bug/op_label_change.go
index b0dd2c33..84542b6e 100644
--- a/bug/op_label_change.go
+++ b/bug/op_label_change.go
@@ -6,6 +6,7 @@ import (
"sort"
"github.com/MichaelMure/git-bug/identity"
+ "github.com/MichaelMure/git-bug/util/timestamp"
"github.com/MichaelMure/git-bug/util/git"
"github.com/pkg/errors"
@@ -68,7 +69,7 @@ AddLoop:
item := &LabelChangeTimelineItem{
hash: hash,
Author: op.Author,
- UnixTime: Timestamp(op.UnixTime),
+ UnixTime: timestamp.Timestamp(op.UnixTime),
Added: op.Added,
Removed: op.Removed,
}
@@ -162,7 +163,7 @@ func NewLabelChangeOperation(author identity.Interface, unixTime int64, added, r
type LabelChangeTimelineItem struct {
hash git.Hash
Author identity.Interface
- UnixTime Timestamp
+ UnixTime timestamp.Timestamp
Added []Label
Removed []Label
}
diff --git a/bug/op_noop.go b/bug/op_noop.go
index fbc112a8..3cd9f39a 100644
--- a/bug/op_noop.go
+++ b/bug/op_noop.go
@@ -11,7 +11,7 @@ var _ Operation = &NoOpOperation{}
// NoOpOperation is an operation that does not change the bug state. It can
// however be used to store arbitrary metadata in the bug history, for example
-// to support a bridge feature
+// to support a bridge feature.
type NoOpOperation struct {
OpBase
}
diff --git a/bug/op_set_metadata.go b/bug/op_set_metadata.go
index 57b78667..7616a591 100644
--- a/bug/op_set_metadata.go
+++ b/bug/op_set_metadata.go
@@ -2,6 +2,7 @@ package bug
import (
"encoding/json"
+ "fmt"
"github.com/MichaelMure/git-bug/identity"
"github.com/MichaelMure/git-bug/util/git"
@@ -55,6 +56,10 @@ func (op *SetMetadataOperation) Validate() error {
return err
}
+ if !op.Target.IsValid() {
+ return fmt.Errorf("target hash is invalid")
+ }
+
return nil
}
diff --git a/bug/op_set_status.go b/bug/op_set_status.go
index 6deb1675..0105d78d 100644
--- a/bug/op_set_status.go
+++ b/bug/op_set_status.go
@@ -5,6 +5,7 @@ import (
"github.com/MichaelMure/git-bug/identity"
"github.com/MichaelMure/git-bug/util/git"
+ "github.com/MichaelMure/git-bug/util/timestamp"
"github.com/pkg/errors"
)
@@ -37,7 +38,7 @@ func (op *SetStatusOperation) Apply(snapshot *Snapshot) {
item := &SetStatusTimelineItem{
hash: hash,
Author: op.Author,
- UnixTime: Timestamp(op.UnixTime),
+ UnixTime: timestamp.Timestamp(op.UnixTime),
Status: op.Status,
}
@@ -114,7 +115,7 @@ func NewSetStatusOp(author identity.Interface, unixTime int64, status Status) *S
type SetStatusTimelineItem struct {
hash git.Hash
Author identity.Interface
- UnixTime Timestamp
+ UnixTime timestamp.Timestamp
Status Status
}
diff --git a/bug/op_set_title.go b/bug/op_set_title.go
index ae6484c6..084838cb 100644
--- a/bug/op_set_title.go
+++ b/bug/op_set_title.go
@@ -6,6 +6,7 @@ import (
"strings"
"github.com/MichaelMure/git-bug/identity"
+ "github.com/MichaelMure/git-bug/util/timestamp"
"github.com/MichaelMure/git-bug/util/git"
"github.com/MichaelMure/git-bug/util/text"
@@ -41,7 +42,7 @@ func (op *SetTitleOperation) Apply(snapshot *Snapshot) {
item := &SetTitleTimelineItem{
hash: hash,
Author: op.Author,
- UnixTime: Timestamp(op.UnixTime),
+ UnixTime: timestamp.Timestamp(op.UnixTime),
Title: op.Title,
Was: op.Was,
}
@@ -139,7 +140,7 @@ func NewSetTitleOp(author identity.Interface, unixTime int64, title string, was
type SetTitleTimelineItem struct {
hash git.Hash
Author identity.Interface
- UnixTime Timestamp
+ UnixTime timestamp.Timestamp
Title string
Was string
}
diff --git a/bug/timeline.go b/bug/timeline.go
index 306ffa9e..d8ee2c6b 100644
--- a/bug/timeline.go
+++ b/bug/timeline.go
@@ -5,6 +5,7 @@ import (
"github.com/MichaelMure/git-bug/identity"
"github.com/MichaelMure/git-bug/util/git"
+ "github.com/MichaelMure/git-bug/util/timestamp"
)
type TimelineItem interface {
@@ -19,7 +20,7 @@ type CommentHistoryStep struct {
Author identity.Interface
// The new message
Message string
- UnixTime Timestamp
+ UnixTime timestamp.Timestamp
}
// CommentTimelineItem is a TimelineItem that holds a Comment and its edition history
@@ -28,8 +29,8 @@ type CommentTimelineItem struct {
Author identity.Interface
Message string
Files []git.Hash
- CreatedAt Timestamp
- LastEdit Timestamp
+ CreatedAt timestamp.Timestamp
+ LastEdit timestamp.Timestamp
History []CommentHistoryStep
}
diff --git a/commands/user.go b/commands/user.go
index daf9e654..c4208d41 100644
--- a/commands/user.go
+++ b/commands/user.go
@@ -36,6 +36,9 @@ func runUser(cmd *cobra.Command, args []string) error {
fmt.Printf("Name: %s\n", id.Name())
fmt.Printf("Login: %s\n", id.Login())
fmt.Printf("Email: %s\n", id.Email())
+ fmt.Printf("Last modification: %s (lamport %d)\n",
+ id.LastModification().Time().Format("Mon Jan 2 15:04:05 2006 +0200"),
+ id.LastModificationLamport())
// fmt.Printf("Protected: %v\n", id.IsProtected())
return nil
diff --git a/doc/man/git-bug-user-ls.1 b/doc/man/git-bug-user-ls.1
index 6820a28d..3ac292f1 100644
--- a/doc/man/git-bug-user-ls.1
+++ b/doc/man/git-bug-user-ls.1
@@ -20,10 +20,6 @@ List identities
.SH OPTIONS
.PP
-\fB\-v\fP, \fB\-\-verbose\fP[=false]
- Print extra information
-
-.PP
\fB\-h\fP, \fB\-\-help\fP[=false]
help for ls
diff --git a/doc/md/git-bug_user_ls.md b/doc/md/git-bug_user_ls.md
index 9f706745..d390ed2a 100644
--- a/doc/md/git-bug_user_ls.md
+++ b/doc/md/git-bug_user_ls.md
@@ -13,8 +13,7 @@ git-bug user ls [flags]
### Options
```
- -v, --verbose Print extra information
- -h, --help help for ls
+ -h, --help help for ls
```
### SEE ALSO
diff --git a/identity/bare.go b/identity/bare.go
index b6cbe491..6af794dd 100644
--- a/identity/bare.go
+++ b/identity/bare.go
@@ -9,6 +9,7 @@ import (
"github.com/MichaelMure/git-bug/repository"
"github.com/MichaelMure/git-bug/util/lamport"
"github.com/MichaelMure/git-bug/util/text"
+ "github.com/MichaelMure/git-bug/util/timestamp"
)
var _ Interface = &Bare{}
@@ -191,3 +192,13 @@ func (i *Bare) CommitAsNeeded(repo repository.ClockedRepo) error {
func (i *Bare) IsProtected() bool {
return false
}
+
+// LastModificationLamportTime return the Lamport time at which the last version of the identity became valid.
+func (i *Bare) LastModificationLamport() lamport.Time {
+ return 0
+}
+
+// LastModification return the timestamp at which the last version of the identity became valid.
+func (i *Bare) LastModification() timestamp.Timestamp {
+ return 0
+}
diff --git a/identity/identity.go b/identity/identity.go
index 720a1ebd..3dddfaec 100644
--- a/identity/identity.go
+++ b/identity/identity.go
@@ -8,6 +8,7 @@ import (
"strings"
"time"
+ "github.com/MichaelMure/git-bug/util/timestamp"
"github.com/pkg/errors"
"github.com/MichaelMure/git-bug/repository"
@@ -33,10 +34,11 @@ type Identity struct {
// Id used as unique identifier
id string
- lastCommit git.Hash
-
// all the successive version of the identity
versions []*Version
+
+ // not serialized
+ lastCommit git.Hash
}
func NewIdentity(name string, email string) *Identity {
@@ -498,13 +500,6 @@ func (i *Identity) Keys() []Key {
return i.lastVersion().keys
}
-// IsProtected return true if the chain of git commits started to be signed.
-// If that's the case, only signed commit with a valid key for this identity can be added.
-func (i *Identity) IsProtected() bool {
- // Todo
- return false
-}
-
// ValidKeysAtTime return the set of keys valid at a given lamport time
func (i *Identity) ValidKeysAtTime(time lamport.Time) []Key {
var result []Key
@@ -535,6 +530,23 @@ func (i *Identity) DisplayName() string {
panic("invalid person data")
}
+// IsProtected return true if the chain of git commits started to be signed.
+// If that's the case, only signed commit with a valid key for this identity can be added.
+func (i *Identity) IsProtected() bool {
+ // Todo
+ return false
+}
+
+// LastModificationLamportTime return the Lamport time at which the last version of the identity became valid.
+func (i *Identity) LastModificationLamport() lamport.Time {
+ return i.lastVersion().time
+}
+
+// LastModification return the timestamp at which the last version of the identity became valid.
+func (i *Identity) LastModification() timestamp.Timestamp {
+ return timestamp.Timestamp(i.lastVersion().unixTime)
+}
+
// SetMetadata store arbitrary metadata along the last defined Version.
// If the Version has been commit to git already, it won't be overwritten.
func (i *Identity) SetMetadata(key string, value string) {
diff --git a/identity/identity_stub.go b/identity/identity_stub.go
index b6bc0ab0..592eab30 100644
--- a/identity/identity_stub.go
+++ b/identity/identity_stub.go
@@ -5,6 +5,7 @@ import (
"github.com/MichaelMure/git-bug/repository"
"github.com/MichaelMure/git-bug/util/lamport"
+ "github.com/MichaelMure/git-bug/util/timestamp"
)
var _ Interface = &IdentityStub{}
@@ -93,3 +94,11 @@ func (i *IdentityStub) CommitAsNeeded(repo repository.ClockedRepo) error {
func (IdentityStub) IsProtected() bool {
panic("identities needs to be properly loaded with identity.ReadLocal()")
}
+
+func (i *IdentityStub) LastModificationLamport() lamport.Time {
+ panic("identities needs to be properly loaded with identity.ReadLocal()")
+}
+
+func (i *IdentityStub) LastModification() timestamp.Timestamp {
+ panic("identities needs to be properly loaded with identity.ReadLocal()")
+}
diff --git a/identity/interface.go b/identity/interface.go
index 49395ab1..88f1d9a7 100644
--- a/identity/interface.go
+++ b/identity/interface.go
@@ -3,6 +3,7 @@ package identity
import (
"github.com/MichaelMure/git-bug/repository"
"github.com/MichaelMure/git-bug/util/lamport"
+ "github.com/MichaelMure/git-bug/util/timestamp"
)
type Interface interface {
@@ -48,4 +49,10 @@ type Interface interface {
// IsProtected return true if the chain of git commits started to be signed.
// If that's the case, only signed commit with a valid key for this identity can be added.
IsProtected() bool
+
+ // LastModificationLamportTime return the Lamport time at which the last version of the identity became valid.
+ LastModificationLamport() lamport.Time
+
+ // LastModification return the timestamp at which the last version of the identity became valid.
+ LastModification() timestamp.Timestamp
}
diff --git a/misc/bash_completion/git-bug b/misc/bash_completion/git-bug
index c83d33ae..a0ac545c 100644
--- a/misc/bash_completion/git-bug
+++ b/misc/bash_completion/git-bug
@@ -853,9 +853,6 @@ _git-bug_user_ls()
flags_with_completion=()
flags_completion=()
- flags+=("--verbose")
- flags+=("-v")
- local_nonpersistent_flags+=("--verbose")
must_have_one_flag=()
must_have_one_noun=()
diff --git a/misc/zsh_completion/git-bug b/misc/zsh_completion/git-bug
index 232cd3c1..9f7e84dc 100644
--- a/misc/zsh_completion/git-bug
+++ b/misc/zsh_completion/git-bug
@@ -17,15 +17,6 @@ case $state in
;;
level2)
case $words[2] in
- bridge)
- _arguments '2: :(configure pull rm)'
- ;;
- comment)
- _arguments '2: :(add)'
- ;;
- label)
- _arguments '2: :(add rm)'
- ;;
status)
_arguments '2: :(close open)'
;;
@@ -35,6 +26,15 @@ case $state in
user)
_arguments '2: :(adopt create ls)'
;;
+ bridge)
+ _arguments '2: :(configure pull rm)'
+ ;;
+ comment)
+ _arguments '2: :(add)'
+ ;;
+ label)
+ _arguments '2: :(add rm)'
+ ;;
*)
_arguments '*: :_files'
;;
diff --git a/bug/time.go b/util/timestamp/timestamp.go
index a085e8e9..4f587cb4 100644
--- a/bug/time.go
+++ b/util/timestamp/timestamp.go
@@ -1,4 +1,4 @@
-package bug
+package timestamp
import "time"