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


C# Repository.Unstage方法代码示例

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


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

示例1: StagingANewVersionOfAFileThenUnstagingItRevertsTheBlobToTheVersionOfHead

        public void StagingANewVersionOfAFileThenUnstagingItRevertsTheBlobToTheVersionOfHead()
        {
            string path = SandboxStandardTestRepo();
            using (var repo = new Repository(path))
            {
                int count = repo.Index.Count;

                string filename = Path.Combine("1", "branch_file.txt");
                const string posixifiedFileName = "1/branch_file.txt";
                ObjectId blobId = repo.Index[posixifiedFileName].Id;

                string fullpath = Path.Combine(repo.Info.WorkingDirectory, filename);

                File.AppendAllText(fullpath, "Is there there anybody out there?");
                repo.Stage(filename);

                Assert.Equal(count, repo.Index.Count);
                Assert.NotEqual((blobId), repo.Index[posixifiedFileName].Id);

                repo.Unstage(posixifiedFileName);

                Assert.Equal(count, repo.Index.Count);
                Assert.Equal(blobId, repo.Index[posixifiedFileName].Id);
            }
        }
开发者ID:beulah444,项目名称:libgit2sharp,代码行数:25,代码来源:UnstageFixture.cs

示例2: CanUnstageBothSidesOfARename

        public void CanUnstageBothSidesOfARename()
        {
            using (var repo = new Repository(CloneStandardTestRepo()))
            {
                repo.Move("branch_file.txt", "renamed_branch_file.txt");
                repo.Unstage(new string[] { "branch_file.txt", "renamed_branch_file.txt" });

                RepositoryStatus status = repo.RetrieveStatus();
                Assert.Equal(FileStatus.Missing, status["branch_file.txt"].State);
                Assert.Equal(FileStatus.Untracked, status["renamed_branch_file.txt"].State);
            }
        }
开发者ID:nulltoken,项目名称:libgit2sharp,代码行数:12,代码来源:UnstageFixture.cs

示例3: CanUnstage

        public void CanUnstage(
            string relativePath, FileStatus currentStatus, bool doesCurrentlyExistInTheIndex,
            FileStatus expectedStatusOnceStaged, bool doesExistInTheIndexOnceStaged, int expectedIndexCountVariation)
        {
            string path = SandboxStandardTestRepo();
            using (var repo = new Repository(path))
            {
                int count = repo.Index.Count;
                Assert.Equal(doesCurrentlyExistInTheIndex, (repo.Index[relativePath] != null));
                Assert.Equal(currentStatus, repo.RetrieveStatus(relativePath));

                repo.Unstage(relativePath);

                Assert.Equal(count + expectedIndexCountVariation, repo.Index.Count);
                Assert.Equal(doesExistInTheIndexOnceStaged, (repo.Index[relativePath] != null));
                Assert.Equal(expectedStatusOnceStaged, repo.RetrieveStatus(relativePath));
            }
        }
开发者ID:beulah444,项目名称:libgit2sharp,代码行数:18,代码来源:UnstageFixture.cs

示例4: CanStageAndUnstageAnIgnoredFile

        public void CanStageAndUnstageAnIgnoredFile()
        {
            string path = SandboxStandardTestRepo();
            using (var repo = new Repository(path))
            {
                Touch(repo.Info.WorkingDirectory, ".gitignore", "*.ign" + Environment.NewLine);

                const string relativePath = "Champa.ign";
                Touch(repo.Info.WorkingDirectory, relativePath, "On stage!" + Environment.NewLine);

                Assert.Equal(FileStatus.Ignored, repo.RetrieveStatus(relativePath));

                repo.Stage(relativePath, new StageOptions { IncludeIgnored = true });
                Assert.Equal(FileStatus.Added, repo.RetrieveStatus(relativePath));

                repo.Unstage(relativePath);
                Assert.Equal(FileStatus.Ignored, repo.RetrieveStatus(relativePath));
            }
        }
开发者ID:beulah444,项目名称:libgit2sharp,代码行数:19,代码来源:UnstageFixture.cs

示例5: CanMergeIntoOrphanedBranch

        public void CanMergeIntoOrphanedBranch()
        {
            string path = SandboxMergeTestRepo();
            using (var repo = new Repository(path))
            {
                repo.Refs.Add("HEAD", "refs/heads/orphan", true);

                // Remove entries from the working directory
                foreach(var entry in repo.RetrieveStatus())
                {
                    repo.Unstage(entry.FilePath);
                    repo.Remove(entry.FilePath, true);
                }

                // Assert that we have an empty working directory.
                Assert.False(repo.RetrieveStatus().Any());

                MergeResult result = repo.Merge("master", Constants.Signature);

                Assert.Equal(MergeStatus.FastForward, result.Status);
                Assert.Equal(masterBranchInitialId, result.Commit.Id.Sha);
                Assert.False(repo.RetrieveStatus().Any());
            }
        }
开发者ID:beulah444,项目名称:libgit2sharp,代码行数:24,代码来源:MergeFixture.cs

示例6: UnstagingUnknownPathsWithStrictUnmatchedExplicitPathsValidationThrows

        public void UnstagingUnknownPathsWithStrictUnmatchedExplicitPathsValidationThrows(string relativePath, FileStatus currentStatus)
        {
            using (var repo = new Repository(SandboxStandardTestRepo()))
            {
                Assert.Equal(currentStatus, repo.RetrieveStatus(relativePath));

                Assert.Throws<UnmatchedPathException>(() => repo.Unstage(relativePath, new ExplicitPathsOptions()));
            }
        }
开发者ID:beulah444,项目名称:libgit2sharp,代码行数:9,代码来源:UnstageFixture.cs

示例7: CanUnstageTargetOfARename

        public void CanUnstageTargetOfARename()
        {
            using (var repo = new Repository(SandboxStandardTestRepo()))
            {
                repo.Move("branch_file.txt", "renamed_branch_file.txt");

                RepositoryStatus oldStatus = repo.RetrieveStatus();
                Assert.Equal(1, oldStatus.RenamedInIndex.Count());
                Assert.Equal(FileStatus.RenamedInIndex, oldStatus["renamed_branch_file.txt"].State);

                repo.Unstage(new string[] { "renamed_branch_file.txt" });

                RepositoryStatus newStatus = repo.RetrieveStatus();
                Assert.Equal(0, newStatus.RenamedInIndex.Count());
                Assert.Equal(FileStatus.Untracked, newStatus["renamed_branch_file.txt"].State);
                Assert.Equal(FileStatus.Removed, newStatus["branch_file.txt"].State);
            }
        }
开发者ID:beulah444,项目名称:libgit2sharp,代码行数:18,代码来源:UnstageFixture.cs

示例8: UnstagingFileWithBadParamsThrows

 public void UnstagingFileWithBadParamsThrows()
 {
     var path = SandboxStandardTestRepoGitDir();
     using (var repo = new Repository(path))
     {
         Assert.Throws<ArgumentException>(() => repo.Unstage(string.Empty));
         Assert.Throws<ArgumentNullException>(() => repo.Unstage((string)null));
         Assert.Throws<ArgumentException>(() => repo.Unstage(new string[] { }));
         Assert.Throws<ArgumentException>(() => repo.Unstage(new string[] { null }));
     }
 }
开发者ID:beulah444,项目名称:libgit2sharp,代码行数:11,代码来源:UnstageFixture.cs

示例9: UnstagingANewFileWithAFullPathWhichEscapesOutOfTheWorkingDirAgainstAnOrphanedHeadThrows

        public void UnstagingANewFileWithAFullPathWhichEscapesOutOfTheWorkingDirAgainstAnOrphanedHeadThrows()
        {
            SelfCleaningDirectory scd = BuildSelfCleaningDirectory();

            string repoPath = InitNewRepository();

            using (var repo = new Repository(repoPath))
            {
                DirectoryInfo di = Directory.CreateDirectory(scd.DirectoryPath);

                const string filename = "unit_test.txt";
                string fullPath = Touch(di.FullName, filename, "some contents");

                Assert.Throws<ArgumentException>(() => repo.Unstage(fullPath));
            }
        }
开发者ID:beulah444,项目名称:libgit2sharp,代码行数:16,代码来源:UnstageFixture.cs

示例10: CanUnstageUnknownPathsAgainstAnOrphanedHeadWithLaxUnmatchedExplicitPathsValidation

        public void CanUnstageUnknownPathsAgainstAnOrphanedHeadWithLaxUnmatchedExplicitPathsValidation(string relativePath, FileStatus currentStatus)
        {
            using (var repo = new Repository(SandboxStandardTestRepo()))
            {
                repo.Refs.UpdateTarget("HEAD", "refs/heads/orphaned");
                Assert.True(repo.Info.IsHeadUnborn);

                Assert.Equal(currentStatus, repo.RetrieveStatus(relativePath));

                Assert.DoesNotThrow(() => repo.Unstage(relativePath));
                Assert.DoesNotThrow(() => repo.Unstage(relativePath, new ExplicitPathsOptions { ShouldFailOnUnmatchedPath = false }));
                Assert.Equal(currentStatus, repo.RetrieveStatus(relativePath));
            }
        }
开发者ID:beulah444,项目名称:libgit2sharp,代码行数:14,代码来源:UnstageFixture.cs

示例11: UnstagingUnknownPathsAgainstAnOrphanedHeadWithStrictUnmatchedExplicitPathsValidationThrows

        public void UnstagingUnknownPathsAgainstAnOrphanedHeadWithStrictUnmatchedExplicitPathsValidationThrows(string relativePath, FileStatus currentStatus)
        {
            using (var repo = new Repository(SandboxStandardTestRepo()))
            {
                repo.Refs.UpdateTarget("HEAD", "refs/heads/orphaned");
                Assert.True(repo.Info.IsHeadUnborn);

                Assert.Equal(currentStatus, repo.RetrieveStatus(relativePath));

                Assert.Throws<UnmatchedPathException>(() => repo.Unstage(relativePath, new ExplicitPathsOptions()));
            }
        }
开发者ID:beulah444,项目名称:libgit2sharp,代码行数:12,代码来源:UnstageFixture.cs

示例12: CanUnstageUntrackedFileAgainstAnOrphanedHead

        public void CanUnstageUntrackedFileAgainstAnOrphanedHead()
        {
            string repoPath = InitNewRepository();

            using (var repo = new Repository(repoPath))
            {
                const string relativePath = "a.txt";
                Touch(repo.Info.WorkingDirectory, relativePath, "hello test file\n");

                repo.Stage(relativePath);

                repo.Unstage(relativePath);
                RepositoryStatus status = repo.RetrieveStatus();
                Assert.Equal(0, status.Staged.Count());
                Assert.Equal(1, status.Untracked.Count());

                Assert.Throws<UnmatchedPathException>(() => repo.Unstage("i-dont-exist", new ExplicitPathsOptions()));
            }
        }
开发者ID:beulah444,项目名称:libgit2sharp,代码行数:19,代码来源:UnstageFixture.cs

示例13: CanUnstageTheRemovalOfAFile

        public void CanUnstageTheRemovalOfAFile()
        {
            string path = SandboxStandardTestRepo();
            using (var repo = new Repository(path))
            {
                int count = repo.Index.Count;

                const string filename = "deleted_staged_file.txt";

                string fullPath = Path.Combine(repo.Info.WorkingDirectory, filename);
                Assert.False(File.Exists(fullPath));

                Assert.Equal(FileStatus.Removed, repo.RetrieveStatus(filename));

                repo.Unstage(filename);
                Assert.Equal(count + 1, repo.Index.Count);

                Assert.Equal(FileStatus.Missing, repo.RetrieveStatus(filename));
            }
        }
开发者ID:beulah444,项目名称:libgit2sharp,代码行数:20,代码来源:UnstageFixture.cs

示例14: CanUnstageUnknownPathsWithLaxUnmatchedExplicitPathsValidation

        public void CanUnstageUnknownPathsWithLaxUnmatchedExplicitPathsValidation(string relativePath, FileStatus currentStatus)
        {
            using (var repo = new Repository(SandboxStandardTestRepo()))
            {
                Assert.Equal(currentStatus, repo.RetrieveStatus(relativePath));

                Assert.DoesNotThrow(() => repo.Unstage(relativePath, new ExplicitPathsOptions() { ShouldFailOnUnmatchedPath = false }));
                Assert.Equal(currentStatus, repo.RetrieveStatus(relativePath));
            }
        }
开发者ID:beulah444,项目名称:libgit2sharp,代码行数:10,代码来源:UnstageFixture.cs

示例15: CanUnstageSourceOfARename

        public void CanUnstageSourceOfARename()
        {
            using (var repo = new Repository(CloneStandardTestRepo()))
            {
                repo.Move("branch_file.txt", "renamed_branch_file.txt");

                RepositoryStatus oldStatus = repo.RetrieveStatus();
                Assert.Equal(1, oldStatus.RenamedInIndex.Count());
                Assert.Equal(FileStatus.Nonexistent, oldStatus["branch_file.txt"].State);
                Assert.Equal(FileStatus.RenamedInIndex, oldStatus["renamed_branch_file.txt"].State);

                repo.Unstage(new string[] { "branch_file.txt" });

                RepositoryStatus newStatus = repo.RetrieveStatus();
                Assert.Equal(0, newStatus.RenamedInIndex.Count());
                Assert.Equal(FileStatus.Missing, newStatus["branch_file.txt"].State);
                Assert.Equal(FileStatus.Added, newStatus["renamed_branch_file.txt"].State);
            }
        }
开发者ID:nulltoken,项目名称:libgit2sharp,代码行数:19,代码来源:UnstageFixture.cs


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