repo git: Encrypt user names and emails in history
This commit is contained in:
parent
41b4fa390d
commit
ee1a65cb68
|
@ -191,12 +191,11 @@ namespace Sparkles {
|
|||
RemoteUrl = new Uri (this.local_config.UrlByName (Name));
|
||||
IsBuffering = false;
|
||||
this.identifier = Identifier;
|
||||
ChangeSets = GetChangeSets ();
|
||||
|
||||
string storage_type = this.local_config.GetFolderOptionalAttribute (Name, "storage_type");
|
||||
|
||||
if (!string.IsNullOrEmpty (storage_type))
|
||||
StorageType = (StorageType) Enum.Parse(typeof(StorageType), storage_type);
|
||||
StorageType = (StorageType) Enum.Parse (typeof (StorageType), storage_type);
|
||||
|
||||
string is_paused = this.local_config.GetFolderOptionalAttribute (Name, "paused");
|
||||
if (is_paused != null && is_paused.Equals (bool.TrueString))
|
||||
|
@ -248,6 +247,8 @@ namespace Sparkles {
|
|||
|
||||
public void Initialize ()
|
||||
{
|
||||
ChangeSets = GetChangeSets ();
|
||||
|
||||
// Sync up everything that changed since we've been offline
|
||||
new Thread (() => {
|
||||
if (Status != SyncStatus.Paused) {
|
||||
|
|
|
@ -368,18 +368,30 @@ namespace Sparkles.Git {
|
|||
{
|
||||
GitCommand git;
|
||||
|
||||
string user_name = base.local_config.User.Name;
|
||||
string user_email = base.local_config.User.Email;
|
||||
|
||||
if (!this.user_is_set) {
|
||||
git = new GitCommand (LocalPath, "config user.name \"" + base.local_config.User.Name + "\"");
|
||||
git = new GitCommand (LocalPath, "config user.name \"" + user_name + "\"");
|
||||
git.StartAndWaitForExit ();
|
||||
|
||||
git = new GitCommand (LocalPath, "config user.email \"" + base.local_config.User.Email + "\"");
|
||||
git = new GitCommand (LocalPath, "config user.email \"" + user_email + "\"");
|
||||
git.StartAndWaitForExit ();
|
||||
|
||||
this.user_is_set = true;
|
||||
}
|
||||
|
||||
git = new GitCommand (LocalPath, "commit --all --message=\"" + message + "\" " +
|
||||
"--author=\"" + base.local_config.User.Name + " <" + base.local_config.User.Email + ">\"");
|
||||
if (StorageType == StorageType.Encrypted) {
|
||||
string password_file_path = Path.Combine (LocalPath, ".git", "info", "encryption_password");
|
||||
string password = File.ReadAllText (password_file_path);
|
||||
|
||||
user_name = user_name.AESEncrypt (password);
|
||||
user_email = user_email.AESEncrypt (password);
|
||||
}
|
||||
|
||||
git = new GitCommand (LocalPath,
|
||||
string.Format ("commit --all --message=\"{0}\" --author=\"{1} <{2}>\"",
|
||||
message, user_name, user_email));
|
||||
|
||||
git.StartAndReadStandardOutput ();
|
||||
}
|
||||
|
@ -706,6 +718,21 @@ namespace Sparkles.Git {
|
|||
|
||||
change_set.RemoteUrl = RemoteUrl;
|
||||
|
||||
if (StorageType == StorageType.Encrypted) {
|
||||
string password_file_path = Path.Combine (LocalPath, ".git", "info", "encryption_password");
|
||||
string password = File.ReadAllText (password_file_path);
|
||||
|
||||
try {
|
||||
change_set.User = new User (
|
||||
change_set.User.Name.AESDecrypt (password),
|
||||
change_set.User.Email.AESDecrypt (password));
|
||||
|
||||
} catch (Exception e) {
|
||||
Console.WriteLine (e.StackTrace);
|
||||
change_set.User = new User (match.Groups [2].Value, match.Groups [3].Value);
|
||||
}
|
||||
}
|
||||
|
||||
change_set.Timestamp = new DateTime (int.Parse (match.Groups [4].Value),
|
||||
int.Parse (match.Groups [5].Value), int.Parse (match.Groups [6].Value),
|
||||
int.Parse (match.Groups [7].Value), int.Parse (match.Groups [8].Value),
|
||||
|
|
Loading…
Reference in a new issue