Repository navigation
Push Command option to Skip Existing Packages - #2802
Conversation
| internal static string PackagesDirectoryName = "packages"; | ||
|
|
||
|
|
||
| internal enum ContinueOnErrorOptions {duplicate, invalid }; |
There was a problem hiding this comment.
I would eyeroll this one if it didn't bother me too :)
| getSymbolApiKey, | ||
| noServiceEndpoint, | ||
| false, | ||
| false, |
There was a problem hiding this comment.
please use named parameters, like the following two parameters. Easier to understand.
| noSymbolsValue, | ||
| noServiceEndpoint, | ||
| false, | ||
| false, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Yes -- good call. I forgot about this feature. Changing the other places as well.
| { | ||
| return response.StatusCode; | ||
| } | ||
| else if (continuedErrorPossibleOptions.Contains(response.StatusCode)) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
As other comments, I think it would be good to have something more understandable than "false, false".
|
Let us know when you've incorporated yesterday's feedback. Also better PR names :) |
|
Why did you close this? :) |
027227f to
2a66d44
Compare
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
8c99394 to
dcd2c3b
Compare
donnie-msft
left a comment
There was a problem hiding this comment.
Thanks. I am using VS2019 and was under the impression the CI was being changed to use VS2019. Anyway this is fine.
There was a problem hiding this comment.
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. | |||
There was a problem hiding this comment.
nit: It looks like you're removing a BOM mark.
There was a problem hiding this comment.
This modification was not by me, but happened automatically from VS.
There was a problem hiding this comment.
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. | |||
There was a problem hiding this comment.
This modification was not by me, but happened automatically from VS.
|
Really great to see this, thanks @donnie-msft and thanks @anangaur for prioritizing. |
nkolev92
left a comment
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Can you please elaborate?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
You are going to log N warnings, where N is the number of packages.
That's noisy.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
I disagree.
This is completely unnecessary,
Let's discuss offline.
| Path.GetFileName(packageToPush), | ||
| sourceName)); | ||
|
|
||
| bool showPushCommandPackagePushed = true; |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Existing tests follow a hard-coded pattern. I just made constants so at least it's only one place to change.
There was a problem hiding this comment.
I understand that, but it doesn't make them great :)
| } | ||
|
|
||
| [Fact] | ||
| public void PushCommand_Server_ContinueOn_NotSpecified_PushHalts() |
| @@ -1,4 +1,4 @@ | |||
| // Copyright (c) .NET Foundation. All rights reserved. | |||
| // Copyright (c) .NET Foundation. All rights reserved. | |||
There was a problem hiding this comment.
In general if you are not making any other changes to the file you should revert it.
* 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
Bug
Fixes: NuGet/Home#1630
Regression: No
Fix
Details: Added -ContinueOnError with options for duplicate and invalid.
Testing/Validation
Tests Added: Yes
Validation: