Skip to content

Commit b7f9674

Browse files
jmhollaJoshua Holland
andauthored
Clone only most recent commits (#49)
This change should greatly reduce the bandwidth requirements of older state repositories. Co-authored-by: Joshua Holland <joshua@uptrusthq.com>
1 parent 2689ec1 commit b7f9674

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

storages/git/git.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,15 @@ func (storageSession *storageSession) clone(params *RequestMetadataParams) error
185185
URL: params.Repository,
186186
Auth: auth,
187187
ReferenceName: ref(params.Ref, false),
188+
// We only need to know the latest version of branches to be able to commit on top
189+
// of them. And, we don't otherwise use the history of the repository. So, this
190+
// saves a lot data.
191+
// A further improvement that has not been implemented would be to use
192+
// sparse-checkouts to only retrieve only blobs (i.e., files) from the server that
193+
// we actually care about. The depth here prevents performance problems from
194+
// history growth. sparse-checkouts help with horizontal growth (e.g., additional
195+
// systems managed by the repository).
196+
Depth: 1,
188197
}
189198

190199
repository, err := git.Clone(storageSession.storer, storageSession.fs, cloneOptions)

0 commit comments

Comments
 (0)