swiftlang / swift-package-manager

The Package Manager for the Swift Programming Language
Apache License 2.0
9.74k stars 1.34k forks source link

Add support for partial or shallow cloning of dependency repos #6747

Closed JoeSzymanskiFAN closed 1 year ago

JoeSzymanskiFAN commented 1 year ago

Description

Currently, SPM does a clone of the entire repo, including the full history. This is apparently intended (see https://github.com/apple/swift-package-manager/issues/5159) as preferred by GitHub, but means that larger or older repos require downloading and storing potentially hundreds of megabytes of data.

As an example, https://github.com/airbnb/lottie-ios appears to be ~415MiB via SPM. When cloned directly, the repo is ~368 MiB. Conversely, a partial clone can be as small as ~238 MiB, about 35% smaller.

In most cases, SPM will only need the specific commit for a given release, meaning the size of the clone can be significantly reduced. There should not be significant downsides to performing partial clones for these cases, since the operations performed on SPM repos are usually very limited.

See https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/ for examples of some of the partial cloning actions supported by GitHub. In testing, there was not a significant additional saving between a blobless clone and a full shallow clone, so I would suggest that support for blobless clones would probably be the best option, since they have the fewest potential downsides.

Expected behavior

No response

Actual behavior

No response

Steps to reproduce

No response

Swift Package Manager version/commit hash

No response

Swift & OS version (output of swift --version && uname -a)

No response

neonichu commented 1 year ago

dupe of #6062