private void GetRemotes(List <GitRemote> allRemotes, bool enabled) { Func <string[]> func; if (enabled) { func = _module.GetRemotes; } else { func = GetDisabledRemotes; } var gitRemotes = func().Where(x => !string.IsNullOrWhiteSpace(x)).ToList(); if (gitRemotes.Any()) { allRemotes.AddRange(gitRemotes.Select(remote => new GitRemote { Disabled = !enabled, Name = remote, Url = _module.GetSetting(GetSettingKey(SettingKeyString.RemoteUrl, remote, enabled)), Push = _module.GetSettings(GetSettingKey(SettingKeyString.RemotePush, remote, enabled)).ToList(), PushUrl = _module.GetSetting(GetSettingKey(SettingKeyString.RemotePushUrl, remote, enabled)), PuttySshKey = _module.GetSetting(GetSettingKey(SettingKeyString.RemotePuttySshKey, remote, enabled)), })); } }
/// <summary> /// Loads the remotes from the .git/config. /// </summary> // TODO: candidate for Async implementations public void LoadRemotes() { if (_module == null) { return; } lock (SyncRoot) { Remotes.Clear(); var gitRemotes = _module.GetRemotes().Where(x => !string.IsNullOrWhiteSpace(x)).ToList(); if (gitRemotes.Any()) { var remotes = gitRemotes.Select(remote => new GitRemote { Name = remote, Url = _module.GetSetting(string.Format(SettingKeyString.RemoteUrl, remote)), Push = _module.GetSettings(string.Format(SettingKeyString.RemotePush, remote)).ToList(), PushUrl = _module.GetSetting(string.Format(SettingKeyString.RemotePushUrl, remote)), PuttySshKey = _module.GetSetting(string.Format(SettingKeyString.RemotePuttySshKey, remote)), }).ToList(); Remotes.AddAll(remotes.OrderBy(x => x.Name)); } } }