Пример #1
0
 private void showLineNumbersToolStripMenuItem_Click(object sender, EventArgs e)
 {
     AppSettings.BlameShowLineNumbers         = !AppSettings.BlameShowLineNumbers;
     showLineNumbersToolStripMenuItem.Checked = AppSettings.BlameShowLineNumbers;
     Blame.UpdateShowLineNumbers();
     UpdateSelectedFileViewers(true);
 }
Пример #2
0
 public static void CheckEqual(Blame a, Blame b)
 {
     Assert.That(a.LineNumber, Is.EqualTo(b.LineNumber));
     Assert.That(a.Revision, Is.EqualTo(b.Revision));
     Assert.That(a.Author, Is.EqualTo(b.Author));
     Assert.That(TruncToSecond(a.Date), Is.EqualTo(TruncToSecond(b.Date)));
     Assert.That(a.Line, Is.EqualTo(b.Line));
 }
Пример #3
0
        private void UpdateSelectedFileViewers(bool force = false)
        {
            var selectedRows = FileChanges.GetSelectedRevisions();

            if (selectedRows.Count == 0)
            {
                return;
            }

            GitRevision revision = selectedRows[0];
            var         children = FileChanges.GetRevisionChildren(revision.Guid);

            var fileName = revision.Name;

            if (string.IsNullOrEmpty(fileName))
            {
                fileName = FileName;
            }

            SetTitle(fileName);

            if (tabControl1.SelectedTab == BlameTab)
            {
                Blame.LoadBlame(revision, children, fileName, FileChanges, BlameTab, Diff.Encoding, force: force);
            }
            else if (tabControl1.SelectedTab == ViewTab)
            {
                var scrollpos = View.ScrollPos;

                View.Encoding = Diff.Encoding;
                View.ViewGitItemRevision(fileName, revision.Guid);
                View.ScrollPos = scrollpos;
            }
            else if (tabControl1.SelectedTab == DiffTab)
            {
                var file = new GitItemStatus
                {
                    IsTracked   = true,
                    Name        = fileName,
                    IsSubmodule = GitModule.IsValidGitWorkingDir(_fullPathResolver.Resolve(fileName))
                };
                Diff.ViewChanges(FileChanges.GetSelectedRevisions(), file, "You need to select at least one revision to view diff.");
            }
            else if (tabControl1.SelectedTab == CommitInfoTabPage)
            {
                CommitDiff.SetRevision(revision.Guid, fileName);
            }

            if (_buildReportTabPageExtension == null)
            {
                _buildReportTabPageExtension = new BuildReportTabPageExtension(tabControl1, _buildReportTabCaption.Text);
            }

            _buildReportTabPageExtension.FillBuildReport(selectedRows.Count == 1 ? revision : null);
        }
Пример #4
0
 public void DecorateLineTestShouldHaveFormatAsRequiredByScmActivity()
 {
     var commitsMock = new Mock<ICommits>();
     ICommits commits = commitsMock.Object;
     // scm activity expects the sequence to be as shown below
     String expectedCommit="12345 PeterStevens 2014-01-01";
     commitsMock.Setup(instance => instance.GetFormattedCommit(12345)).Returns(expectedCommit);
     Blame blame = new Blame(commits);
     String expectedLine = expectedCommit + " MyOriginalTest";
     String decoratedLine=blame.DecorateLine("12345 MyOriginalTest");
     Assert.AreEqual(expectedLine,decoratedLine);
 }
Пример #5
0
        private void UpdateSelectedFileViewers()
        {
            var selectedRows = FileChanges.GetSelectedRevisions();

            if (selectedRows.Count == 0)
            {
                return;
            }

            GitRevision revision = selectedRows[0];
            var         children = FileChanges.GetRevisionChildren(revision.Guid);

            var fileName = revision.Name;

            if (string.IsNullOrEmpty(fileName))
            {
                fileName = FileName;
            }

            SetTitle(fileName);

            if (tabControl1.SelectedTab == BlameTab)
            {
                Blame.LoadBlame(revision, children, fileName, FileChanges, BlameTab, Diff.Encoding);
            }
            else if (tabControl1.SelectedTab == ViewTab)
            {
                var scrollpos = View.ScrollPos;

                View.Encoding = Diff.Encoding;
                View.ViewGitItemRevision(fileName, revision.Guid);
                View.ScrollPos = scrollpos;
            }
            else if (tabControl1.SelectedTab == DiffTab)
            {
                GitItemStatus file = new GitItemStatus();
                file.IsTracked   = true;
                file.Name        = fileName;
                file.IsSubmodule = GitModule.IsValidGitWorkingDir(Path.Combine(Module.WorkingDir, fileName));
                Diff.ViewChanges(FileChanges.GetSelectedRevisions(), file, "You need to select at least one revision to view diff.");
            }

            if (!EnvUtils.IsMonoRuntime())
            {
                if (_buildReportTabPageExtension == null)
                {
                    _buildReportTabPageExtension = new BuildReportTabPageExtension(tabControl1, _buildReportTabCaption.Text);
                }

                _buildReportTabPageExtension.FillBuildReport(selectedRows.Count == 1 ? revision : null);
            }
        }
Пример #6
0
 private void RunBlame(BlamePositionModel position)
 {
     if (position == null || position.RepoPath == null)
     {
         Blame.ClearBlameResult();
     }
     else
     {
         ProfileOptimization.StartProfile("Blame");
         BlameResult blame = GitWrapper.GetBlameOutput(position.RepoPath, position.FileName, position.CommitId);
         Blame.SetBlameResult(blame, position.LineNumber ?? 1);
     }
 }
Пример #7
0
        private FormFileHistory([NotNull] GitUICommands commands)
            : base(commands)
        {
            InitializeComponent();
            ConfigureTabControl();

            _filterBranchHelper    = new FilterBranchHelper(toolStripBranchFilterComboBox, toolStripBranchFilterDropDownButton, FileChanges);
            _filterRevisionsHelper = new FilterRevisionsHelper(toolStripRevisionFilterTextBox, toolStripRevisionFilterDropDownButton, FileChanges, toolStripRevisionFilterLabel, ShowFirstParent, form: this);

            _formBrowseMenus = new FormBrowseMenus(FileHistoryContextMenu);
            _formBrowseMenus.ResetMenuCommandSets();
            _formBrowseMenus.AddMenuCommandSet(MainMenuItem.NavigateMenu, FileChanges.MenuCommands.NavigateMenuCommands);
            _formBrowseMenus.AddMenuCommandSet(MainMenuItem.ViewMenu, FileChanges.MenuCommands.ViewMenuCommands);
            _formBrowseMenus.InsertAdditionalMainMenuItems(toolStripSeparator4);

            _commitDataManager = new CommitDataManager(() => Module);
            _fullPathResolver  = new FullPathResolver(() => Module.WorkingDir);

            CommitDiff.EscapePressed += Close;
            View.EscapePressed       += Close;
            Diff.EscapePressed       += Close;
            Blame.EscapePressed      += Close;

            copyToClipboardToolStripMenuItem.SetRevisionFunc(() => FileChanges.GetSelectedRevisions());

            InitializeComplete();

            Blame.ConfigureRepositoryHostPlugin(PluginRegistry.TryGetGitHosterForModule(Module));

            return;

            void ConfigureTabControl()
            {
                tabControl1.ImageList = new ImageList
                {
                    ColorDepth = ColorDepth.Depth32Bit,
                    ImageSize  = DpiUtil.Scale(new Size(16, 16)),
                    Images     =
                    {
                        Images.CommitSummary,
                        Images.Diff,
                        Images.ViewFile,
                        Images.Blame
                    }
                };
                tabControl1.TabPages[0].ImageIndex = 0;
                tabControl1.TabPages[1].ImageIndex = 1;
                tabControl1.TabPages[2].ImageIndex = 2;
                tabControl1.TabPages[3].ImageIndex = 3;
            }
        }
Пример #8
0
        private void UpdateSelectedFileViewers()
        {
            var selectedRows = FileChanges.GetSelectedRevisions();

            if (selectedRows.Count == 0)
            {
                return;
            }

            IGitItem revision = selectedRows[0];

            var fileName = revision.Name;

            if (string.IsNullOrEmpty(fileName))
            {
                fileName = FileName;
            }

            Text = string.Format("File History - {0}", FileName);
            if (!fileName.Equals(FileName))
            {
                Text = Text + string.Format(" ({0})", fileName);
            }

            if (tabControl1.SelectedTab == BlameTab)
            {
                Blame.LoadBlame(revision.Guid, fileName, FileChanges, BlameTab, Diff.Encoding);
            }
            if (tabControl1.SelectedTab == ViewTab)
            {
                var scrollpos = View.ScrollPos;

                View.Encoding = Diff.Encoding;
                View.ViewGitItemRevision(fileName, revision.Guid);
                View.ScrollPos = scrollpos;
            }

            if (tabControl1.SelectedTab == DiffTab)
            {
                GitItemStatus file = new GitItemStatus();
                file.IsTracked = true;
                file.Name      = fileName;
                Diff.ViewPatch(FileChanges, file, "You need to select at least one revision to view diff.");
            }
        }
Пример #9
0
        public InternalBlameViewModel(string filePath, int?lineNumber, IToolWindowViewModel tool)
        {
            this.blameHelper           = new BlameHelper(tool);
            this.mergeHelper           = new MergeHelper(tool);
            FilePath                   = filePath;
            PreviousRevisionCommand    = new DelegateCommand(NavigateToPreviousRevision, CanNavigateToPreviousRevision);
            NextRevisionCommand        = new DelegateCommand(NavigateToNextRevision, CanNavigateToNextRevision);
            SpecifiedRevisionCommand   = new DelegateCommand(NavigateToSpecifiedRevision, CanNavigateToSpecifiedRevision);
            LastRevisionCommand        = new DelegateCommand(NavigateToLastRevision, CanNavigateToLastRevision);
            CompareWithPreviousCommand = new DelegateCommand(CompareWithPrevious, CanCompareWithPrevious);
            CompareCurrentFileCommand  = new DelegateCommand(CompareCurrentFile, CanCompareCurrentFile);
            CopyCommentCommand         = new DelegateCommand(CopyComment, CanCopyComment);

            int line = lineNumber - 1 ?? 0;

            InitializeFileDiffInfo();
            Blame           = fileDiffInfo.BlameAtRevision(LastRevision);
            CurrentRevision = LastRevision;
            CurrentLine     = Blame.ElementAtOrDefault(line);
        }
Пример #10
0
        // GET /api/blames/{id}
        public BlameViewModel Get(long id)
        {
            using (BlameRepository repo = new BlameRepository(User.Identity.GetUserId()))
            {
                Blame blame = repo.Get().SingleOrDefault(b => b.ID == id);
                if (blame == null)
                {
                    throw new HttpResponseException(HttpStatusCode.NotFound);
                }

                return(new BlameViewModel
                {
                    ID = blame.ID,
                    CreatedAt = blame.CreatedAt,
                    CreatedBy = blame.CreatedBy,
                    ShameID = blame.ShameID,
                    UserID = blame.UserID
                });
            }
        }
Пример #11
0
        public void Blame_BlameBasic()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            sbox.Create(SandBoxRepository.AnkhSvnCases);
            string WcPath = sbox.Wc;

            string path  = Path.Combine(WcPath, "Form.cs");
            string blame = this.RunCommand("svn", "blame -v " + path);

            Blame[] cmdline = this.ParseCommandLineBlame(blame);

            SvnBlameArgs a = new SvnBlameArgs();

            Assert.That(this.Client.Blame(path, a, this.Receiver));

            Assert.That(this.blames.Count, Is.EqualTo(cmdline.Length));
            for (int i = 0; i < cmdline.Length; i++)
            {
                Blame.CheckEqual(cmdline[i], (Blame)this.blames[i]);
            }
        }
Пример #12
0
        private void UpdateSelectedFileViewers(bool force = false)
        {
            var selectedRevisions = FileChanges.GetSelectedRevisions();

            if (selectedRevisions.Count == 0)
            {
                return;
            }

            GitRevision revision = selectedRevisions[0];
            var         children = FileChanges.GetRevisionChildren(revision.ObjectId);

            var fileName = revision.Name;

            if (string.IsNullOrEmpty(fileName))
            {
                fileName = FileName;
            }

            SetTitle(fileName);

            if (revision.IsArtificial)
            {
                tabControl1.SelectedTab = DiffTab;

                CommitInfoTabPage.Parent = null;
                BlameTab.Parent          = null;
                ViewTab.Parent           = null;
            }
            else
            {
                if (CommitInfoTabPage.Parent == null)
                {
                    tabControl1.TabPages.Insert(0, CommitInfoTabPage);
                }

                if (ViewTab.Parent == null)
                {
                    var index = tabControl1.TabPages.IndexOf(DiffTab);
                    Debug.Assert(index != -1, "TabControl should contain diff tab page");
                    tabControl1.TabPages.Insert(index + 1, ViewTab);
                }

                if (BlameTab.Parent == null)
                {
                    var index = tabControl1.TabPages.IndexOf(ViewTab);
                    Debug.Assert(index != -1, "TabControl should contain view tab page");
                    tabControl1.TabPages.Insert(index + 1, BlameTab);
                }
            }

            if (tabControl1.SelectedTab == BlameTab)
            {
                Blame.LoadBlame(revision, children, fileName, FileChanges, BlameTab, Diff.Encoding, force: force);
            }
            else if (tabControl1.SelectedTab == ViewTab)
            {
                var scrollPos = View.ScrollPos;

                View.Encoding = Diff.Encoding;
                View.ViewGitItemRevisionAsync(fileName, revision.ObjectId);
                View.ScrollPos = scrollPos;
            }
            else if (tabControl1.SelectedTab == DiffTab)
            {
                var file = new GitItemStatus
                {
                    IsTracked   = true,
                    Name        = fileName,
                    IsSubmodule = GitModule.IsValidGitWorkingDir(_fullPathResolver.Resolve(fileName))
                };
                Diff.ViewChangesAsync(FileChanges.GetSelectedRevisions(), file, "You need to select at least one revision to view diff.");
            }
            else if (tabControl1.SelectedTab == CommitInfoTabPage)
            {
                CommitDiff.SetRevision(revision.ObjectId, fileName);
            }

            if (_buildReportTabPageExtension == null)
            {
                _buildReportTabPageExtension = new BuildReportTabPageExtension(tabControl1, _buildReportTabCaption.Text);
            }

            _buildReportTabPageExtension.FillBuildReport(selectedRevisions.Count == 1 ? revision : null);
        }
Пример #13
0
 public void Add(Blame blame)
 {
     _context.Blames.Add(blame);
     _context.SaveChanges();
 }
Пример #14
0
 public void TestBlame()
 {
     Blame blame = new Blame();
     String result = blame.RunAnnotate("joker");
     Assert.IsNotNull(result);
 }
Пример #15
0
 private void RunBlame(BlamePositionModel?position)
 {
     if (position is null || position.RepoPath is null)
     {
         Blame.ClearBlameResult();
     }
Пример #16
0
 public static void CheckEqual(Blame a, Blame b)
 {
     Assert.That(a.LineNumber, Is.EqualTo(b.LineNumber));
     Assert.That(a.Revision, Is.EqualTo(b.Revision));
     Assert.That(a.Author, Is.EqualTo(b.Author));
     Assert.That(TruncToSecond(a.Date), Is.EqualTo(TruncToSecond(b.Date)));
     Assert.That(a.Line, Is.EqualTo(b.Line));
 }