From b923a2065a4f5696831560396aa4ded4eab3d993 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Mon, 4 Aug 2014 23:25:32 +0200 Subject: [PATCH] Rename field in Snapshot: Tree -> TreeID --- cmd/khepri/cmd_backup.go | 2 +- cmd/khepri/cmd_restore.go | 2 +- snapshot.go | 4 ++-- snapshot_test.go | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/khepri/cmd_backup.go b/cmd/khepri/cmd_backup.go index 6785d12be..1b4d80988 100644 --- a/cmd/khepri/cmd_backup.go +++ b/cmd/khepri/cmd_backup.go @@ -125,7 +125,7 @@ func commandBackup(repo *khepri.Repository, args []string) error { } sn := khepri.NewSnapshot(target) - sn.Tree = id + sn.TreeID = id snid, err := sn.Save(repo) if err != nil { diff --git a/cmd/khepri/cmd_restore.go b/cmd/khepri/cmd_restore.go index 0aef4bedc..fe8adbd09 100644 --- a/cmd/khepri/cmd_restore.go +++ b/cmd/khepri/cmd_restore.go @@ -127,7 +127,7 @@ func commandRestore(repo *khepri.Repository, args []string) error { log.Fatalf("error loading snapshot %s", id) } - err = restore_dir(repo, sn.Tree, target) + err = restore_dir(repo, sn.TreeID, target) if err != nil { return err } diff --git a/snapshot.go b/snapshot.go index 514e29cfe..555ebcf1e 100644 --- a/snapshot.go +++ b/snapshot.go @@ -9,7 +9,7 @@ import ( type Snapshot struct { Time time.Time `json:"time"` - Tree ID `json:"tree"` + TreeID ID `json:"tree"` Dir string `json:"dir"` Hostname string `json:"hostname,omitempty"` Username string `json:"username,omitempty"` @@ -39,7 +39,7 @@ func NewSnapshot(dir string) *Snapshot { } func (sn *Snapshot) Save(repo *Repository) (ID, error) { - if sn.Tree == nil { + if sn.TreeID == nil { panic("Snapshot.Save() called with nil tree id") } diff --git a/snapshot_test.go b/snapshot_test.go index 611f9512f..c294312d7 100644 --- a/snapshot_test.go +++ b/snapshot_test.go @@ -17,7 +17,7 @@ func TestSnapshot(t *testing.T) { }() sn := khepri.NewSnapshot("/home/foobar") - sn.Tree, err = khepri.ParseID("c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2") + sn.TreeID, err = khepri.ParseID("c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2") ok(t, err) sn.Time, err = time.Parse(time.RFC3339Nano, "2014-08-03T17:49:05.378595539+02:00") ok(t, err)