From eb6418b9b68e3c36e4918f97036b3b18382873e1 Mon Sep 17 00:00:00 2001 From: Catherine Date: Fri, 5 Dec 2025 08:06:50 +0000 Subject: [PATCH] Fill in `git_hash` for regular files in archive uploads. This will be used for incremental archive uploads. --- src/manifest.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/manifest.go b/src/manifest.go index ea1ae2f..d9da487 100644 --- a/src/manifest.go +++ b/src/manifest.go @@ -17,6 +17,8 @@ import ( "time" "github.com/c2h5oh/datasize" + "github.com/go-git/go-git/v6/plumbing" + format "github.com/go-git/go-git/v6/plumbing/format/config" "github.com/klauspost/compress/zstd" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" @@ -103,7 +105,14 @@ func NewManifestEntry(type_ Type, data []byte) *Entry { } func AddFile(manifest *Manifest, path string, data []byte) *Entry { + // Fill in `git_hash` even for files not originating from git using the SHA256 algorithm; + // we use this primarily for incremental archive uploads, but when support for git SHA256 + // repositories is complete, archive uploads and git checkouts will have cross-support for + // incremental updates. + hasher := plumbing.NewHasher(format.SHA256, plumbing.BlobObject, int64(len(data))) + hasher.Write(data) entry := NewManifestEntry(Type_InlineFile, data) + entry.GitHash = proto.String(hasher.Sum().String()) manifest.Contents[path] = entry return entry }