Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added code to be smarter about overwriting files

Fixes #11
  • Loading branch information...
commit b029f60346494e117a355a358b0a603ecbe84d5f 1 parent ab56d1f
@anurse authored
Showing with 8 additions and 4 deletions.
  1. +8 −4 git-credential-winstore/Program.cs
View
12 git-credential-winstore/Program.cs
@@ -134,9 +134,10 @@ private static void InstallTheApp(string pathToGit, bool silent)
// Look for git
if (String.IsNullOrEmpty(pathToGit))
{
- string[] paths = Environment.GetEnvironmentVariable("PATH").Split(Path.DirectorySeparatorChar);
- bool foundGit = paths.Select(path => File.Exists(Path.Combine(path, "git.exe"))).Any(b => b);
- if (!foundGit)
+ string[] paths = Environment.GetEnvironmentVariable("PATH").Split(Path.PathSeparator);
+ pathToGit = paths.Select(path => Path.Combine(path, "git.exe"))
+ .Where(File.Exists).FirstOrDefault();
+ if (String.IsNullOrEmpty(pathToGit))
{
Console.WriteLine(@"Could not find Git in your PATH environment variable.");
Console.WriteLine(@"You can specify the exact path to git by running: ");
@@ -145,7 +146,6 @@ private static void InstallTheApp(string pathToGit, bool silent)
Console.ReadLine();
return;
}
- pathToGit = "git"; // Still use PATH resolution to run the command
}
var target = new DirectoryInfo(Environment.ExpandEnvironmentVariables(@"%AppData%\GitCredStore"));
@@ -155,6 +155,10 @@ private static void InstallTheApp(string pathToGit, bool silent)
}
var dest = new FileInfo(Environment.ExpandEnvironmentVariables(@"%AppData%\GitCredStore\git-credential-winstore.exe"));
+ if (dest.Exists)
+ {
+ dest.Delete();
+ }
File.Copy(Assembly.GetExecutingAssembly().Location, dest.FullName, true);
Process.Start(pathToGit, string.Format("config --global credential.helper \"!'{0}'\"", dest.FullName));
Please sign in to comment.
Something went wrong with that request. Please try again.