public bool Equals(ConfigBranch other) { return (String.Equals(name, other.name) && remote.Equals(other.remote) ); }
private static GitBranch GetLocalGitBranch(ConfigBranch x) { var branchName = x.Name; var trackingName = x.IsTracking ? x.Remote.Value.Name + "/" + branchName : null; return(new GitBranch(branchName, trackingName)); }
private GitBranch GetRemoteGitBranch(ConfigBranch x) { var name = x.Remote.Value.Name + "/" + x.Name; var trackingName = "[None]"; return(new GitBranch(name, trackingName, false)); }
public void UpdateData(IRepositoryInfoCacheData data) { var now = DateTimeOffset.Now; var isUpdated = false; if (!Nullable.Equals(currentGitRemote, data.CurrentGitRemote)) { currentGitRemote = data.CurrentGitRemote ?? GitRemote.Default; isUpdated = true; } if (!Nullable.Equals(currentGitBranch, data.CurrentGitBranch)) { currentGitBranch = data.CurrentGitBranch ?? GitBranch.Default; isUpdated = true; } if (!Nullable.Equals(currentConfigRemote, data.CurrentConfigRemote)) { currentConfigRemote = data.CurrentConfigRemote ?? ConfigRemote.Default; isUpdated = true; } if (!Nullable.Equals(currentConfigBranch, data.CurrentConfigBranch)) { currentConfigBranch = data.CurrentConfigBranch ?? ConfigBranch.Default; isUpdated = true; } SaveData(now, isUpdated); }
private static GitBranch GetLocalGitBranch(string currentBranchName, ConfigBranch x) { var branchName = x.Name; var trackingName = x.IsTracking ? x.Remote.Value.Name + "/" + branchName : "[None]"; return(new GitBranch(branchName, trackingName)); }
private GitBranch GetLocalGitBranch(ConfigBranch x) { var name = x.Name; var trackingName = x.IsTracking ? x.Remote.Value.Name + "/" + name : "[None]"; var isActive = name == CurrentBranchName; return(new GitBranch(name, trackingName, isActive)); }
private void AddLocalBranch(string name) { if (!branches.ContainsKey(name)) { var branch = config.GetBranch(name); if (!branch.HasValue) { branch = new ConfigBranch { Name = name }; } branches.Add(name, branch.Value); OnLocalBranchListChanged?.Invoke(); } }
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); }
private void UpdateLocalBranches(Dictionary <string, ConfigBranch> branches, NPath path, IEnumerable <ConfigBranch> configBranches, string prefix) { foreach (var file in path.Files()) { var branchName = prefix + file.FileName; var branch = configBranches.Where(x => x.Name == branchName).Select(x => x as ConfigBranch?).FirstOrDefault(); if (!branch.HasValue) { branch = new ConfigBranch(branchName); } branches.Add(branchName, branch.Value); } foreach (var dir in path.Directories()) { UpdateLocalBranches(branches, dir, configBranches, prefix + dir.FileName + "/"); } }
private void RepositoryManager_OnLocalBranchAdded(string name) { if (!localBranches.ContainsKey(name)) { var branch = repositoryManager.Config.GetBranch(name); if (!branch.HasValue) { branch = new ConfigBranch { Name = name }; } localBranches.Add(name, branch.Value); Logger.Trace("OnLocalBranchListChanged"); OnLocalBranchListChanged?.Invoke(); } else { Logger.Warning("Branch {0} is already present", name); } }
private void LoadBranchesFromConfig(NPath path, IEnumerable <ConfigBranch> configBranches, string prefix) { foreach (var file in path.Files()) { var branchName = prefix + file.FileName; var branch = configBranches.Where(x => x.Name == branchName).Select(x => x as ConfigBranch?).FirstOrDefault(); if (!branch.HasValue) { branch = new ConfigBranch { Name = branchName }; } branches.Add(branchName, branch.Value); } foreach (var dir in path.Directories()) { LoadBranchesFromConfig(dir, configBranches, prefix + dir.FileName + "/"); } }
private void GetCurrentBranchAndRemote(out ConfigBranch?branch, out ConfigRemote?remote) { branch = null; remote = null; var head = GetCurrentHead(); 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(branchName); } } var defaultRemote = "origin"; 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(); } } }
private static GitBranch GetRemoteGitBranch(ConfigBranch x) => new GitBranch(x.Remote.Value.Name + "/" + x.Name, "[None]");
private static GitBranch GetRemoteGitBranch(ConfigBranch x) { var name = x.Remote.Value.Name + "/" + x.Name; return(new GitBranch(name, "[None]", false)); }