-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Read new wwwauth[]
input from Git 2.41
#1288
Conversation
Add support for reading and writing multi-dictionaries in Git's credential helper I/O format. Multi-dictionaries differ from normal dictionaries by being key:value relation 1:N. Git prepends "[]" to the end of keys that should be treated as lists or having mutliple values. An empty value in the list has the effect of cleaning/resetting the values in the list so far. The first multiple-valued key is expected to be 'wwwauth[]' from this patch series: https://lore.kernel.org/git/pull.1352.v11.git.1677518420.gitgitgadget@gmail.com/
Add the new `wwwauth[]` credential property to the input arguments surfaced to providers and commands.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! The tests made what you did super clear and easy to follow. Nice work! ⭐
@@ -207,6 +402,20 @@ private static string WriteStringStream(IDictionary<string, string> input, Actio | |||
return output.ToString(); | |||
} | |||
|
|||
private static void AssertDictionary(string expectedValue, string key, IDictionary<string, string> dict) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks to be unused - do we want to keep it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's worth keeping. We should maybe be using it in some of the existing tests!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'm fine with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushed a new commit on top that now uses the AssertDictionary
helper method.
src/shared/Core/Trace.cs
Outdated
@@ -215,13 +216,25 @@ public void Flush() | |||
{ | |||
bool isSecretEntry = !(secretKeys is null) && | |||
secretKeys.Contains(entry.Key, keyComparer ?? EqualityComparer<TKey>.Default); | |||
if (isSecretEntry && !this.IsSecretTracingEnabled) | |||
|
|||
void WriteSecretLine(object value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't aware you could do this. Interesting!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean the use of local functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep!
|
||
// Transform input from 1:1 to 1:n and store as readonly | ||
_dict = new ReadOnlyDictionary<string, IList<string>>( | ||
dict.ToDictionary(x => x.Key, x => (IList<string>)new[] { x.Value }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Elegant!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Helps reduce churn. This constructor is now only called from test set up code.
**Changes:** - Use in-proc methods for getting OS version number (#1240, #1264) - Update System.CommandLine (#1265) - Suppress GUI from command-line argument (#1267) - Add github (login|logout|list) commands (#1267) - cURL Cookie file support (#1251) - Update target framework on Mac/Linux to .NET 7 (#1274, #1282) - Replace JSON.NET with System.Text.Json (#1274) - Preserve exact redirect URI formatting in OAuth requests (#1281) - Use IP localhost redirect for GitHub (#1286) - Use WWW-Authenticate headers from Git for Azure Repos authority (#1288) - Better GitHub Enterprise Managed User (EMU) account support (#1190)
Add the new
wwwauth[]
credential property to the input arguments surfaced to providers and commands. This optional property is available as of Git 2.41.https://lore.kernel.org/git/xmqqleh3a3wm.fsf@gitster.g/
This new property may contain multiple values, as identified by a trailing
[]
on the property name. Extend ourDictionary/Stream(Reader|Writer)
methods to allow for these multi-valued properties and add a convenience property to theInputArguments
to getwwwauth[]
.