diff --git a/SparkleLib/Git/SparkleFetcherGit.cs b/SparkleLib/Git/SparkleFetcherGit.cs index 4ab3b6ea..1ef1ef24 100755 --- a/SparkleLib/Git/SparkleFetcherGit.cs +++ b/SparkleLib/Git/SparkleFetcherGit.cs @@ -39,19 +39,15 @@ namespace SparkleLib.Git { return this.cached_salt; // Check if the repo's salt is stored in a branch... - SparkleGit git = new SparkleGit (TargetFolder, "branch -a"); - git.StartAndWaitForExit (); - - string [] branches = git.StartAndReadStandardOutput ().Split ("\n".ToCharArray ()); - Regex salt_regex = new Regex ("remotes/origin/salt-(.+)"); + SparkleGit git = new SparkleGit (TargetFolder, "ls-remote --heads"); + string branches = git.StartAndReadStandardOutput (); + Regex salt_regex = new Regex ("refs/heads/salt-([0-9a-f]+)"); - foreach (string branch in branches) { - Match salt_match = salt_regex.Match (branch); + Match salt_match = salt_regex.Match (branches); - if (salt_match.Success) { - this.cached_salt = salt_match.Groups [1].Value; - break; - } + if (salt_match.Success) { + this.cached_salt = salt_match.Groups [1].Value; + SparkleLogger.LogInfo ("SALT", salt_match.Groups [1].Value); } // ...if not, create a new salt for the repo @@ -179,9 +175,6 @@ namespace SparkleLib.Git { this.git.WaitForExit (); if (this.git.ExitCode == 0) { - SparkleGit git_fetch = new SparkleGit (TargetFolder, "fetch --all"); - git_fetch.StartAndWaitForExit (); - while (percentage < 100) { percentage += 25; diff --git a/SparkleLib/Git/SparkleRepoGit.cs b/SparkleLib/Git/SparkleRepoGit.cs index e427bc1e..0d50c8e3 100644 --- a/SparkleLib/Git/SparkleRepoGit.cs +++ b/SparkleLib/Git/SparkleRepoGit.cs @@ -284,7 +284,7 @@ namespace SparkleLib.Git { string salt_file_path = new string [] { LocalPath, ".git", "salt" }.Combine (); // If the repo is encrypted, create a branch to - // store the in and push it to the host + // store the salt in and push it to the host if (File.Exists (salt_file_path)) { string salt = File.ReadAllText (salt_file_path).Trim (); diff --git a/SparkleLib/SparkleWrappers.cs b/SparkleLib/SparkleWrappers.cs index b14e1d0f..ca108513 100644 --- a/SparkleLib/SparkleWrappers.cs +++ b/SparkleLib/SparkleWrappers.cs @@ -40,6 +40,32 @@ namespace SparkleLib { public Uri RemoteUrl; public List Changes = new List (); + + public string ToMessage () + { + string message = "added ‘{0}’"; + + switch (Changes [0].Type) { + case SparkleChangeType.Edited: message = "edited ‘{0}’"; break; + case SparkleChangeType.Deleted: message = "deleted ‘{0}’"; break; + case SparkleChangeType.Moved: message = "moved ‘{0}’"; break; + } + + if (Changes.Count == 1) { + return message = string.Format (message, Changes [0].Path); + + } else if (Changes.Count > 1) { + message = string.Format (message, Changes [0].Path); + + if ((Changes.Count - 1) == 1) + return string.Format (message + " and one other event", Changes.Count - 1); + else + return string.Format (message + " and {0} other events", Changes.Count - 1); + + } else { + return "did something magical"; + } + } }