public void SaveRemote_should_update_settings(string remoteUrl, string remotePushUrl, string remotePuttySshKey) { var remote = new ConfigFileRemote { Name = "bla", Url = remoteUrl }; _remotesManager.SaveRemote(remote, remote.Name, remoteUrl, remotePushUrl, remotePuttySshKey); void Ensure(string setting, string value) { setting = string.Format(setting, remote.Name); if (!string.IsNullOrWhiteSpace(value)) { _module.Received(1).SetSetting(setting, value); } else { _module.Received(1).UnsetSetting(setting); } } Ensure(SettingKeyString.RemoteUrl, remoteUrl); Ensure(SettingKeyString.RemotePushUrl, remotePushUrl); Ensure(SettingKeyString.RemotePuttySshKey, remotePuttySshKey); }
public void RemoveRemote_success() { var remote = new ConfigFileRemote { Name = "bla" }; _remotesManager.RemoveRemote(remote); _module.Received(1).RemoveRemote(remote.Name); }
public void SaveRemote_populated_remote_should_require_update_if_remoteUrl_mismatch() { const string remoteName = "a"; const string remoteUrl = "b"; const string output = "yes!"; var gitRemote = new ConfigFileRemote { Name = "old", Url = "old" }; _module.RenameRemote(Arg.Any <string>(), Arg.Any <string>()).Returns(x => output); var result = _remotesManager.SaveRemote(gitRemote, remoteName, remoteUrl, null, null); result.UserMessage.Should().Be(output); result.ShouldUpdateRemote.Should().BeTrue(); _module.Received(1).RenameRemote(gitRemote.Name, remoteName); }
private void BindRemotesDropDown(string selectedRemoteName) { _NO_TRANSLATE_Remotes.SelectedIndexChanged -= RemotesUpdated; _NO_TRANSLATE_Remotes.TextUpdate -= RemotesUpdated; _NO_TRANSLATE_Remotes.Sorted = false; _NO_TRANSLATE_Remotes.DataSource = UserGitRemotes; _NO_TRANSLATE_Remotes.DisplayMember = nameof(ConfigFileRemote.Name); _NO_TRANSLATE_Remotes.SelectedIndex = -1; _NO_TRANSLATE_Remotes.SelectedIndexChanged += RemotesUpdated; _NO_TRANSLATE_Remotes.TextUpdate += RemotesUpdated; if (string.IsNullOrEmpty(selectedRemoteName)) { selectedRemoteName = Module.GetSetting(string.Format(SettingKeyString.BranchRemote, _currentBranchName)); } _currentBranchRemote = UserGitRemotes.FirstOrDefault(x => x.Name.Equals(selectedRemoteName, StringComparison.OrdinalIgnoreCase)); if (_currentBranchRemote != null) { _NO_TRANSLATE_Remotes.SelectedItem = _currentBranchRemote; } else if (UserGitRemotes.Any()) { var defaultRemote = UserGitRemotes.FirstOrDefault(x => x.Name.Equals("origin", StringComparison.OrdinalIgnoreCase)); // we couldn't find the default assigned remote for the selected branch // it is usually gets mapped via FormRemotes -> "default pull behavior" tab // so pick the default user remote if (defaultRemote == null) { _NO_TRANSLATE_Remotes.SelectedIndex = 0; } else { _NO_TRANSLATE_Remotes.SelectedItem = defaultRemote; } } else { _NO_TRANSLATE_Remotes.SelectedIndex = -1; } }
private void Remotes_SelectedIndexChanged(object sender, EventArgs e) { if (Remotes.SelectedIndices.Count > 0 && _selectedRemote == Remotes.SelectedItems[0].Tag) { return; } New.Enabled = Delete.Enabled = btnToggleState.Enabled = false; RemoteName.Text = string.Empty; Url.Text = string.Empty; comboBoxPushUrl.Text = string.Empty; checkBoxSepPushUrl.Checked = false; PuttySshKey.Text = string.Empty; gbMgtPanel.Text = _gbMgtPanelHeaderNew.Text; if (Remotes.SelectedIndices.Count < 1) { // we are here because we're adding a new remote - so no remotes selected // we just need to enable the panel so the user can enter the information _selectedRemote = null; flpnlRemoteManagement.Enabled = true; return; } // reset all controls and disable all buttons until we have a selection _selectedRemote = Remotes.SelectedItems[0].Tag as ConfigFileRemote; if (_selectedRemote == null) { return; } New.Enabled = Delete.Enabled = btnToggleState.Enabled = true; RemoteName.Text = _selectedRemote.Name; Url.Text = _selectedRemote.Url; comboBoxPushUrl.Text = _selectedRemote.PushUrl; checkBoxSepPushUrl.Checked = !string.IsNullOrEmpty(_selectedRemote.PushUrl); PuttySshKey.Text = _selectedRemote.PuttySshKey; gbMgtPanel.Text = _gbMgtPanelHeaderEdit.Text; BindBtnToggleState(_selectedRemote.Disabled); btnToggleState.Visible = true; flpnlRemoteManagement.Enabled = !_selectedRemote.Disabled; }
private void RemotesUpdated(object sender, EventArgs e) { _selectedRemote = _NO_TRANSLATE_Remotes.SelectedItem as ConfigFileRemote; if (_selectedRemote == null) { return; } if (TabControlTagBranch.SelectedTab == MultipleBranchTab) { UpdateMultiBranchView(); } EnableLoadSshButton(); // update the text box of the Remote Url combobox to show the URL of selected remote string pushUrl = _selectedRemote.PushUrl; if (string.IsNullOrEmpty(pushUrl)) { pushUrl = _selectedRemote.Url; } PushDestination.Text = pushUrl; if (string.IsNullOrEmpty(_NO_TRANSLATE_Branch.Text)) { // Doing this makes it pretty easy to accidentally create a branch on the remote. // But leaving it blank will do the 'default' thing, meaning all branches are pushed. // Solution: when pushing a branch that doesn't exist on the remote, ask what to do var currentBranch = new GitRef(Module, null, _currentBranchName, _selectedRemote.Name); _NO_TRANSLATE_Branch.Items.Add(currentBranch); _NO_TRANSLATE_Branch.SelectedItem = currentBranch; } BranchSelectedValueChanged(null, null); }