Skip to content

Commit fdc777d

Browse files
committed
Add source option to PackageFetchStrategy enum
1 parent c77d35d commit fdc777d

3 files changed

Lines changed: 19 additions & 5 deletions

File tree

docs/configuration-reference.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,18 @@ Enable building distribution from the source.
140140

141141
Type: `string` | Default: `mirror`
142142

143-
todo
144-
145-
Fetch mirrored packages from their VCS repositories by default when possible.
146-
147-
Sets the fetch strategy of new mirrored packages to **Fetch from VCS**.
143+
Configure the default fetch strategy for packages:
144+
145+
**mirror**
146+
Always try to mirror package metaddata from mirror registries when possible. Only metadata from the project's
147+
`composer.json` is available. If mirroring is not possible, it defaults to `source` instead.
148+
**source**
149+
Try to fetch package metadata directly from the source, but doesn't have to include VCS data. For example, when the
150+
package is hosted on GitHub the API is used instead which saves on storage and bandwidth, but limits the amount of
151+
metadata that's available.
152+
**vcs**
153+
Always fetch package metadata directly from the source through VCS. Package metadata is create directly from the
154+
source code.
148155

149156
[iso-8601-durations]: https://en.wikipedia.org/wiki/ISO_8601#Durations
150157
[symfony]: https://symfony.com

src/Doctrine/Entity/PackageFetchStrategy.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,19 @@
55
enum PackageFetchStrategy: string
66
{
77
case Mirror = 'mirror';
8+
case Source = 'source';
89
case Vcs = 'vcs';
910

1011
public function isMirror(): bool
1112
{
1213
return self::Mirror === $this;
1314
}
1415

16+
public function isSource(): bool
17+
{
18+
return self::Source === $this;
19+
}
20+
1521
public function isVcs(): bool
1622
{
1723
return self::Vcs === $this;

src/Package/PackageMetadataResolver.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public function resolve(Package $package): void
7878
{
7979
match ($package->getFetchStrategy()) {
8080
PackageFetchStrategy::Mirror => $this->resolveRegistryPackage($package),
81+
PackageFetchStrategy::Source,
8182
PackageFetchStrategy::Vcs => $this->resolveVcsPackage($package),
8283
};
8384

0 commit comments

Comments
 (0)