Exemple #1
0
 public void Reset()
 {
     OnIsBusy.Reset();
     OnIsNotBusy.Reset();
     OnStatusUpdated.Reset();
     OnLocksUpdated.Reset();
     OnCurrentBranchAndRemoteUpdated.Reset();
     OnHeadUpdated.Reset();
     OnLocalBranchListUpdated.Reset();
     OnRemoteBranchListUpdated.Reset();
     OnLocalBranchUpdated.Reset();
     OnLocalBranchAdded.Reset();
     OnLocalBranchRemoved.Reset();
     OnRemoteBranchAdded.Reset();
     OnRemoteBranchRemoved.Reset();
 }
Exemple #2
0
        private void UpdateCurrentBranchAndRemote(string head)
        {
            ConfigBranch?branch = null;

            if (head.StartsWith("ref:"))
            {
                var branchName = head.Substring(head.IndexOf("refs/heads/") + "refs/heads/".Length);
                branch = config.GetBranch(branchName);

                if (!branch.HasValue)
                {
                    branch = new ConfigBranch {
                        Name = branchName
                    };
                }
            }

            var          defaultRemote = "origin";
            ConfigRemote?remote        = null;

            if (branch.HasValue && branch.Value.IsTracking)
            {
                remote = branch.Value.Remote;
            }

            if (!remote.HasValue)
            {
                remote = config.GetRemote(defaultRemote);
            }

            if (!remote.HasValue)
            {
                var configRemotes = config.GetRemotes().ToArray();
                if (configRemotes.Any())
                {
                    remote = configRemotes.FirstOrDefault();
                }
            }

            Logger.Trace("OnCurrentBranchUpdated: {0}", branch.HasValue ? branch.Value.ToString() : "[NULL]");
            Logger.Trace("OnCurrentRemoteUpdated: {0}", remote.HasValue ? remote.Value.ToString() : "[NULL]");
            OnCurrentBranchAndRemoteUpdated?.Invoke(branch, remote);
        }