Example #1
0
        public static Settings Parse(IVsrModule gitModule, ISettingsSource settings, BitbucketPlugin plugin)
        {
            var result = new Settings
            {
                Username     = plugin.BitbucketUsername.ValueOrDefault(settings),
                Password     = plugin.BitbucketPassword.ValueOrDefault(settings),
                BitbucketUrl = plugin.BitbucketBaseUrl.ValueOrDefault(settings),
                DisableSSL   = plugin.BitbucketDisableSsl.ValueOrDefault(settings)
            };

            var module = (VsrModule)gitModule;

            var remotes = module.GetRemoteNames()
                          .Where(s => !string.IsNullOrWhiteSpace(s))
                          .Distinct()
                          .Select(r => module.GetSetting(string.Format(SettingKeyString.RemoteUrl, r)))
                          .ToArray();

            foreach (var url in remotes)
            {
                var pattern = url.Contains("http") ? BitbucketHttpRegex : BitbucketSshRegex;
                var match   = Regex.Match(url, pattern);
                if (match.Success && result.BitbucketUrl.Contains(match.Groups["url"].Value))
                {
                    result.ProjectKey = match.Groups["project"].Value;
                    result.RepoSlug   = match.Groups["repo"].Value;
                    return(result);
                }
            }

            return(null);
        }
        public BitbucketPullRequestForm(BitbucketPlugin plugin, ISettingsSource settings, GitUIBaseEventArgs gitUiCommands)
        {
            InitializeComponent();
            Translate();

            _plugin            = plugin;
            _settingsContainer = settings;
            _gitUiCommands     = gitUiCommands;

            _settings = Settings.Parse(_gitUiCommands.GitModule, _settingsContainer, _plugin);
            if (_settings == null)
            {
                MessageBox.Show(_yourRepositoryIsNotInBitbucket.Text);
                Close();
                return;
            }
            Load += BitbucketViewPullRequestFormLoad;
            Load += BitbucketPullRequestFormLoad;

            lblLinkCreatePull.Text = string.Format("{0}/projects/{1}/repos/{2}/pull-requests?create",
                                                   _settings.BitbucketUrl, _settings.ProjectKey, _settings.RepoSlug);
            toolTipLink.SetToolTip(lblLinkCreatePull, _linkLabelToolTip.Text);

            lblLinkViewPull.Text = string.Format("{0}/projects/{1}/repos/{2}/pull-requests",
                                                 _settings.BitbucketUrl, _settings.ProjectKey, _settings.RepoSlug);
            toolTipLink.SetToolTip(lblLinkViewPull, _linkLabelToolTip.Text);
        }
        public BitbucketPullRequestForm(BitbucketPlugin plugin, ISettingsSource settings, GitUIBaseEventArgs gitUiCommands)
        {
            InitializeComponent();
            Translate();

            // NOTE ddlBranchSource and ddlBranchTarget both have string items so do not need a display member
            ddlRepositorySource.DisplayMember = nameof(Repository.DisplayName);
            ddlRepositoryTarget.DisplayMember = nameof(Repository.DisplayName);

            _settings = Settings.Parse(gitUiCommands.GitModule, settings, plugin);
            if (_settings == null)
            {
                MessageBox.Show(_yourRepositoryIsNotInBitbucket.Text);
                Close();
                return;
            }

            Load += BitbucketViewPullRequestFormLoad;
            Load += BitbucketPullRequestFormLoad;

            lblLinkCreatePull.Text = string.Format("{0}/projects/{1}/repos/{2}/pull-requests?create",
                                                   _settings.BitbucketUrl, _settings.ProjectKey, _settings.RepoSlug);
            toolTipLink.SetToolTip(lblLinkCreatePull, _linkLabelToolTip.Text);

            lblLinkViewPull.Text = string.Format("{0}/projects/{1}/repos/{2}/pull-requests",
                                                 _settings.BitbucketUrl, _settings.ProjectKey, _settings.RepoSlug);
            toolTipLink.SetToolTip(lblLinkViewPull, _linkLabelToolTip.Text);

            this.AdjustForDpiScaling();
        }
Example #4
0
        public BitbucketPullRequestForm(BitbucketPlugin plugin, ISettingsSource settings, GitUIBaseEventArgs gitUiCommands)
        {
            InitializeComponent();
            Translate();

            _plugin            = plugin;
            _settingsContainer = settings;
            _gitUiCommands     = gitUiCommands;
        }
Example #5
0
        public BitbucketPullRequestForm(BitbucketPlugin plugin, ISettingsSource settings, GitUIBaseEventArgs gitUiCommands)
        {
            InitializeComponent();
            Translate();

            _plugin            = plugin;
            _settingsContainer = settings;
            _gitUiCommands     = gitUiCommands;
            //TODO Retrieve all users and set default reviewers
            ReviewersDataGrid.Visible = false;
        }