aboutsummaryrefslogtreecommitdiffstats
path: root/identity
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2019-02-24 23:05:03 +0100
committerMichael Muré <batolettre@gmail.com>2019-03-01 22:52:54 +0100
commitc235d89d36500e58e3bcadda94e9cab06023dd55 (patch)
treec2ee84316886cca3e439dbc12f64d6a06ddd7c18 /identity
parent46beb4b886761ff69abe2ce45c2498a4fafe50d9 (diff)
downloadgit-bug-c235d89d36500e58e3bcadda94e9cab06023dd55.tar.gz
commands: show the last modification time in "user"
Diffstat (limited to 'identity')
-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
4 files changed, 48 insertions, 9 deletions
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
}