aboutsummaryrefslogtreecommitdiffstats
path: root/identity/identity.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2019-02-19 00:19:27 +0100
committerMichael Muré <batolettre@gmail.com>2019-03-01 22:40:27 +0100
commit71f9290fdae7551f3d3ada2179ece4084304d734 (patch)
tree3494e4d4491012899ace256f534f5faea1ba2a88 /identity/identity.go
parentffe35fece1b1526949107f154abc21a1a02fc74d (diff)
downloadgit-bug-71f9290fdae7551f3d3ada2179ece4084304d734.tar.gz
identity: store the times properly
Diffstat (limited to 'identity/identity.go')
-rw-r--r--identity/identity.go13
1 files changed, 9 insertions, 4 deletions
diff --git a/identity/identity.go b/identity/identity.go
index 193a3013..b9d40967 100644
--- a/identity/identity.go
+++ b/identity/identity.go
@@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"strings"
+ "time"
"github.com/pkg/errors"
@@ -252,8 +253,8 @@ func (i *Identity) AddVersion(version *Version) {
// Write the identity into the Repository. In particular, this ensure that
// the Id is properly set.
-func (i *Identity) Commit(repo repository.Repo) error {
- // Todo: check for mismatch between memory and commited data
+func (i *Identity) Commit(repo repository.ClockedRepo) error {
+ // Todo: check for mismatch between memory and commit data
if !i.NeedCommit() {
return fmt.Errorf("can't commit an identity with no pending version")
@@ -266,10 +267,14 @@ func (i *Identity) Commit(repo repository.Repo) error {
for _, v := range i.versions {
if v.commitHash != "" {
i.lastCommit = v.commitHash
- // ignore already commited versions
+ // ignore already commit versions
continue
}
+ // get the times where new versions starts to be valid
+ v.time = repo.EditTime()
+ v.unixTime = time.Now().Unix()
+
blobHash, err := v.Write(repo)
if err != nil {
return err
@@ -319,7 +324,7 @@ func (i *Identity) Commit(repo repository.Repo) error {
return nil
}
-func (i *Identity) CommitAsNeeded(repo repository.Repo) error {
+func (i *Identity) CommitAsNeeded(repo repository.ClockedRepo) error {
if !i.NeedCommit() {
return nil
}