code cleanup

This commit is contained in:
Hylke Bons 2010-05-27 11:14:56 +02:00
parent c0450a5112
commit 33331fe998
2 changed files with 24 additions and 18 deletions

View file

@ -121,12 +121,11 @@ namespace SparkleShare {
string RepoRemoteUrl = RemoteUrlCombo.Entry.Text; string RepoRemoteUrl = RemoteUrlCombo.Entry.Text;
// Check wheter a "/" or ":" is used to separate the
// repo name from the domain.
int SlashPos = RepoRemoteUrl.LastIndexOf ("/"); int SlashPos = RepoRemoteUrl.LastIndexOf ("/");
int ColumnPos = RepoRemoteUrl.LastIndexOf (":"); int ColumnPos = RepoRemoteUrl.LastIndexOf (":");
// Check wheter a "/" or ":" is used to separate the
// repo name from the domain.
string RepoName; string RepoName;
if (SlashPos > ColumnPos) if (SlashPos > ColumnPos)
RepoName = RepoRemoteUrl.Substring (SlashPos + 1); RepoName = RepoRemoteUrl.Substring (SlashPos + 1);
@ -145,15 +144,20 @@ namespace SparkleShare {
SparkleHelpers.CombineMore (RepoRemoteUrl, RepoName).Substring (2); SparkleHelpers.CombineMore (RepoRemoteUrl, RepoName).Substring (2);
SparkleBubble SparkleBubble = SparkleBubble SparkleBubble =
new SparkleBubble (_("Syncing ") + RepoName + "", new SparkleBubble (_("Syncing folder ") + RepoName + "",
_("SparkleShare will notify you when this is done.")); _("SparkleShare will notify you when this is done."));
SparkleBubble.IconName = "folder-sparkleshare"; SparkleBubble.IconName = "folder-sparkleshare";
Hide (); Hide ();
Process.WaitForExit ();
Process.Start (); Process.Start ();
string Output = Process.StandardOutput.ReadToEnd ();
if (Output.Contains ("fatal")) {
Console.WriteLine ("SOMETHING WENT WRONG!!!");
}
// Move the folder to the SparkleShare folder when done cloning // Move the folder to the SparkleShare folder when done cloning
Process.Exited += delegate { Process.Exited += delegate {
@ -165,7 +169,7 @@ namespace SparkleShare {
); );
SparkleBubble = SparkleBubble =
new SparkleBubble ("Successfully added the folder" + new SparkleBubble ("Successfully synced the folder" +
" " + RepoName + "", " " + RepoName + "",
"Now make great stuff happen!"); "Now make great stuff happen!");
@ -176,8 +180,7 @@ namespace SparkleShare {
SparkleHelpers.CombineMore ( SparkleHelpers.CombineMore (
SparklePaths.SparklePath, RepoName); SparklePaths.SparklePath, RepoName);
Process.Start(); Process.Start();
} ); } );
Destroy (); Destroy ();
}; };

View file

@ -57,20 +57,20 @@ namespace SparkleShare {
Process.StartInfo.FileName = "git"; Process.StartInfo.FileName = "git";
Process.StartInfo.Arguments = "config --get user.name"; Process.StartInfo.Arguments = "config --get user.name";
Process.Start(); Process.Start();
UserName = Process.StandardOutput.ReadToEnd().Trim (); UserName = Process.StandardOutput.ReadToEnd ().Trim ();
// Get user.email, example: "user@github.com" // Get user.email, example: "user@github.com"
UserEmail = "not.set@git-scm.com"; UserEmail = "not.set@git-scm.com";
Process.StartInfo.FileName = "git"; Process.StartInfo.FileName = "git";
Process.StartInfo.Arguments = "config --get user.email"; Process.StartInfo.Arguments = "config --get user.email";
Process.Start(); Process.Start();
UserEmail = Process.StandardOutput.ReadToEnd().Trim (); UserEmail = Process.StandardOutput.ReadToEnd ().Trim ();
// Get remote.origin.url, example: "ssh://git@github.com/user/repo" // Get remote.origin.url, example: "ssh://git@github.com/user/repo"
Process.StartInfo.FileName = "git"; Process.StartInfo.FileName = "git";
Process.StartInfo.Arguments = "config --get remote.origin.url"; Process.StartInfo.Arguments = "config --get remote.origin.url";
Process.Start(); Process.Start();
RemoteOriginUrl = Process.StandardOutput.ReadToEnd().Trim (); RemoteOriginUrl = Process.StandardOutput.ReadToEnd ().Trim ();
// Get the repository name, example: "Project" // Get the repository name, example: "Project"
Name = Path.GetFileName (LocalPath); Name = Path.GetFileName (LocalPath);
@ -87,7 +87,7 @@ namespace SparkleShare {
Process.StartInfo.FileName = "git"; Process.StartInfo.FileName = "git";
Process.StartInfo.Arguments = "rev-list --max-count=1 HEAD"; Process.StartInfo.Arguments = "rev-list --max-count=1 HEAD";
Process.Start(); Process.Start();
CurrentHash = Process.StandardOutput.ReadToEnd().Trim (); CurrentHash = Process.StandardOutput.ReadToEnd ().Trim ();
// Watch the repository's folder // Watch the repository's folder
Watcher = new FileSystemWatcher (LocalPath); Watcher = new FileSystemWatcher (LocalPath);
@ -213,7 +213,7 @@ namespace SparkleShare {
Console.WriteLine ("[Git][" + Name + "] Fetching changes... "); Console.WriteLine ("[Git][" + Name + "] Fetching changes... ");
Process.StartInfo.Arguments = "fetch -v"; Process.StartInfo.Arguments = "fetch -v";
Process.Start(); Process.Start();
string Output = Process.StandardOutput.ReadToEnd().Trim (); // TODO: This doesn't work :( string Output = Process.StandardOutput.ReadToEnd ().Trim (); // TODO: This doesn't work :(
Process.WaitForExit (); Process.WaitForExit ();
Console.WriteLine ("[Git][" + Name + "] Changes fetched."); Console.WriteLine ("[Git][" + Name + "] Changes fetched.");
if (!Output.Contains ("up to date")) if (!Output.Contains ("up to date"))
@ -232,7 +232,7 @@ namespace SparkleShare {
Process.WaitForExit (); Process.WaitForExit ();
Process.Start(); Process.Start();
Console.WriteLine ("[Git][" + Name + "] Changes rebased."); Console.WriteLine ("[Git][" + Name + "] Changes rebased.");
string Output = Process.StandardOutput.ReadToEnd().Trim (); string Output = Process.StandardOutput.ReadToEnd ().Trim ();
// Show notification if there are updates // Show notification if there are updates
if (!Output.Contains ("up to date")) { if (!Output.Contains ("up to date")) {
@ -244,7 +244,7 @@ namespace SparkleShare {
Process.StartInfo.Arguments = "status"; Process.StartInfo.Arguments = "status";
Process.WaitForExit (); Process.WaitForExit ();
Process.Start(); Process.Start();
Output = Process.StandardOutput.ReadToEnd().Trim (); Output = Process.StandardOutput.ReadToEnd ().Trim ();
foreach (string Line in Regex.Split (Output, "\n")) { foreach (string Line in Regex.Split (Output, "\n")) {
@ -297,17 +297,20 @@ namespace SparkleShare {
// Get the last committer e-mail // Get the last committer e-mail
Process.StartInfo.Arguments = "log --format=\"%ae\" -1"; Process.StartInfo.Arguments = "log --format=\"%ae\" -1";
Process.Start(); Process.Start();
string LastCommitEmail = Process.StandardOutput.ReadToEnd().Trim (); string LastCommitEmail =
Process.StandardOutput.ReadToEnd ().Trim ();
// Get the last commit message // Get the last commit message
Process.StartInfo.Arguments = "log --format=\"%s\" -1"; Process.StartInfo.Arguments = "log --format=\"%s\" -1";
Process.Start(); Process.Start();
string LastCommitMessage = Process.StandardOutput.ReadToEnd().Trim (); string LastCommitMessage =
Process.StandardOutput.ReadToEnd ().Trim ();
// Get the last commiter // Get the last commiter
Process.StartInfo.Arguments = "log --format=\"%an\" -1"; Process.StartInfo.Arguments = "log --format=\"%an\" -1";
Process.Start(); Process.Start();
string LastCommitUserName = Process.StandardOutput.ReadToEnd().Trim (); string LastCommitUserName =
Process.StandardOutput.ReadToEnd ().Trim ();
string NotifySettingFile = string NotifySettingFile =
SparkleHelpers.CombineMore (SparklePaths.SparkleConfigPath, SparkleHelpers.CombineMore (SparklePaths.SparkleConfigPath,
@ -365,7 +368,7 @@ namespace SparkleShare {
Process.StartInfo.Arguments = "status"; Process.StartInfo.Arguments = "status";
Process.Start(); Process.Start();
string Output = Process.StandardOutput.ReadToEnd(); string Output = Process.StandardOutput.ReadToEnd ();
foreach (string Line in Regex.Split (Output, "\n")) { foreach (string Line in Regex.Split (Output, "\n")) {
if (Line.IndexOf ("new file:") > -1) if (Line.IndexOf ("new file:") > -1)