Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AllowPreReleasePackageOverwrites option #765

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/BaGet.Core/Configuration/BaGetOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ public class BaGetOptions
/// </summary>
public bool AllowPackageOverwrites { get; set; } = false;

/// <summary>
/// If enabled, pushing a pre released package that already exists will replace the
/// existing package.
/// </summary>
public bool AllowPreReleasePackageOverwrites { get; set; } = false;

/// <summary>
/// If true, disables package pushing, deleting, and re-listing.
/// </summary>
Expand Down
9 changes: 8 additions & 1 deletion src/BaGet.Core/Indexing/PackageIndexingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,14 @@ public async Task<PackageIndexingResult> IndexAsync(Stream packageStream, Cancel
// The package is well-formed. Ensure this is a new package.
if (await _packages.ExistsAsync(package.Id, package.Version, cancellationToken))
{
if (!_options.Value.AllowPackageOverwrites)
if (package.IsPrerelease)
{
if (!_options.Value.AllowPreReleasePackageOverwrites)
{
return PackageIndexingResult.PackageAlreadyExists;
}
}
else if (!_options.Value.AllowPackageOverwrites)
{
return PackageIndexingResult.PackageAlreadyExists;
}
Expand Down
1 change: 1 addition & 0 deletions src/BaGet/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"ApiKey": "",
"PackageDeletionBehavior": "Unlist",
"AllowPackageOverwrites": false,
"AllowPreReleasePackageOverwrites": false,

"Database": {
"Type": "Sqlite",
Expand Down