public void RepoNameExtractorTest_ValidCurrentRemote(string remote, string url, string expProject, string expRepo)
        {
            _module.GetCurrentRemote().Returns(x => remote);
            _module.GetRemoteNames().Returns(x => new[] { remote, "    ", "\t" });
            _module.GetSetting(string.Format(SettingKeyString.RemoteUrl, remote)).Returns(x => url);

            var(project, repo) = _repoNameExtractor.Get();

            project.Should().Be(expProject);
            repo.Should().Be(expRepo);
        }
예제 #2
0
        public void LoadRemotes_should_not_populate_remotes_if_none()
        {
            _module.GetRemoteNames().Returns(x => Enumerable.Empty <string>());

            var remotes = _controller.LoadRemotes(true);

            remotes.Count().Should().Be(0);
            _module.Received(1).GetRemoteNames();
            _module.DidNotReceive().GetSetting(Arg.Any <string>());
            _module.DidNotReceive().GetSettings(Arg.Any <string>());
        }
예제 #3
0
        public void InitializeConfiguredParameters(IGitModule gitModule)
        {
            var firstRemoteName  = gitModule.GetRemoteNames().FirstOrDefault();
            var url              = gitModule.GetSetting(string.Format(SettingKeyString.RemoteUrl, firstRemoteName));
            var remoteHost       = !string.IsNullOrEmpty(url) ? new Uri(url).Host : DefaultGitLabHost;
            var gitLabHostParsed = $"https://{remoteHost}";

            GitLabClient = new Client.Client(
                gitLabHostParsed,
                Instance.OAuthToken.ValueOrDefault(Instance.Settings));
            AskForMergeRequestAfterPushValue = AskForMergeRequestAfterPush.ValueOrDefault(Settings);
        }
        private void Validate()
        {
            if (string.IsNullOrEmpty(Host))
            {
                throw new GerritSettingsException(_settingsErrorHostNotEntered.Text);
            }

            if (string.IsNullOrEmpty(Project))
            {
                throw new GerritSettingsException(_settingsErrorProjectNotEntered.Text);
            }

            var remotes = _module.GetRemoteNames();

            if (!remotes.Contains(DefaultRemote))
            {
                throw new GerritSettingsException(string.Format(_settingsErrorDefaultRemoteNotPresent.Text, DefaultRemote));
            }
        }