예제 #1
0
        public void EmptyState()
        {
            var oldContent = "";
            var newContent = "";
            var diffs      = DiffLineGenerator.GenerateLineDiffs(oldContent, newContent);

            Assert.AreEqual(1, diffs.Count);
            Assert.AreEqual(0, diffs[0].Count);
        }
예제 #2
0
        public void InsertNewLine()
        {
            var oldContent = "a\r\nc";
            var newContent = "a\r\nb\r\nc";
            var diffs      = DiffLineGenerator.GenerateLineDiffs(oldContent, newContent);

            Assert.AreEqual(3, diffs.Count);
            var line = diffs[1];

            Assert.AreEqual(1, line.Count);
            Assert.AreEqual("b", line[0].Text);
            Assert.IsTrue(line[0].Operation.IsInsert);
        }
예제 #3
0
        private void WhenSelectedUnstagedFileChanged()
        {
            var selectedFile = SelectedUnstagedFile;

            if (selectedFile == null)
            {
                return;
            }

            var oldContent = Repository.Lookup <Blob>(Repository.Index[selectedFile].Id);
//                var oldContent = (Blob)Branch.Tip[selectedFile]?.Target;
            var oldContentText = oldContent?.GetContentText();

            var newContentText = File.ReadAllText(Path.Combine(Repository.Info.WorkingDirectory, selectedFile)).Replace("\r\n", "\n");

            SelectedFileContent = DiffLineGenerator.GenerateLineDiffs(oldContentText, newContentText);
        }
예제 #4
0
        /// <summary>
        /// Don't rename to OnSelectedFileChanged as that messes things up with NotifyPropertyChanged.Fody
        /// </summary>
        private void WhenSelectedFileChanged()
        {
            var selectedFile = SelectedFile;

            if (selectedFile == null)
            {
                return;
            }

            var oldContent = (Blob)Commit?.Parents.FirstOrDefault()?[selectedFile]?.Target;
            var newContent = (Blob)Commit?[selectedFile]?.Target;

            var oldContentText = oldContent?.GetContentText();
            var newContentText = newContent?.GetContentText();

            SelectedFileContent = DiffLineGenerator.GenerateLineDiffs(oldContentText, newContentText);
        }
예제 #5
0
        /// <summary>
        /// Don't rename to OnSelectedFileChanged as that messes things up with NotifyPropertyChanged.Fody
        /// </summary>
        private void WhenSelectedStagedFileChanged()
        {
            var selectedFile = SelectedStagedFile;

            if (selectedFile == null)
            {
                return;
            }

//            var oldContent = Repository.Lookup<Blob>(Repository.Index[selectedFile].Id);
            var oldContent = (Blob)Repository.Head.Tip[selectedFile]?.Target;
//                var oldContent = (Blob)Branch.Tip[selectedFile]?.Target;
            var oldContentText = oldContent?.GetContentText();

//            var newContentText = Status.Staged.Single(x => x.FilePath == selectedFile).;
            var newContent     = Repository.Lookup <Blob>(Repository.Index[selectedFile].Id);
            var newContentText = newContent?.GetContentText();

            SelectedFileContent = DiffLineGenerator.GenerateLineDiffs(oldContentText, newContentText);
        }