Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add an installer based on GitPad's installer

  • Loading branch information...
commit 9b4e7e0e189d033c0be6fd22f4361c5403f11063 1 parent f42006d
@paulcbetts authored
View
38 git-credential-winstore/Program.cs
@@ -1,12 +1,15 @@
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
+using System.Reflection;
using System.Text;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System.ComponentModel;
using System.Diagnostics;
using System.Threading;
+using System.Windows.Forms;
namespace Git.Credential.WinStore
{
@@ -23,9 +26,6 @@ static void Main(string[] args)
{
TryLaunchDebugger(ref args);
- // Read arguments
- IDictionary<string, string> parameters = ReadGitParameters();
-
// Parse command
Func<IDictionary<string, string>, IEnumerable<Tuple<string, string>>> command = null;
string cmd;
@@ -37,14 +37,14 @@ static void Main(string[] args)
// specified in key-value pairs.
cmd = parameters.GetOrDefault("cmd", "get");
#else
- WriteUsage();
+ InstallTheApp();
return;
#endif
}
- else
- {
- cmd = args[0];
- }
+
+ cmd = args[0];
+
+ IDictionary<string, string> parameters = ReadGitParameters();
if (!_commands.TryGetValue(cmd, out command))
{
@@ -54,6 +54,7 @@ static void Main(string[] args)
IDictionary<string, string> response = command(parameters).ToDictionary(
t => t.Item1,
t => t.Item2);
+
WriteGitParameters(response);
}
@@ -96,6 +97,27 @@ private static void WriteUsage()
Console.Error.WriteLine("See the following link for more info: http://www.manpagez.com/man/1/git-credential-cache/");
}
+ private static void InstallTheApp()
+ {
+ if (MessageBox.Show("Do you want to install git-credential-winstore to prompt for passwords?",
+ "Installing git-credential-winstore", MessageBoxButtons.YesNo) != DialogResult.Yes)
+ {
+ return;
+ }
+
+ var target = new DirectoryInfo(Environment.ExpandEnvironmentVariables(@"%AppData%\GitCredStore"));
+ if (!target.Exists)
+ {
+ target.Create();
+ }
+
+ var dest = new FileInfo(Environment.ExpandEnvironmentVariables(@"%AppData%\GitCredStore\git-credential-winstore.exe"));
+ File.Copy(Assembly.GetExecutingAssembly().Location, dest.FullName, true);
+
+ Process.Start("git", "config --global credential.helper !~/AppData/Roaming/GitCredStore/git-credential-winstore");
+ Environment.SetEnvironmentVariable("EDITOR", "~/AppData/Roaming/GitPad/GitPad.exe", EnvironmentVariableTarget.User);
@anurse
anurse added a note

This looks like a copypasta artifact from GitPad ;)

@paulcbetts Owner

hwhoops

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ }
+
static IEnumerable<Tuple<string, string>> GetCommand(IDictionary<string, string> args)
{
// Build the URL
View
1  git-credential-winstore/git-credential-winstore.csproj
@@ -36,6 +36,7 @@
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
+ <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />

1 comment on commit 9b4e7e0

@anurse

This looks like a copypasta artifact from GitPad ;)

@anurse

Other than the copypasta referenced above, looks good! Will merge after it's fixed.

Please sign in to comment.
Something went wrong with that request. Please try again.