Skip to content

Push Command option to Skip Existing Packages - #2802

Merged
donnie-msft merged 6 commits into
devfrom
dev-donnie-msft-SkipExistingPackageVersion
May 1, 2019
Merged

donnie-msft merged 6 commits into
devfrom
dev-donnie-msft-SkipExistingPackageVersion

Conversation

@donnie-msft

Copy link
Copy Markdown
Contributor

Bug

Fixes: NuGet/Home#1630
Regression: No

  • Last working version:
  • How are we preventing it in future:

Fix

Details: Added -ContinueOnError with options for duplicate and invalid.

Testing/Validation

Tests Added: Yes
Validation:

@dnfclas

dnfclas commented Apr 12, 2019 •

Copy link
Copy Markdown

CLA assistant check
All CLA requirements met.

@donnie-msft
donnie-msft marked this pull request as ready for review April 15, 2019 16:51
internal static string PackagesDirectoryName = "packages";


internal enum ContinueOnErrorOptions {duplicate, invalid };

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: whitespace after {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would eyeroll this one if it didn't bother me too :)

getSymbolApiKey,
noServiceEndpoint,
false,
false,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use named parameters, like the following two parameters. Easier to understand.

noSymbolsValue,
noServiceEndpoint,
false,
false,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use named paramters, or create two variables before the method call, so anyone reading knows what these variables mean. The compiler will optimise them away in release mode.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes -- good call. I forgot about this feature. Changing the other places as well.

{
return response.StatusCode;
}
else if (continuedErrorPossibleOptions.Contains(response.StatusCode))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since continuedErrorPossibleOptions is always a superset of codesNotToThrow, instead of effectively checking the same values twice, what about using a Dictionary<HttpStatusCode, bool>, so there's only a single lookup? Although the two lists have a max length of 2 elements at the moment, so maybe not worthwhile.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably won't use a Dictionary since actually we are now going to reduce this to 1. Don't expect the list to grow any, and certainly not substantially.

}

await PushPackage(symbolPackagePath, source, apiKey, noServiceEndpoint, requestTimeout, log, token, isSnupkgPush: isSymbolEndpointSnupkgCapable);
await PushPackage(symbolPackagePath, source, apiKey, noServiceEndpoint, false, false, requestTimeout, log, token, isSnupkgPush: isSymbolEndpointSnupkgCapable);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As other comments, I think it would be good to have something more understandable than "false, false".

@nkolev92

Copy link
Copy Markdown
Member

Let us know when you've incorporated yesterday's feedback.

Also better PR names :)

@donnie-msft donnie-msft changed the title Dev donnie msft skip existing package version Push Command option to Skip Existing Packages Apr 18, 2019
@nkolev92

Copy link
Copy Markdown
Member

Why did you close this? :)

@donnie-msft donnie-msft reopened this Apr 18, 2019
@donnie-msft
donnie-msft force-pushed the dev-donnie-msft-SkipExistingPackageVersion branch from 027227f to 2a66d44 Compare April 23, 2019 19:19
@donnie-msft
donnie-msft requested a review from zivkan April 30, 2019 23:56
@donnie-msft

Copy link
Copy Markdown
Contributor Author

@nkolev92

String Resource and designer with new strings

Error on Invalid option for ContinueOnError

Refactored unit tests and added test for Invalid ContinueOnError

Messages for suggesting usage and ContinueOnError not supported warning.

Remove todo

Remove comment

ContinueOnError is now just a flag, ContinueOnDuplicate.

WIP Directory Push tests

Renamed option to SkipDuplicate
@donnie-msft
donnie-msft force-pushed the dev-donnie-msft-SkipExistingPackageVersion branch from 8c99394 to dcd2c3b Compare May 1, 2019 00:14

@donnie-msft donnie-msft left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I am using VS2019 and was under the impression the CI was being changed to use VS2019. Anyway this is fine.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I wanted to make sure the dotnet.exe execution did not advertise an option that doesn't exist!

@@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.

@dominoFire dominoFire May 1, 2019 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: It looks like you're removing a BOM mark.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This modification was not by me, but happened automatically from VS.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general if you are not making any other changes to the file you should revert it.

@@ -1,18 +1,25 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: BOM mark.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This modification was not by me, but happened automatically from VS.

@donnie-msft
donnie-msft merged commit 5b975f4 into dev May 1, 2019
@donnie-msft
donnie-msft deleted the dev-donnie-msft-SkipExistingPackageVersion branch May 1, 2019 03:07
@infin8x

infin8x commented May 1, 2019

Copy link
Copy Markdown

Really great to see this, thanks @donnie-msft and thanks @anangaur for prioritizing.

@nkolev92 nkolev92 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few style comments, but I really think you should address the logging issue.

This is only nuget.exe work, so it didn't need to be merged immediately.

{
var length = new FileInfo(packageToPush).Length;
await PushPackageToServer(source, apiKey, packageToPush, length, noServiceEndpoint, requestTimeout, log, token);
showPushCommandPackagePushed = await PushPackageToServer(source, apiKey, packageToPush, length, noServiceEndpoint, skipDuplicate

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: formatting

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please elaborate?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally you have 1 param per line or all on 1 line.

Specifically here, though, I was referring to the line below

, requestTimeout, log, tokenSource.Token, isSnupkgPush: false);
should be
requestTimeout, log, tokenSource.Token, isSnupkgPush: false);

The comma , goes on the previous line.

File.Copy(pathToPackage, fullPath, overwrite: true);

//Indicate that SkipDuplicate is currently not supported in this scenario.
if (skipDuplicate)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are going to log N warnings, where N is the number of packages.

That's noisy.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already asked others about this before I committed. The thought was that being noisy is fine since someone is using an option that doesn't make sense.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree.

This is completely unnecessary,

Let's discuss offline.

Path.GetFileName(packageToPush),
sourceName));

bool showPushCommandPackagePushed = true;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better name would have been something like "packagePushStatus".
Variable should be named based on what they represent, not how they are used.

{
public class PushCommandTest
{
private const string MESSAGE_EXISTING_PACKAGE = "already exists at feed"; //Derived from resx: AddPackage_PackageAlreadyExists

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are these resources put?

If you add internals visible to for this assembyl from what I presume is NuGet.Commands, you'd be able to use the exact string and avoid test changes if the strings ever change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Existing tests follow a hard-coded pattern. I just made constants so at least it's only one place to change.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that, but it doesn't make them great :)

}

[Fact]
public void PushCommand_Server_ContinueOn_NotSpecified_PushHalts()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: name :)

@@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general if you are not making any other changes to the file you should revert it.

donnie-msft added a commit that referenced this pull request May 2, 2019
* Push code/tests for Skip Duplicates

String Resource and designer with new strings

Error on Invalid option for ContinueOnError

Refactored unit tests and added test for Invalid ContinueOnError

Messages for suggesting usage and ContinueOnError not supported warning.

Remove todo

Remove comment

ContinueOnError is now just a flag, ContinueOnDuplicate.

WIP Directory Push tests

Renamed option to SkipDuplicate

* Dotnet.exe command added; removed Invalid plumbing; Reworded some strings

* WIP triggering CI to run new test draft

* Making compatible with VS2017

* Removing dotnet CLI changes

* Fix build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Skip Duplicate switch added to nuget.exe push command

6 participants