Skip to content

Commit

Permalink
Set scm.PR.Sha to scm.PR.Head.Sha when loading from disk.
Browse files Browse the repository at this point in the history
This guarantee is made when retrieving a PR from a provider, but we do not persist
that guarantee when roundtripping from disk.
  • Loading branch information
dlorenc authored and imjasonh committed Dec 6, 2019
1 parent c5fdfb5 commit fad2bef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd/pullrequest-init/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ func FromDisk(path string) (*Resource, error) {
return nil, err
}

r.PR.Sha = r.PR.Head.Sha

return r, nil
}

Expand Down
3 changes: 3 additions & 0 deletions cmd/pullrequest-init/disk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down

0 comments on commit fad2bef

Please sign in to comment.