PublicRepoScan¶
Namespace Nfty.Core.Publish.Community in assembly Nfty.Core.
The scan before every share (spec 3.3). PublicRepoScan.Scan() is pure over a fetched RepoSnapshot and never throws; PublicRepoScan.RemoveAsync() deletes exactly the extras it is given, and only ones a fresh scan still names.
Fields¶
ManifestFile¶
The manifest file at its root.
PreviewAsset¶
The preview asset every Release holds.
ReadmeFile¶
The only other file allowed at its root.
RepoName¶
The repository's name.
Methods¶
FetchAsync(GitHubShareClient, string, IReadOnlyCollection<string>, CancellationToken)¶
public static Task<RepoSnapshot?> FetchAsync(GitHubShareClient client, string login, IReadOnlyCollection<string> protectedTags, CancellationToken ct);
Reads everything the scan needs. Returns null when the repository does not exist (the first share creates it). A missing or damaged nfty-public.json is a null RepoSnapshot.Manifest; one written by a newer nfty throws a CommunityException saying so rather than being called foreign.
Parameters
client(GitHubShareClient) - The GitHub client.login(string) - The signed-in account, which owns the repository.protectedTags(IReadOnlyCollection<string>) - Release tags that are never extras: every one the gallery lists for the account, and every one an open pull request names (the live version while an update waits, and the new one). Pass an empty set only when nothing is pending.ct(CancellationToken) - Cancellation.
Returns. The snapshot, or null when the repository does not exist.
RemoveAsync(GitHubShareClient, string, IReadOnlyList<RepoExtra>, IReadOnlyCollection<string>, CancellationToken)¶
public static Task RemoveAsync(GitHubShareClient client, string login, IReadOnlyList<RepoExtra> extras, IReadOnlyCollection<string> protectedTags, CancellationToken ct);
Deletes exactly extras: assets, then Releases, then tags, then files (each blob at its own sha), the extra branches last. Before deleting anything it re-reads the repository and refuses (nothing deleted) when the repository is not nfty's, or when any item is not an extra of that fresh scan, which is what keeps README.md, nfty-public.json, the default branch and every allowed Release and tag out of reach.
Parameters
client(GitHubShareClient) - The GitHub client.login(string) - The signed-in account, which owns the repository.extras(IReadOnlyList<RepoExtra>) - What to delete, as the scan listed it.protectedTags(IReadOnlyCollection<string>) - The tags kept out of reach (seePublicRepoScan.FetchAsync()): the live version while an update waits, and the new one.ct(CancellationToken) - Cancellation.
Exceptions
ArgumentException- An item is README.md, nfty-public.json or the default branch.CommunityException- The repository is not nfty's, changed since the scan, or an item can't be removed (a submodule).
Scan(RepoSnapshot)¶
Applies the 3.3 table to a snapshot.
Parameters
snapshot(RepoSnapshot) - What was read from the repository.
Returns. The extra releases to remove and the blocker that stops sharing, if any.