当前位置: 首页>>代码示例>>C#>>正文


C# Repository.RemoveUntrackedFiles方法代码示例

本文整理汇总了C#中Repository.RemoveUntrackedFiles方法的典型用法代码示例。如果您正苦于以下问题:C# Repository.RemoveUntrackedFiles方法的具体用法?C# Repository.RemoveUntrackedFiles怎么用?C# Repository.RemoveUntrackedFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Repository的用法示例。


在下文中一共展示了Repository.RemoveUntrackedFiles方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CannotCleanABareRepository

 public void CannotCleanABareRepository()
 {
     using (var repo = new Repository(BareTestRepoPath))
     {
         Assert.Throws<BareRepositoryException>(() => repo.RemoveUntrackedFiles());
     }
 }
开发者ID:KindDragon,项目名称:libgit2sharp,代码行数:7,代码来源:CleanFixture.cs

示例2: CannotCleanABareRepository

 public void CannotCleanABareRepository()
 {
     string path = SandboxBareTestRepo();
     using (var repo = new Repository(path))
     {
         Assert.Throws<BareRepositoryException>(() => repo.RemoveUntrackedFiles());
     }
 }
开发者ID:beulah444,项目名称:libgit2sharp,代码行数:8,代码来源:CleanFixture.cs

示例3: CanFastForwardRepos

        public void CanFastForwardRepos(bool shouldMergeOccurInDetachedHeadState)
        {
            const string firstBranchFileName = "first branch file.txt";
            const string sharedBranchFileName = "first+second branch file.txt";

            string path = CloneStandardTestRepo();
            using (var repo = new Repository(path))
            {
                // Reset the index and the working tree.
                repo.Reset(ResetMode.Hard);

                // Clean the working directory.
                repo.RemoveUntrackedFiles();

                var firstBranch = repo.CreateBranch("FirstBranch");
                firstBranch.Checkout();

                // Commit with ONE new file to both first & second branch (SecondBranch is created on this commit).
                AddFileCommitToRepo(repo, sharedBranchFileName);

                var secondBranch = repo.CreateBranch("SecondBranch");

                // Commit with ONE new file to first branch (FirstBranch moves forward as it is checked out, SecondBranch stays back one).
                AddFileCommitToRepo(repo, firstBranchFileName);

                if (shouldMergeOccurInDetachedHeadState)
                {
                    // Detaches HEAD
                    repo.Checkout(secondBranch.Tip);
                }
                else
                {
                    secondBranch.Checkout();
                }

                Assert.Equal(shouldMergeOccurInDetachedHeadState, repo.Info.IsHeadDetached);

                MergeResult mergeResult = repo.Merge(repo.Branches["FirstBranch"].Tip, Constants.Signature);

                Assert.Equal(MergeStatus.FastForward, mergeResult.Status);
                Assert.Equal(repo.Branches["FirstBranch"].Tip, mergeResult.Commit);
                Assert.Equal(repo.Branches["FirstBranch"].Tip, repo.Head.Tip);
                Assert.Equal(repo.Head.Tip, mergeResult.Commit);

                Assert.Equal(0, repo.Index.RetrieveStatus().Count());
                Assert.Equal(shouldMergeOccurInDetachedHeadState, repo.Info.IsHeadDetached);

                if (!shouldMergeOccurInDetachedHeadState)
                {
                    // Ensure HEAD is still attached and points to SecondBranch
                    Assert.Equal(repo.Refs.Head.TargetIdentifier, secondBranch.CanonicalName);
                }
            }
        }
开发者ID:nagyist,项目名称:libgit2sharp,代码行数:54,代码来源:MergeFixture.cs

示例4: CanCleanWorkingDirectory

        public void CanCleanWorkingDirectory()
        {
            TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoWorkingDirPath);
            using (var repo = new Repository(path.RepositoryPath))
            {
                // Verify that there are the expected number of entries and untracked files
                Assert.Equal(6, repo.Index.RetrieveStatus().Count());
                Assert.Equal(1, repo.Index.RetrieveStatus().Untracked.Count());

                repo.RemoveUntrackedFiles();

                // Verify that there are the expected number of entries and 0 untracked files
                Assert.Equal(5, repo.Index.RetrieveStatus().Count());
                Assert.Equal(0, repo.Index.RetrieveStatus().Untracked.Count());
            }
        }
开发者ID:KindDragon,项目名称:libgit2sharp,代码行数:16,代码来源:CleanFixture.cs

示例5: CanCleanWorkingDirectory

        public void CanCleanWorkingDirectory()
        {
            string path = SandboxStandardTestRepo();
            using (var repo = new Repository(path))
            {
                // Verify that there are the expected number of entries and untracked files
                Assert.Equal(6, repo.RetrieveStatus().Count());
                Assert.Equal(1, repo.RetrieveStatus().Untracked.Count());

                repo.RemoveUntrackedFiles();

                // Verify that there are the expected number of entries and 0 untracked files
                Assert.Equal(5, repo.RetrieveStatus().Count());
                Assert.Equal(0, repo.RetrieveStatus().Untracked.Count());
            }
        }
开发者ID:beulah444,项目名称:libgit2sharp,代码行数:16,代码来源:CleanFixture.cs

示例6: CanAmendAnEmptyMergeCommit

        public void CanAmendAnEmptyMergeCommit()
        {
            string path = CloneStandardTestRepo();
            using (var repo = new Repository(path))
            {
                repo.Reset(ResetMode.Hard);
                repo.RemoveUntrackedFiles();

                Touch(repo.Info.Path, "MERGE_HEAD", "f705abffe7015f2beacf2abe7a36583ebee3487e\n");
                Commit newMergedCommit = repo.Commit("Merge commit", Constants.Signature, Constants.Signature);

                Commit amendedCommit = repo.Commit("I'm rewriting the history!", Constants.Signature, Constants.Signature,
                    new CommitOptions { AmendPreviousCommit = true });
                AssertCommitHasBeenAmended(repo, amendedCommit, newMergedCommit);
            }
        }
开发者ID:nulltoken,项目名称:libgit2sharp,代码行数:16,代码来源:CommitFixture.cs

示例7: CanAmendAnEmptyCommitWhenForced

        public void CanAmendAnEmptyCommitWhenForced()
        {
            string path = CloneStandardTestRepo();
            using (var repo = new Repository(path))
            {
                repo.Reset(ResetMode.Hard);
                repo.RemoveUntrackedFiles();

                Commit emptyCommit = repo.Commit("Empty commit!", Constants.Signature, Constants.Signature,
                    new CommitOptions { AllowEmptyCommit = true });

                Commit amendedCommit = repo.Commit("I'm rewriting the history!", Constants.Signature, Constants.Signature,
                    new CommitOptions { AmendPreviousCommit = true, AllowEmptyCommit = true });
                AssertCommitHasBeenAmended(repo, amendedCommit, emptyCommit);
            }
        }
开发者ID:nulltoken,项目名称:libgit2sharp,代码行数:16,代码来源:CommitFixture.cs

示例8: CanCorrectlyCountCommitsWhenSwitchingToAnotherBranch

        public void CanCorrectlyCountCommitsWhenSwitchingToAnotherBranch()
        {
            string path = SandboxStandardTestRepo();
            using (var repo = new Repository(path))
            {
                // Hard reset and then remove untracked files
                repo.Reset(ResetMode.Hard);
                repo.RemoveUntrackedFiles();

                repo.Checkout("test");
                Assert.Equal(2, repo.Commits.Count());
                Assert.Equal("e90810b8df3e80c413d903f631643c716887138d", repo.Commits.First().Id.Sha);

                repo.Checkout("master");
                Assert.Equal(9, repo.Commits.Count());
                Assert.Equal("32eab9cb1f450b5fe7ab663462b77d7f4b703344", repo.Commits.First().Id.Sha);
            }
        }
开发者ID:beulah444,项目名称:libgit2sharp,代码行数:18,代码来源:CommitFixture.cs

示例9: UnalteredFilesDontMarkIndexAsDirty

        public void UnalteredFilesDontMarkIndexAsDirty()
        {
            var path = SandboxStandardTestRepo();

            using (var repo = new Repository(path))
            {
                repo.Reset(ResetMode.Hard);
                repo.RemoveUntrackedFiles();

                RepositoryStatus status = repo.RetrieveStatus(new StatusOptions() { IncludeUnaltered = true });

                Assert.Equal(false, status.IsDirty);
                Assert.Equal(9, status.Count());
            }
        }
开发者ID:PKRoma,项目名称:libgit2sharp,代码行数:15,代码来源:StatusFixture.cs

示例10: CanEnumerateFromDetachedHead

        public void CanEnumerateFromDetachedHead()
        {
            string path = CloneStandardTestRepo();
            using (var repoClone = new Repository(path))
            {
                // Hard reset and then remove untracked files
                repoClone.Reset(ResetOptions.Hard);
                repoClone.RemoveUntrackedFiles();

                string headSha = repoClone.Head.Tip.Sha;
                repoClone.Checkout(headSha);

                AssertEnumerationOfCommitsInRepo(repoClone,
                    repo => new Filter { Since = repo.Head },
                    new[]
                        {
                            "32eab9c", "592d3c8", "4c062a6",
                            "be3563a", "c47800c", "9fd738e",
                            "4a202b3", "5b5b025", "8496071",
                        });
            }
        }
开发者ID:TiThompson,项目名称:libgit2sharp,代码行数:22,代码来源:CommitFixture.cs

示例11: ResetAndCleanWorkingDirectory

        /// <summary>
        /// Reset and clean current working directory. This will ensure that the current
        /// working directory matches the current Head commit.
        /// </summary>
        /// <param name="repo">Repository whose current working directory should be operated on.</param>
        private void ResetAndCleanWorkingDirectory(Repository repo)
        {
            // Reset the index and the working tree.
            repo.Reset(ResetOptions.Hard);

            // Clean the working directory.
            repo.RemoveUntrackedFiles();
        }
开发者ID:JenekX,项目名称:libgit2sharp,代码行数:13,代码来源:CheckoutFixture.cs

示例12: CanNotCommitAnEmptyCommit

        public void CanNotCommitAnEmptyCommit()
        {
            string path = CloneStandardTestRepo();
            using (var repo = new Repository(path))
            {
                repo.Reset(ResetMode.Hard);
                repo.RemoveUntrackedFiles();

                Assert.Throws<EmptyCommitException>(() => repo.Commit("Empty commit!", Constants.Signature, Constants.Signature));
            }
        }
开发者ID:nulltoken,项目名称:libgit2sharp,代码行数:11,代码来源:CommitFixture.cs

示例13: CanCommitAnEmptyCommitWhenMerging

        public void CanCommitAnEmptyCommitWhenMerging()
        {
            string path = CloneStandardTestRepo();
            using (var repo = new Repository(path))
            {
                repo.Reset(ResetMode.Hard);
                repo.RemoveUntrackedFiles();

                Touch(repo.Info.Path, "MERGE_HEAD", "f705abffe7015f2beacf2abe7a36583ebee3487e\n");

                Assert.Equal(CurrentOperation.Merge, repo.Info.CurrentOperation);

                Commit newMergedCommit = repo.Commit("Merge commit", Constants.Signature, Constants.Signature);

                Assert.Equal(2, newMergedCommit.Parents.Count());
                Assert.Equal(newMergedCommit.Parents.First().Sha, "32eab9cb1f450b5fe7ab663462b77d7f4b703344");
                Assert.Equal(newMergedCommit.Parents.Skip(1).First().Sha, "f705abffe7015f2beacf2abe7a36583ebee3487e");
            }
        }
开发者ID:nulltoken,项目名称:libgit2sharp,代码行数:19,代码来源:CommitFixture.cs

示例14: CanCommitAnEmptyCommitWhenForced

        public void CanCommitAnEmptyCommitWhenForced()
        {
            string path = CloneStandardTestRepo();
            using (var repo = new Repository(path))
            {
                repo.Reset(ResetMode.Hard);
                repo.RemoveUntrackedFiles();

                repo.Commit("Empty commit!", Constants.Signature, Constants.Signature,
                    new CommitOptions { AllowEmptyCommit = true });
            }
        }
开发者ID:nulltoken,项目名称:libgit2sharp,代码行数:12,代码来源:CommitFixture.cs

示例15: CanNotAmendAnEmptyCommit

        public void CanNotAmendAnEmptyCommit()
        {
            string path = SandboxStandardTestRepo();
            using (var repo = new Repository(path))
            {
                repo.Reset(ResetMode.Hard);
                repo.RemoveUntrackedFiles();

                repo.Commit("Empty commit!", Constants.Signature, Constants.Signature,
                    new CommitOptions { AllowEmptyCommit = true });

                Assert.Throws<EmptyCommitException>(() => repo.Commit("Empty commit!", Constants.Signature, Constants.Signature,
                    new CommitOptions { AmendPreviousCommit = true }));
            }
        }
开发者ID:beulah444,项目名称:libgit2sharp,代码行数:15,代码来源:CommitFixture.cs


注:本文中的Repository.RemoveUntrackedFiles方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。