Skip to content

Commit

Permalink
Version 1.2
Browse files Browse the repository at this point in the history
- Internal refactoring
- First search in KeePass on title "git [...lowercase last part of directory...][...lowercase computername...]"
  • Loading branch information
MircoBabin committed Nov 27, 2020
1 parent 213af08 commit 7e986f4
Show file tree
Hide file tree
Showing 15 changed files with 396 additions and 263 deletions.
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The minimum .NET framework required is 4.0.
Execute **git-credential-keepasscommand.exe** without parameters to view the help.

```
git-credential-keepasscommand 1.0
git-credential-keepasscommand 1.2
https://github.com/MircoBabin/GitCredentialsViaKeePassCommander - MIT license
git-credential-keepasscommand.exe is a credential helper for GIT.
Expand All @@ -25,7 +25,7 @@ It's purpose is to retrieve username/password credentials for GIT from KeePass u
INSTALLATION:
*** Place executable and config in same directory as KeePassCommandDll.dll
*** See KeePassCommander at https://github.com/MircoBabin/KeePassCommander
git config --global credential.helper "D:/Projects/GitCredentialsViaKeePassCommander/bin/Release/git-credential-keepasscommand.exe"
git config --global credential.helper "D:/KeePass/git-credential-keepasscommand.exe"
git config --system --list --show-origin
if there still is a credential.helper=manager listed, remove that
e.g. from C:/Program Files/Git/mingw64/etc/gitconfig remove [credential] helper=manager
Expand All @@ -34,8 +34,16 @@ UNINSTALL:
git config --global credential.helper manager
KeePass ENTRY:
In KeePass an entry containing username and password should be present with the following case-sensitive title (without quotes): "git [...lowercase last part of directoryname...]".
e.g. the rootdirectory of the GIT project is d:\projects\GitCredentialsViaKeePassCommander, then the KeePass title is exactly "git [gitcredentialsviakeepasscommander]
In KeePass an entry containing username and password should be present with the following case-sensitive title (without quotes): "git [...lowercase last part of directoryname...][...lowercase computername...]".
If this entry is not found, the following case-sensitive title (without quotes) should be present: "git [...lowercase last part of directoryname...]".
e.g. The rootdirectory of the GIT project is
d:\projects\GitCredentialsViaKeePassCommander
And the computername is MIRCONB.
Then the KeePass title must be exactly (without quotes):
"git [gitcredentialsviakeepasscommander][mirconb]", or
"git [gitcredentialsviakeepasscommander]".
```

Expand All @@ -47,9 +55,9 @@ e.g. the rootdirectory of the GIT project is d:\projects\GitCredentialsViaKeePas

# Entries in KeePass

Each project (GIT rootdirectory) must have an entry in KeePass. The title of the entry should be ```git [...lowercase last part of directoryname...]```. And the entry should contain the username and password to login.
Each project (GIT rootdirectory) must have an entry in KeePass. The title of the entry should be ```git [...lowercase last part of directoryname...][...lowercase computername...]``` or ```git [...lowercase last part of directoryname...]```. And the entry should contain the username and password to login.

E.g. the root of the GIT project is d:\projects\webpage\myportals (containing the subdirectory .git) then the title of the entry is ```git [myportals]```.
E.g. the root of the GIT project is d:\projects\webpage\myportals (containing the subdirectory .git) and the computername is mirconb then the title of the entry is ```git [myportals][mirconb]``` or ```git [myportals]```.

![ScreenshotEntries](screenshotentries.png)

Expand Down
Binary file removed assets/Release_1.1-debugpack.zip
Binary file not shown.
Binary file removed assets/Release_1.1.zip
Binary file not shown.
Binary file added assets/Release_1.2-debugpack.zip
Binary file not shown.
Binary file added assets/Release_1.2.zip
Binary file not shown.
4 changes: 2 additions & 2 deletions src/GlobalAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0")]
[assembly: AssemblyVersion("1.2.0.0")]
[assembly: AssemblyFileVersion("1.2.0")]
11 changes: 3 additions & 8 deletions src/git-credential-keepasscommand/NameValue.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace git_credential_keepasscommand
namespace git_credential_keepasscommand
{
public class NameValue
{
public string Name { get; set; }
public string Value { get; set; }
public string Name { get; }
public string Value { get; }

public NameValue(string Name, string Value)
{
Expand Down
51 changes: 51 additions & 0 deletions src/git-credential-keepasscommand/NameValuePairs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;

namespace git_credential_keepasscommand
{
public class NameValuePairs
{
public ReadOnlyCollection<NameValue> pairs { get; }

public NameValuePairs(ReadOnlyCollection<NameValue> pairs)
{
this.pairs = pairs;
}

public static NameValuePairs fromStdin()
{
//stdin contains input as name = value pairs.
var input = new List<NameValue>();

string stdin = String.Empty;
try
{
var isKeyAvailable = Console.KeyAvailable;
}
catch (InvalidOperationException)
{
//On a redirected stdin, there can't be a KeyAvailable
stdin = Console.In.ReadToEnd();
}

foreach (var line in stdin.Split('\n'))
{
var pos_is = line.IndexOf('=');
if (pos_is >= 0)
{
string name = String.Empty;
string value = String.Empty;

if (pos_is > 0) name = line.Substring(0, pos_is).Trim();
if (pos_is + 1 < line.Length) value = line.Substring(pos_is + 1).Trim();

input.Add(new NameValue(name, value));
}
}

return new NameValuePairs(input.AsReadOnly());
}
}
}
Loading

0 comments on commit 7e986f4

Please sign in to comment.