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); }
public void Reset() { OnIsBusy.Reset(); OnIsNotBusy.Reset(); OnStatusUpdated.Reset(); OnLocksUpdated.Reset(); OnCurrentBranchUpdated.Reset(); OnCurrentRemoteUpdated.Reset(); OnHeadUpdated.Reset(); OnLocalBranchListUpdated.Reset(); OnRemoteBranchListUpdated.Reset(); OnLocalBranchUpdated.Reset(); OnLocalBranchAdded.Reset(); OnLocalBranchRemoved.Reset(); OnRemoteBranchAdded.Reset(); OnRemoteBranchRemoved.Reset(); OnGitUserLoaded.Reset(); }