git: Prefer remote SparkleShare branch if it exists

This commit is contained in:
Hylke Bons 2016-04-02 10:59:36 +01:00
parent 1e79d8c89b
commit 4018bfc19c

View file

@ -233,8 +233,18 @@ namespace Sparkles.Git {
public override void Complete ()
{
if (!IsFetchedRepoEmpty) {
GitCommand git = new GitCommand (TargetFolder, "checkout --quiet HEAD");
git.StartAndWaitForExit ();
string branch = "HEAD";
string prefered_branch = "SparkleShare";
// Prefer the "SparkleShare" branch if it exists
var git_show_ref = new GitCommand (TargetFolder, "show-ref --verify --quiet refs/heads/" + prefered_branch);
git_show_ref.StartAndWaitForExit ();
if (git_show_ref.ExitCode == 0)
branch = prefered_branch;
var git_checkout = new GitCommand (TargetFolder, "checkout --quiet " + branch);
git_checkout.StartAndWaitForExit ();
}
base.Complete ();