From 8ac8fee9122b207c26e64c0aa2e73bf9c6807ac5 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Wed, 20 Apr 2011 16:32:34 +0200 Subject: [PATCH] [repo] don't rely on Git# for username, email and remote url --- SparkleLib/SparkleRepo.cs | 47 +++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/SparkleLib/SparkleRepo.cs b/SparkleLib/SparkleRepo.cs index 6f67428d..c2d9bb18 100644 --- a/SparkleLib/SparkleRepo.cs +++ b/SparkleLib/SparkleRepo.cs @@ -138,12 +138,12 @@ namespace SparkleLib { LocalPath = path; Name = Path.GetFileName (LocalPath); - RemoteOriginUrl = Config ["remote.origin.url"]; + RemoteOriginUrl = GetRemoteOriginUrl (); RemoteName = Path.GetFileNameWithoutExtension (RemoteOriginUrl); Domain = GetDomain (RemoteOriginUrl); Description = GetDescription (); - UserName = Config ["user.name"]; - UserEmail = Config ["user.email"]; + UserName = GetUserName (); + UserEmail = GetUserEmail (); if (Head.CurrentCommit == null) _CurrentHash = null; @@ -704,7 +704,46 @@ namespace SparkleLib { return description; } - + + + private string GetRemoteOriginUrl () + { + SparkleGit git = new SparkleGit (LocalPath, "config --get remote.origin.url"); + git.Start (); + git.WaitForExit (); + + string output = git.StandardOutput.ReadToEnd (); + string url = output.Trim (); + + return url; + } + + + private string GetUserName () + { + SparkleGit git = new SparkleGit (LocalPath, "config --get user.name"); + git.Start (); + git.WaitForExit (); + + string output = git.StandardOutput.ReadToEnd (); + string user_name = output.Trim (); + + return user_name; + } + + + private string GetUserEmail () + { + SparkleGit git = new SparkleGit (LocalPath, "config --get user.email"); + git.Start (); + git.WaitForExit (); + + string output = git.StandardOutput.ReadToEnd (); + string user_email = output.Trim (); + + return user_email; + } + // Recursively gets a folder's size in bytes private double CalculateFolderSize (DirectoryInfo parent)