Skip to content

Commit

Permalink
attest: preserve refs/attestations parent. (#129)
Browse files Browse the repository at this point in the history
Signed-off-by: Billy Lynch <[email protected]>

Signed-off-by: Billy Lynch <[email protected]>
  • Loading branch information
wlynch authored Sep 6, 2022
1 parent 4ee1d4c commit 06bc251
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions cmd/gitsign-attest/internal/attest/attest.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,7 @@ func WriteFile(ctx context.Context, repo *git.Repository, refName string, sha pl

// Check current attestation ref to see if there is existing data.
// If so, make sure old data is preserved.
var (
parentHash plumbing.Hash
attCommit *object.Commit
)
var attCommit *object.Commit
attRef, err := repo.Reference(plumbing.ReferenceName(refName), true)
if err != nil {
if !errors.Is(err, plumbing.ErrReferenceNotFound) {
Expand Down Expand Up @@ -138,8 +135,8 @@ func WriteFile(ctx context.Context, repo *git.Repository, refName string, sha pl
When: time.Now(),
},
}
if parentHash != plumbing.ZeroHash {
commit.ParentHashes = []plumbing.Hash{parentHash}
if attCommit != nil {
commit.ParentHashes = []plumbing.Hash{attCommit.Hash}
}
chash, err := encode(repo.Storer, commit)
if err != nil {
Expand Down

0 comments on commit 06bc251

Please sign in to comment.