private void RepositoryManager_OnLocalBranchUpdated(string name) { if (name == currentBranch?.Name) { Logger.Trace("OnCurrentBranchUpdated: {0}", name); OnCurrentBranchUpdated?.Invoke(); Refresh(); } }
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]"); OnCurrentBranchUpdated?.Invoke(branch); Logger.Trace("OnCurrentRemoteUpdated: {0}", remote.HasValue ? remote.Value.ToString() : "[NULL]"); OnCurrentRemoteUpdated?.Invoke(remote); }