GetFileStatus() public method

public GetFileStatus ( string fileName, bool forceRefresh = false ) : GitFileStatus
fileName string
forceRefresh bool
return GitFileStatus
Example #1
0
        public void GetFileStatusTest()
        {
            GitRepository.Init(tempFolder);
            GitRepository tracker = new GitRepository(tempFolder);

            File.WriteAllLines(tempFilePath, lines);
            Assert.AreEqual(GitFileStatus.New, tracker.GetFileStatus(tempFile));

            tracker.StageFile(tempFile);
            tracker.Refresh();
            Assert.AreEqual(GitFileStatus.Added, tracker.GetFileStatus(tempFile));

            tracker.UnStageFile(tempFile);
            tracker.Refresh();
            Assert.AreEqual(GitFileStatus.New, tracker.GetFileStatus(tempFile));

            tracker.StageFile(tempFile);
            tracker.Refresh();
            Assert.AreEqual(GitFileStatus.Added, tracker.GetFileStatus(tempFile));

            tracker.Commit("中文 1čtestč");
            tracker.Refresh();
            Assert.AreEqual(GitFileStatus.Tracked, tracker.GetFileStatus(tempFile));

            File.WriteAllText(tempFilePath, "changed text");
            tracker.Refresh();
            Assert.AreEqual(GitFileStatus.Modified, tracker.GetFileStatus(tempFile));

            tracker.StageFile(tempFile);
            tracker.Refresh();
            Assert.AreEqual(GitFileStatus.Staged, tracker.GetFileStatus(tempFile));

            tracker.UnStageFile(tempFile);
            tracker.Refresh();
            Assert.AreEqual(GitFileStatus.Modified, tracker.GetFileStatus(tempFile));

            File.Delete(tempFilePath);
            tracker.Refresh();
            Assert.AreEqual(GitFileStatus.Deleted, tracker.GetFileStatus(tempFile));

            tracker.StageFile(tempFile);
            tracker.Refresh();
            Assert.AreEqual(GitFileStatus.Removed, tracker.GetFileStatus(tempFile));

            tracker.UnStageFile(tempFile);
            tracker.Refresh();
            Assert.AreEqual(GitFileStatus.Deleted, tracker.GetFileStatus(tempFile));
        }
Example #2
0
        public void GetChangedFilesTest()
        {
            GitRepository.Init(tempFolder);
            File.WriteAllLines(tempFilePath, lines);

            GitRepository tracker = new GitRepository(tempFolder);
            tracker.StageFile(tempFile);
            tracker.Refresh();
            Assert.AreEqual(GitFileStatus.Added, tracker.GetFileStatus(tempFile));
            tracker.Commit("中文 1čtestč");
            tracker.Refresh();
            Assert.AreEqual(0, tracker.ChangedFiles.Count());
            File.WriteAllText(tempFilePath, "a");
            tracker.Refresh();
            Assert.AreEqual(GitFileStatus.Modified, tracker.GetFileStatus(tempFile));
        }