fetcher git: fix crypto. 'git branch -a' doesn't always show all branches
This commit is contained in:
parent
8cdaebc142
commit
c45d883728
|
@ -39,19 +39,15 @@ namespace SparkleLib.Git {
|
||||||
return this.cached_salt;
|
return this.cached_salt;
|
||||||
|
|
||||||
// Check if the repo's salt is stored in a branch...
|
// Check if the repo's salt is stored in a branch...
|
||||||
SparkleGit git = new SparkleGit (TargetFolder, "branch -a");
|
SparkleGit git = new SparkleGit (TargetFolder, "ls-remote --heads");
|
||||||
git.StartAndWaitForExit ();
|
string branches = git.StartAndReadStandardOutput ();
|
||||||
|
Regex salt_regex = new Regex ("refs/heads/salt-([0-9a-f]+)");
|
||||||
string [] branches = git.StartAndReadStandardOutput ().Split ("\n".ToCharArray ());
|
|
||||||
Regex salt_regex = new Regex ("remotes/origin/salt-(.+)");
|
|
||||||
|
|
||||||
foreach (string branch in branches) {
|
Match salt_match = salt_regex.Match (branches);
|
||||||
Match salt_match = salt_regex.Match (branch);
|
|
||||||
|
|
||||||
if (salt_match.Success) {
|
if (salt_match.Success) {
|
||||||
this.cached_salt = salt_match.Groups [1].Value;
|
this.cached_salt = salt_match.Groups [1].Value;
|
||||||
break;
|
SparkleLogger.LogInfo ("SALT", salt_match.Groups [1].Value);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ...if not, create a new salt for the repo
|
// ...if not, create a new salt for the repo
|
||||||
|
@ -179,9 +175,6 @@ namespace SparkleLib.Git {
|
||||||
this.git.WaitForExit ();
|
this.git.WaitForExit ();
|
||||||
|
|
||||||
if (this.git.ExitCode == 0) {
|
if (this.git.ExitCode == 0) {
|
||||||
SparkleGit git_fetch = new SparkleGit (TargetFolder, "fetch --all");
|
|
||||||
git_fetch.StartAndWaitForExit ();
|
|
||||||
|
|
||||||
while (percentage < 100) {
|
while (percentage < 100) {
|
||||||
percentage += 25;
|
percentage += 25;
|
||||||
|
|
||||||
|
|
|
@ -284,7 +284,7 @@ namespace SparkleLib.Git {
|
||||||
string salt_file_path = new string [] { LocalPath, ".git", "salt" }.Combine ();
|
string salt_file_path = new string [] { LocalPath, ".git", "salt" }.Combine ();
|
||||||
|
|
||||||
// If the repo is encrypted, create a branch to
|
// 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)) {
|
if (File.Exists (salt_file_path)) {
|
||||||
string salt = File.ReadAllText (salt_file_path).Trim ();
|
string salt = File.ReadAllText (salt_file_path).Trim ();
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,32 @@ namespace SparkleLib {
|
||||||
public Uri RemoteUrl;
|
public Uri RemoteUrl;
|
||||||
|
|
||||||
public List<SparkleChange> Changes = new List<SparkleChange> ();
|
public List<SparkleChange> Changes = new List<SparkleChange> ();
|
||||||
|
|
||||||
|
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";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue