Skip to content

Commit

Permalink
Add an installer based on GitPad's installer
Browse files Browse the repository at this point in the history
  • Loading branch information
anaisbetts committed Apr 17, 2012
1 parent f42006d commit 9b4e7e0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
38 changes: 30 additions & 8 deletions git-credential-winstore/Program.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -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;
Expand All @@ -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))
{
Expand All @@ -54,6 +54,7 @@ static void Main(string[] args)
IDictionary<string, string> response = command(parameters).ToDictionary(
t => t.Item1,
t => t.Item2);

WriteGitParameters(response);
}

Expand Down Expand Up @@ -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);

This comment has been minimized.

Copy link
@analogrelay

analogrelay Apr 17, 2012

This looks like a copypasta artifact from GitPad ;)

This comment has been minimized.

Copy link
@anaisbetts

anaisbetts Apr 17, 2012

Author Owner

hwhoops

}

static IEnumerable<Tuple<string, string>> GetCommand(IDictionary<string, string> args)
{
// Build the URL
Expand Down
1 change: 1 addition & 0 deletions git-credential-winstore/git-credential-winstore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down

1 comment on commit 9b4e7e0

@analogrelay
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Please sign in to comment.