Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Expand workaround to any Git with osxkeychain
Browse files Browse the repository at this point in the history
It turns out the "Git OSX Installer" brings the same hardcoded
osxkeychain credential helper and thus it is no longer sufficient
to try to detect based on the Git version.
  • Loading branch information
Oli Dagenais committed Jul 1, 2016
1 parent 43a27a1 commit 22f8d6d
Showing 1 changed file with 20 additions and 24 deletions.
44 changes: 20 additions & 24 deletions src/main/java/com/microsoft/alm/gitcredentialmanager/Program.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,15 @@ private void printHelpMessage()
standardOut.println(" `git config --global credential.microsoft.visualstudio.com.authority AAD`");
standardOut.println();
standardOut.println(" eraseosxkeychain Enables a workaround when running on Mac OS X");
standardOut.println(" and using 'Apple Git' (which includes the osxkeychain");
standardOut.println(" and using a version of Git which includes the osxkeychain");
standardOut.println(" credential helper, hardcoded before all other helpers).");
standardOut.println(" The problem is osxkeychain may return expired or");
standardOut.println(" revoked credentials, aborting the Git operation.");
standardOut.println(" The workaround is to preemptively erase from osxkeychain");
standardOut.println(" any Git credentials that can be refreshed or re-acquired");
standardOut.println(" by this credential helper.");
standardOut.println(" Defaults to TRUE. Ignored by Basic authority.");
standardOut.println(" Does nothing if Apple Git on Mac OS X isn't detected.");
standardOut.println(" Does nothing if osxkeychain on Mac OS X isn't detected.");
standardOut.println();
standardOut.println(" `git config --global credential.microsoft.visualstudio.com.eraseosxkeychain false`");
standardOut.println();
Expand Down Expand Up @@ -437,30 +437,26 @@ public static void store(final OperationArguments operationArguments, final IAut
{
if (operationArguments.EraseOsxKeyChain && Provider.isMac(osName))
{
final String gitResponse = fetchGitVersion(processFactory);
if (gitResponse.contains("Apple Git-"))
// check for the presence of git-credential-osxkeychain by scanning PATH
final File osxkeychainFile = findProgram(pathString, pathSeparator, "git-credential-osxkeychain", fileChecker);
if (osxkeychainFile != null)
{
// check for the presence of git-credential-osxkeychain by scanning PATH
final File osxkeychainFile = findProgram(pathString, pathSeparator, "git-credential-osxkeychain", fileChecker);
if (osxkeychainFile != null)
// erase these credentials from osxkeychain
try
{
// erase these credentials from osxkeychain
try
{
final String program = osxkeychainFile.getAbsolutePath();
final TestableProcess process = processFactory.create(program, "erase");
final ProcessCoordinator coordinator = new ProcessCoordinator(process);
coordinator.print(operationArguments.toString());
coordinator.waitFor();
}
catch (final IOException e)
{
throw new Error(e);
}
catch (final InterruptedException e)
{
throw new Error(e);
}
final String program = osxkeychainFile.getAbsolutePath();
final TestableProcess process = processFactory.create(program, "erase");
final ProcessCoordinator coordinator = new ProcessCoordinator(process);
coordinator.print(operationArguments.toString());
coordinator.waitFor();
}
catch (final IOException e)
{
throw new Error(e);
}
catch (final InterruptedException e)
{
throw new Error(e);
}
}
}
Expand Down

0 comments on commit 22f8d6d

Please sign in to comment.