Skip to content
This repository was archived by the owner on Jul 15, 2023. It is now read-only.

Commit 03c0fd4

Browse files
author
J Wyman
authored
Merge pull request #630 from whoisj/find-git
[Series 1/2] alm: read URL from git-remote-https process.
2 parents d3dc8c1 + a849555 commit 03c0fd4

25 files changed

+1853
-512
lines changed

Bitbucket.Authentication/Src/OAuth/OAuthAuthenticator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ private async Task<AuthenticationResult> GetAccessToken(TargetUri targetUri, str
176176
Timeout = TimeSpan.FromMilliseconds(RequestTimeout),
177177
};
178178
var grantUri = GetGrantUrl(targetUri, authCode);
179-
var requestUri = new TargetUri(grantUri, targetUri.ProxyUri);
179+
var requestUri = targetUri.CreateWith(grantUri);
180180
var content = GetGrantRequestContent(authCode);
181181

182182
using (var response = await Network.HttpPostAsync(requestUri, content, options))
@@ -223,7 +223,7 @@ private async Task<AuthenticationResult> RefreshAccessToken(TargetUri targetUri,
223223
throw new ArgumentNullException(nameof(currentRefreshToken));
224224

225225
var refreshUri = GetRefreshUri();
226-
var requestUri = new TargetUri(refreshUri, targetUri.ProxyUri);
226+
var requestUri = targetUri.CreateWith(refreshUri);
227227
var options = new NetworkRequestOptions(true)
228228
{
229229
Timeout = TimeSpan.FromMilliseconds(RequestTimeout),

Bitbucket.Authentication/Src/Rest/RestClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public async Task<AuthenticationResult> TryGetUser(TargetUri targetUri, int requ
2626
Authorization = authorization,
2727
Timeout = TimeSpan.FromMilliseconds(requestTimeout),
2828
};
29-
var requestUri = new TargetUri(restRootUrl, targetUri.ProxyUri);
29+
var requestUri = targetUri.CreateWith(restRootUrl);
3030

3131
using (var response = await Network.HttpGetAsync(requestUri, options))
3232
{

Cli/Askpass/GlobalSuppressions.cs

-944 Bytes
Binary file not shown.

Cli/Manager/Program.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ internal void Delete()
278278
throw new ArgumentException(inner.Message, nameof(operationArguments), inner);
279279
}
280280

281+
// Load operation arguments.
281282
await LoadOperationArguments(operationArguments);
282283
EnableTraceLogging(operationArguments);
283284

@@ -350,9 +351,13 @@ internal void Erase()
350351
throw new ArgumentException(inner.Message, nameof(operationArguments), inner);
351352
}
352353

354+
// Load operation arguments.
353355
await LoadOperationArguments(operationArguments);
354356
EnableTraceLogging(operationArguments);
355357

358+
// Read the details of any git-remote-http(s).exe parent process.
359+
ReadGitRemoteDetails(operationArguments);
360+
356361
// Set the parent window handle.
357362
ParentHwnd = operationArguments.ParentHwnd;
358363

@@ -386,9 +391,13 @@ internal void Get()
386391
throw new ArgumentException(inner.Message, nameof(operationArguments), inner);
387392
}
388393

394+
// Load operation arguments.
389395
await LoadOperationArguments(operationArguments);
390396
EnableTraceLogging(operationArguments);
391397

398+
// Read the details of any git-remote-http(s).exe parent process.
399+
ReadGitRemoteDetails(operationArguments);
400+
392401
// Set the parent window handle.
393402
ParentHwnd = operationArguments.ParentHwnd;
394403

@@ -473,9 +482,13 @@ internal void Store()
473482
throw new ArgumentException(inner.Message, nameof(operationArguments), inner);
474483
}
475484

485+
// Load operation arguments.
476486
await LoadOperationArguments(operationArguments);
477487
EnableTraceLogging(operationArguments);
478488

489+
// Read the details of any git-remote-http(s).exe parent process.
490+
ReadGitRemoteDetails(operationArguments);
491+
479492
// Set the parent window handle.
480493
ParentHwnd = operationArguments.ParentHwnd;
481494

Cli/Shared/Delegates.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ internal delegate bool ModalPromptDisplayDialogDelegate(Program program,
8989

9090
internal delegate Task<Credential> QueryCredentialsDelegate(Program program, OperationArguments operationArguments);
9191

92+
internal delegate void ReadGitRemoteDetailsDelegate(Program program, OperationArguments operationArguments);
93+
9294
internal delegate ConsoleKeyInfo ReadKeyDelegate(Program program, bool intercept);
9395

9496
internal delegate void SetStandardReaderDelegate(Program program, TextReader writer);

Cli/Shared/Functions/Common.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public static async Task<BaseAuthentication> CreateAuthentication(Program progra
170170
null);
171171

172172
case AuthorityType.Bitbucket:
173-
program.Trace.WriteLine($"authority for '{operationArguments.TargetUri}' is Bitbucket");
173+
program.Trace.WriteLine($"authority for '{operationArguments.TargetUri}' is Bitbucket.");
174174

175175
// Return a Bitbucket authentication object.
176176
return authority ?? new Bitbucket.Authentication(program.Context,
@@ -845,6 +845,19 @@ public static async Task<Credential> QueryCredentials(Program program, Operation
845845
return credentials;
846846
}
847847

848+
public static void ReadGitRemoteDetails(Program program, OperationArguments operationArguments)
849+
{
850+
if (program is null)
851+
throw new ArgumentNullException(nameof(program));
852+
if (operationArguments is null)
853+
throw new ArgumentNullException(nameof(operationArguments));
854+
855+
if (program.Context.Utilities.TryReadGitRemoteHttpDetails(out string commandLine, out _))
856+
{
857+
operationArguments.GitRemoteHttpCommandLine = commandLine;
858+
}
859+
}
860+
848861
public static bool TryParse(string text, out int result)
849862
{
850863
return (text.StartsWith("0x", StringComparison.OrdinalIgnoreCase)

0 commit comments

Comments
 (0)