mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
git: extract authentication machinery to let override it in a plugin
This commit is contained in:
@@ -86,8 +86,8 @@ abstract class GitImplBase implements Git {
|
||||
* Run handler with retry on authentication failure
|
||||
*/
|
||||
@NotNull
|
||||
private static GitCommandResult run(@NotNull Computable<GitLineHandler> handlerConstructor,
|
||||
@NotNull Computable<OutputCollector> outputCollectorConstructor) {
|
||||
private GitCommandResult run(@NotNull Computable<GitLineHandler> handlerConstructor,
|
||||
@NotNull Computable<OutputCollector> outputCollectorConstructor) {
|
||||
@NotNull GitCommandResult result;
|
||||
|
||||
int authAttempt = 0;
|
||||
@@ -105,10 +105,10 @@ abstract class GitImplBase implements Git {
|
||||
* Run handler with per-project locking, logging and authentication
|
||||
*/
|
||||
@NotNull
|
||||
private static GitCommandResult run(@NotNull GitLineHandler handler, @NotNull OutputCollector outputCollector) {
|
||||
private GitCommandResult run(@NotNull GitLineHandler handler, @NotNull OutputCollector outputCollector) {
|
||||
Project project = handler.project();
|
||||
if (project != null && handler.isRemote()) {
|
||||
try (GitHandlerAuthenticationManager authenticationManager = GitHandlerAuthenticationManager.prepare(project, handler)) {
|
||||
try (GitHandlerAuthenticationManager authenticationManager = prepareAuthentication(project, handler)) {
|
||||
return GitCommandResult.withAuthentication(doRun(handler, outputCollector), authenticationManager.isHttpAuthFailed());
|
||||
}
|
||||
catch (IOException e) {
|
||||
@@ -119,6 +119,12 @@ abstract class GitImplBase implements Git {
|
||||
return doRun(handler, outputCollector);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected GitHandlerAuthenticationManager prepareAuthentication(@NotNull Project project, @NotNull GitLineHandler handler)
|
||||
throws IOException {
|
||||
return GitHandlerAuthenticationManager.prepare(project, handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run handler with per-project locking, logging
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user