From fad2bef872c3699448b0dbfb46cea85499855bba Mon Sep 17 00:00:00 2001 From: Dan Lorenc Date: Thu, 5 Dec 2019 13:46:44 -0600 Subject: [PATCH] Set scm.PR.Sha to scm.PR.Head.Sha when loading from disk. This guarantee is made when retrieving a PR from a provider, but we do not persist that guarantee when roundtripping from disk. --- cmd/pullrequest-init/disk.go | 2 ++ cmd/pullrequest-init/disk_test.go | 3 +++ 2 files changed, 5 insertions(+) diff --git a/cmd/pullrequest-init/disk.go b/cmd/pullrequest-init/disk.go index 6bef194f25a..f3d00f1575f 100644 --- a/cmd/pullrequest-init/disk.go +++ b/cmd/pullrequest-init/disk.go @@ -201,6 +201,8 @@ func FromDisk(path string) (*Resource, error) { return nil, err } + r.PR.Sha = r.PR.Head.Sha + return r, nil } diff --git a/cmd/pullrequest-init/disk_test.go b/cmd/pullrequest-init/disk_test.go index a3ceed29c8d..b5b91d53b64 100644 --- a/cmd/pullrequest-init/disk_test.go +++ b/cmd/pullrequest-init/disk_test.go @@ -310,6 +310,9 @@ func TestFromDisk(t *testing.T) { if diff := cmp.Diff(rsrc.PR.Head, head); diff != "" { t.Errorf("Get Head: -want +got: %s", diff) } + if diff := cmp.Diff(rsrc.PR.Sha, head.Sha); diff != "" { + t.Errorf("Get Sha: -want +got: %s", diff) + } // Check the comments commentMap := map[int]scm.Comment{}