コード例 #1
0
        private void SelectHostedRepositoryForCurrentRemote()
        {
            var currentRemote = Module.GetCurrentRemote();

            // Local branches have no current remote, return value is empty string.
            // In this case we fallback to the first remote in the list.
            // Currently, local git repo with no remote will show error message and can not open this dialog.
            // So there will always be at least 1 remote when this dialog is open
            _cloneGitProtocol = ThreadHelper.JoinableTaskFactory.Run(async() => (await Module.GetRemotesAsync())
                                                                     .First(r => string.IsNullOrEmpty(currentRemote) || r.Name == currentRemote).FetchUrl.IsUrlUsingHttp() ? GitProtocol.Https : GitProtocol.Ssh);
            var hostedRemote = _selectHostedRepoCB.Items.
                               Cast <IHostedRemote>().
                               FirstOrDefault(remote => remote.Name.Equals(currentRemote, StringComparison.OrdinalIgnoreCase));

            if (hostedRemote == null)
            {
                if (_selectHostedRepoCB.Items.Count > 0)
                {
                    _selectHostedRepoCB.SelectedIndex = 0;
                }
            }
            else
            {
                _selectHostedRepoCB.SelectedItem = hostedRemote;
            }
        }
コード例 #2
0
 public GitRepository(
     GitProtocol protocol,
     string endpoint,
     string identifier,
     string branch,
     string localDirectory,
     string head,
     string commit,
     IReadOnlyCollection <string> tags)
 {
     Protocol       = protocol;
     Endpoint       = endpoint;
     Identifier     = identifier;
     Branch         = branch;
     LocalDirectory = localDirectory;
     Head           = head;
     Commit         = commit;
     Tags           = tags;
 }
コード例 #3
0
        private void SelectHostedRepositoryForCurrentRemote()
        {
            var currentRemote = Module.GetCurrentRemote();

            _cloneGitProtocol = ThreadHelper.JoinableTaskFactory.Run(async() => (await Module.GetRemotesAsync())
                                                                     .First(r => r.Name == currentRemote).FetchUrl.IsUrlUsingHttp() ? GitProtocol.Https : GitProtocol.Ssh);
            var hostedRemote = _selectHostedRepoCB.Items.
                               Cast <IHostedRemote>().
                               FirstOrDefault(remote => remote.Name.Equals(currentRemote, StringComparison.OrdinalIgnoreCase));

            if (hostedRemote == null)
            {
                if (_selectHostedRepoCB.Items.Count > 0)
                {
                    _selectHostedRepoCB.SelectedIndex = 0;
                }
            }
            else
            {
                _selectHostedRepoCB.SelectedItem = hostedRemote;
            }
        }
コード例 #4
0
ファイル: GitRepositoryTest.cs プロジェクト: wgnf/nuke
        public void FromUrlProtocolTest(string url, GitProtocol protocol)
        {
            var repository = GitRepository.FromUrl(url);

            repository.Protocol.Should().Be(protocol);
        }