public DeleteUnusedBranchesForm(DeleteUnusedBranchesFormSettings settings, IVsrModule gitCommands, IGitUICommands gitUiCommands, IGitPlugin gitPlugin)
        {
            _settings            = settings;
            _gitCommands         = gitCommands;
            _gitUiCommands       = gitUiCommands;
            _gitPlugin           = gitPlugin;
            _commandOutputParser = new GitBranchOutputCommandParser();

            InitializeComponent();

            _NO_TRANSLATE_deleteDataGridViewCheckBoxColumn.Width = DpiUtil.Scale(50);
            dateDataGridViewTextBoxColumn.Width = DpiUtil.Scale(175);
            Author.Width = DpiUtil.Scale(91);

            imgLoading.Image = Resources.loadingpanel;

            _NO_TRANSLATE_deleteDataGridViewCheckBoxColumn.DataPropertyName = nameof(Branch.Delete);
            nameDataGridViewTextBoxColumn.DataPropertyName = nameof(Branch.Name);
            dateDataGridViewTextBoxColumn.DataPropertyName = nameof(Branch.Date);
            Author.DataPropertyName  = nameof(Branch.Author);
            Message.DataPropertyName = nameof(Branch.Message);

            InitializeComplete();

            if (gitUiCommands == null)
            {
                return;
            }

            ThreadHelper.JoinableTaskFactory.RunAsync(() => RefreshObsoleteBranchesAsync());
        }
Esempio n. 2
0
            private static IReadOnlyList <GitItemStatus> GetStatusChangedFiles(IVsrModule module)
            {
                var cmd    = GitCommandHelpers.GetAllChangedFilesCmd(true, UntrackedFilesMode.Default, noLocks: true);
                var output = module.GitExecutable.GetOutput(cmd);

                return(GitCommandHelpers.GetStatusChangedFilesFromString(module, output));
            }
Esempio n. 3
0
        public BitbucketPullRequestForm([CanBeNull] Settings settings, IVsrModule module)
        {
            InitializeComponent();

            // 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 ?? new Settings();

            Load += delegate
            {
                ReloadPullRequests();
                ReloadRepositories();
            };

            if (module != null)
            {
                var repoUrl = _NO_TRANSLATE_RepoUrl = string.Format(_NO_TRANSLATE_RepoUrl,
                                                                    _settings.BitbucketUrl, _settings.ProjectKey, _settings.RepoSlug);
                var branch = GitCommands.GitRefName.GetFullBranchName(module.GetSelectedBranch());

                _NO_TRANSLATE_lblLinkCreatePull.Text = repoUrl +
                                                       ((string.IsNullOrEmpty(branch) || branch.Equals(DetachedHeadParser.DetachedBranch)) ?
                                                        _NO_TRANSLATE_LinkCreatePullNoBranch :
                                                        string.Format(_NO_TRANSLATE_LinkCreatePull, branch));
                toolTipLink.SetToolTip(_NO_TRANSLATE_lblLinkCreatePull, _linkLabelToolTip.Text);

                _NO_TRANSLATE_lblLinkViewPull.Text = repoUrl + _NO_TRANSLATE_LinkViewPull;
                toolTipLink.SetToolTip(_NO_TRANSLATE_lblLinkViewPull, _linkLabelToolTip.Text);
            }

            InitializeComplete();
        }
Esempio n. 4
0
        public FormGitStatistics(IVsrModule module, string codeFilePattern, bool countSubmodules)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            _module          = module;
            _codeFilePattern = codeFilePattern;
            _countSubmodules = countSubmodules;
            InitializeComponent();

            splitContainer1.SplitterDistance = DpiUtil.Scale(splitContainer1.SplitterDistance);
            splitContainer2.SplitterDistance = DpiUtil.Scale(splitContainer2.SplitterDistance);
            splitContainer3.SplitterDistance = DpiUtil.Scale(splitContainer3.SplitterDistance);
            splitContainer4.SplitterDistance = DpiUtil.Scale(splitContainer4.SplitterDistance);
            splitContainer5.SplitterDistance = DpiUtil.Scale(splitContainer5.SplitterDistance);
            splitContainer6.SplitterDistance = DpiUtil.Scale(splitContainer6.SplitterDistance);
            splitContainer7.SplitterDistance = DpiUtil.Scale(splitContainer7.SplitterDistance);
            splitContainer8.SplitterDistance = DpiUtil.Scale(splitContainer8.SplitterDistance);

            TotalLinesOfCode.Font     = new Font(TotalLinesOfCode.Font, FontStyle.Bold);
            TotalLinesOfCode2.Font    = TotalLinesOfCode.Font;
            TotalLinesOfTestCode.Font = TotalLinesOfCode.Font;
            TotalCommits.Font         = TotalLinesOfCode.Font;
            LoadingLabel.Font         = TotalLinesOfCode.Font;

            InitializeComplete();
        }
Esempio n. 5
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 void Setup()
        {
            _configFile = Substitute.For <IConfigFileSettings>();

            _module = Substitute.For <IVsrModule>();
            _module.LocalConfigFile.Returns(_configFile);
            _repoNameExtractor = new RepoNameExtractor(() => _module);
        }
Esempio n. 7
0
        public void Setup()
        {
            _module      = Substitute.For <IVsrModule>();
            _getModule   = () => _module;
            _linkFactory = Substitute.For <ILinkFactory>();

            _renderer     = new CommitDataBodyRenderer(_getModule, _linkFactory);
            _rendererReal = new CommitDataBodyRenderer(_getModule, new LinkFactory());
        }
Esempio n. 8
0
        public void Setup()
        {
            _module = Substitute.For <IVsrModule>();
            _module.ReEncodeStringFromLossless(Arg.Any <string>()).Returns(x => x[0]);
            _module.ReEncodeCommitMessage(Arg.Any <string>(), Arg.Any <string>()).Returns(x => x[0]);

            _getModule         = () => _module;
            _commitDataManager = new CommitDataManager(_getModule);
        }
        public void Setup()
        {
            _configFile = Substitute.For <IConfigFileSettings>();

            _module = Substitute.For <IVsrModule>();
            _module.LocalConfigFile.Returns(_configFile);

            _remotesManager = new ConfigFileRemoteSettingsManager(() => _module);
        }
Esempio n. 10
0
 public override void Register(IGitUICommands gitUiCommands)
 {
     base.Register(gitUiCommands);
     _gitModule = gitUiCommands.VsrModule;
     gitUiCommands.PostSettings          += gitUiCommands_PostSettings;
     gitUiCommands.PreCommit             += gitUiCommands_PreCommit;
     gitUiCommands.PostCommit            += gitUiCommands_PostRepositoryChanged;
     gitUiCommands.PostRepositoryChanged += gitUiCommands_PostRepositoryChanged;
     UpdateJiraSettings();
 }
Esempio n. 11
0
        public ProxySwitcherForm(ProxySwitcherPlugin plugin, ISettingsSource settings, GitUIEventArgs gitUiCommands)
        {
            InitializeComponent();
            InitializeComplete();

            Text         = _pluginDescription.Text;
            _plugin      = plugin;
            _settings    = settings;
            _gitCommands = gitUiCommands.VsrModule;
        }
        public void Setup()
        {
            _module = Substitute.For <IVsrModule>();

            _fullPathResolver = Substitute.For <IFullPathResolver>();

            _file       = Substitute.For <FileBase>();
            _fileSystem = Substitute.For <IFileSystem>();
            _fileSystem.File.Returns(_file);
            _manager = new CommitTemplateManager(_module, _fullPathResolver, _fileSystem);
        }
Esempio n. 13
0
 /// <summary>
 /// Parse the output from git-status --porcelain=2 -z
 /// Note that the caller should check for fatal errors in the Git output
 /// </summary>
 /// <param name="module">The Git module</param>
 /// <param name="statusString">output from the git command</param>
 /// <returns>list with the parsed GitItemStatus</returns>
 /// <seealso href="https://git-scm.com/docs/git-status"/>
 public static IReadOnlyList <GitItemStatus> GetStatusChangedFilesFromString(IVsrModule module, string statusString)
 {
     if (VsrVersion.Current.SupportStatusPorcelainV2)
     {
         return(GetAllChangedFilesFromString_v2(statusString));
     }
     else
     {
         return(GetAllChangedFilesFromString_v1(module, statusString, false, StagedStatus.Unset));
     }
 }
Esempio n. 14
0
 public FormImpact(IVsrModule module)
 {
     InitializeComponent();
     InitializeComplete();
     UpdateAuthorInfo("");
     if (module != null)
     {
         Impact.Init(module);
         Impact.UpdateData();
         Impact.Invalidated += Impact_Invalidated;
     }
 }
        private static void UpdateSettings(IVsrModule module, string remoteName, bool remoteDisabled, string settingName, string value)
        {
            var prefix          = remoteDisabled ? DisabledSectionPrefix : string.Empty;
            var fullSettingName = prefix + string.Format(settingName, remoteName);

            if (!string.IsNullOrWhiteSpace(value))
            {
                module.SetSetting(fullSettingName, value);
            }
            else
            {
                module.UnsetSetting(fullSettingName);
            }
        }
Esempio n. 16
0
        public void Setup()
        {
            _module = Substitute.For <IVsrModule>();
            _module.LocalConfigFile.Returns(Substitute.For <IConfigFileSettings>());

            _refs = new IGitRef[]
            {
                new GitRef(_module, ObjectId.Random(), $"{GitRefName.RefsTagsPrefix}tag1"),
                new GitRef(_module, ObjectId.Random(), $"{GitRefName.RefsHeadsPrefix}branch1"),
                new GitRef(_module, ObjectId.Random(), $"{GitRefName.RefsRemotesPrefix}branch1"),
            };
            _revision = new GitRevision(ObjectId.Random())
            {
                Refs = _refs
            };
        }
Esempio n. 17
0
        public void Setup()
        {
            _gitFile       = Path.Combine(_workingDir, ".git");
            _gitWorkingDir = _gitFile.EnsureTrailingPathSeparator();
            _indexLockFile = Path.Combine(_gitWorkingDir, IndexLock);

            _file       = Substitute.For <FileBase>();
            _directory  = Substitute.For <DirectoryBase>();
            _fileSystem = Substitute.For <IFileSystem>();
            _fileSystem.Directory.Returns(_directory);
            _fileSystem.File.Returns(_file);

            _module = Substitute.For <IVsrModule>();
            _module.WorkingDir.Returns(_workingDir);

            _gitDirectoryResolver = Substitute.For <IGitDirectoryResolver>();
            _gitDirectoryResolver.Resolve(_workingDir).Returns(_gitWorkingDir);

            _manager = new IndexLockManager(_module, _gitDirectoryResolver, _fileSystem);
        }
Esempio n. 18
0
        public void Setup()
        {
            if (_referenceRepository == null)
            {
                _referenceRepository = new ReferenceRepository();
            }
            else
            {
                _referenceRepository.Reset();
            }

            _uiCommands = new GitUICommands(_referenceRepository.Module);

            _module = Substitute.For <IVsrModule>();
            _module.GetCurrentRemote().ReturnsForAnyArgs("origin");
            _module.GetCurrentCheckout().ReturnsForAnyArgs(ObjectId.WorkTreeId);
            _exampleScript = ScriptManager.GetScript(_keyOfExampleScript);
            _exampleScript.AskConfirmation = false; // avoid any dialogs popping up
            _exampleScript.RunInBackground = true;  // avoid any dialogs popping up
        }
Esempio n. 19
0
        private static GitRevision GetCurrentRevision(
            [NotNull] IVsrModule module, [CanBeNull] IScriptHostControl scriptHostControl, List <IGitRef> currentTags, List <IGitRef> currentLocalBranches,
            List <IGitRef> currentRemoteBranches, List <IGitRef> currentBranches)
        {
            GitRevision           currentRevision;
            IEnumerable <IGitRef> refs;

            if (scriptHostControl == null)
            {
                var currentRevisionGuid = module.GetCurrentCheckout();
                currentRevision = currentRevisionGuid == null ? null : new GitRevision(currentRevisionGuid);
                refs            = module.GetRefs(true, true).Where(gitRef => gitRef.ObjectId == currentRevisionGuid);
            }
            else
            {
                currentRevision = scriptHostControl.GetCurrentRevision();
                refs            = currentRevision?.Refs ?? Array.Empty <IGitRef>();
            }

            foreach (var gitRef in refs)
            {
                if (gitRef.IsTag)
                {
                    currentTags.Add(gitRef);
                }
                else if (gitRef.IsHead || gitRef.IsRemote)
                {
                    currentBranches.Add(gitRef);
                    if (gitRef.IsRemote)
                    {
                        currentRemoteBranches.Add(gitRef);
                    }
                    else
                    {
                        currentLocalBranches.Add(gitRef);
                    }
                }
            }

            return(currentRevision);
        }
Esempio n. 20
0
 private void SetTopProjectSubmoduleInfo(SubmoduleInfoResult result,
                                         string noBranchText,
                                         IVsrModule topProject,
                                         bool isParentTopProject,
                                         bool isCurrentTopProject)
 {
     if (isParentTopProject && !isCurrentTopProject)
     {
         result.TopProject = result.SuperProject;
     }
     else
     {
         string path = topProject.WorkingDir;
         string name = Directory.Exists(path) ?
                       Path.GetFileName(Path.GetDirectoryName(path)) + GetBranchNameSuffix(path, noBranchText) :
                       path;
         result.TopProject = new SubmoduleInfo {
             Text = name, Path = path, Bold = isCurrentTopProject
         };
     }
 }
Esempio n. 21
0
        public bool ProcessRevisionSelectionChange(IVsrModule currentModule, IReadOnlyCollection <GitRevision> selectedRevisions)
        {
            if (selectedRevisions.Count > 1)
            {
                return(false);
            }

            var revision = selectedRevisions.FirstOrDefault();

            var changed = !string.Equals(revision?.AuthorEmail, AuthorEmailToHighlight, StringComparison.OrdinalIgnoreCase);

            if (changed)
            {
                AuthorEmailToHighlight = revision != null
                    ? revision.AuthorEmail
                    : currentModule.GetEffectiveSetting(SettingKeyString.UserEmail);
                return(true);
            }

            return(false);
        }
Esempio n. 22
0
        public FindLargeFilesForm(float threshold, GitUIEventArgs gitUiEventArgs)
        {
            InitializeComponent();

            sHADataGridViewTextBoxColumn.Width            = DpiUtil.Scale(54);
            sizeDataGridViewTextBoxColumn.Width           = DpiUtil.Scale(52);
            commitCountDataGridViewTextBoxColumn.Width    = DpiUtil.Scale(88);
            lastCommitDateDataGridViewTextBoxColumn.Width = DpiUtil.Scale(103);

            InitializeComplete();

            sHADataGridViewTextBoxColumn.DataPropertyName  = nameof(GitObject.SHA);
            pathDataGridViewTextBoxColumn.DataPropertyName = nameof(GitObject.Path);
            sizeDataGridViewTextBoxColumn.DataPropertyName = nameof(GitObject.Size);
            CompressedSize.DataPropertyName = nameof(GitObject.CompressedSize);
            commitCountDataGridViewTextBoxColumn.DataPropertyName    = nameof(GitObject.CommitCount);
            lastCommitDateDataGridViewTextBoxColumn.DataPropertyName = nameof(GitObject.LastCommitDate);
            dataGridViewCheckBoxColumn1.DataPropertyName             = nameof(GitObject.Delete);

            _threshold     = threshold;
            _gitUiCommands = gitUiEventArgs;
            _gitCommands   = gitUiEventArgs?.VsrModule;
        }
Esempio n. 23
0
        public static CommandStatus RunScript(IWin32Window owner, IVsrModule module, string scriptKey, IGitUICommands uiCommands,
                                              RevisionGridControl revisionGrid, Action <string> showError)
        {
            if (string.IsNullOrEmpty(scriptKey))
            {
                return(false);
            }

            var script = ScriptManager.GetScript(scriptKey);

            if (script == null)
            {
                showError("Cannot find script: " + scriptKey);
                return(false);
            }

            if (string.IsNullOrEmpty(script.Command))
            {
                return(false);
            }

            string arguments = script.Arguments;

            if (!string.IsNullOrEmpty(arguments) && revisionGrid == null)
            {
                string optionDependingOnSelectedRevision
                    = ScriptOptionsParser.Options.FirstOrDefault(option => ScriptOptionsParser.DependsOnSelectedRevision(option) &&
                                                                 ScriptOptionsParser.Contains(arguments, option));
                if (optionDependingOnSelectedRevision != null)
                {
                    showError($"Option {optionDependingOnSelectedRevision} is only supported when started with revision grid available.");
                    return(false);
                }
            }

            return(RunScript(owner, module, script, uiCommands, revisionGrid, showError));
        }
Esempio n. 24
0
        /// <summary>
        /// This function always at least sets result.TopProject
        /// </summary>
        /// <param name="result">submodule info</param>
        /// <param name="noBranchText">text with no branches</param>
        private void GetSuperProjectRepositorySubmodulesStructure(VsrModule currentModule, SubmoduleInfoResult result, string noBranchText)
        {
            bool isCurrentTopProject = currentModule.SuperprojectModule == null;

            if (isCurrentTopProject)
            {
                SetTopProjectSubmoduleInfo(result, noBranchText, result.Module, false, isCurrentTopProject);

                return;
            }

            IVsrModule topProject = currentModule.SuperprojectModule.GetTopModule();

            bool isParentTopProject = currentModule.SuperprojectModule.WorkingDir == topProject.WorkingDir;

            // Set result.SuperProject
            SetSuperProjectSubmoduleInfo(currentModule.SuperprojectModule, result, noBranchText, topProject, isParentTopProject);

            // Set result.TopProject
            SetTopProjectSubmoduleInfo(result, noBranchText, topProject, isParentTopProject, isCurrentTopProject);

            // Set result.CurrentSubmoduleName and populate result.SuperSubmodules
            SetSubmoduleData(currentModule, result, noBranchText, topProject);
        }
        public void LoadRemotes_should_not_throw_if_module_is_null()
        {
            _module = null;

            ((Action)(() => _remotesManager.LoadRemotes(true))).Should().NotThrow();
        }
 public void Setup()
 {
     _module   = Substitute.For <IVsrModule>();
     _provider = new GitRevisionInfoProvider(() => _module);
 }
 public CommitTemplateManager(IVsrModule module, IFullPathResolver fullPathResolver, IFileSystem fileSystem)
 {
     _module           = module;
     _fullPathResolver = fullPathResolver;
     _fileSystem       = fileSystem;
 }
Esempio n. 28
0
        public void GitDescribeProvider_should_throw_if_module_is_not_provided()
        {
            _module = null;

            ((Action)(() => _provider.Get(ObjectId.Random()))).Should().Throw <ArgumentException>();
        }
Esempio n. 29
0
 public void Setup()
 {
     _module   = Substitute.For <IVsrModule>();
     _provider = new GitDescribeProvider(() => _module);
 }
 public CommitTemplateManager(IVsrModule module)
     : this(module, new FullPathResolver(() => module.WorkingDir), new FileSystem())
 {
 }