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


C# Repository.Reset方法代码示例

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


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

示例1: ResettingWithBadParamsThrows

 public void ResettingWithBadParamsThrows()
 {
     using (var repo = new Repository(BareTestRepoPath))
     {
         Assert.Throws<ArgumentNullException>(() => repo.Reset(ResetOptions.Soft, null));
         Assert.Throws<ArgumentException>(() => repo.Reset(ResetOptions.Soft, ""));
         Assert.Throws<LibGit2Exception>(() => repo.Reset(ResetOptions.Soft, Constants.UnknownSha));
     }
 }
开发者ID:kcomkar,项目名称:libgit2sharp,代码行数:9,代码来源:ResetFixture.cs

示例2: ResettingWithBadParamsThrows

 public void ResettingWithBadParamsThrows()
 {
     using (var repo = new Repository(BareTestRepoPath))
     {
         Assert.Throws<ArgumentNullException>(() => repo.Reset(ResetMode.Soft, (string)null));
         Assert.Throws<ArgumentNullException>(() => repo.Reset(ResetMode.Soft, (Commit)null));
         Assert.Throws<ArgumentException>(() => repo.Reset(ResetMode.Soft, ""));
         Assert.Throws<LibGit2SharpException>(() => repo.Reset(ResetMode.Soft, Constants.UnknownSha));
         Assert.Throws<LibGit2SharpException>(() => repo.Reset(ResetMode.Soft, repo.Head.Tip.Tree.Sha));
     }
 }
开发者ID:AndersKroghDk,项目名称:libgit2sharp,代码行数:11,代码来源:ResetHeadFixture.cs

示例3: ResettingWithBadParamsThrows

 public void ResettingWithBadParamsThrows()
 {
     string path = SandboxBareTestRepo();
     using (var repo = new Repository(path))
     {
         Assert.Throws<ArgumentNullException>(() => repo.Reset(ResetMode.Soft, (string)null));
         Assert.Throws<ArgumentNullException>(() => repo.Reset(ResetMode.Soft, (Commit)null));
         Assert.Throws<ArgumentException>(() => repo.Reset(ResetMode.Soft, ""));
         Assert.Throws<NotFoundException>(() => repo.Reset(ResetMode.Soft, Constants.UnknownSha));
         Assert.Throws<InvalidSpecificationException>(() => repo.Reset(ResetMode.Soft, repo.Head.Tip.Tree.Sha));
     }
 }
开发者ID:beulah444,项目名称:libgit2sharp,代码行数:12,代码来源:ResetHeadFixture.cs

示例4: MixedResetRefreshesTheIndex

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

            using (var repo = new Repository(repoPath, new RepositoryOptions { Identity = Constants.Identity }))
            {
                FeedTheRepository(repo);

                var oldHeadId = repo.Head.Tip.Id;

                Tag tag = repo.Tags["mytag"];

                var before = DateTimeOffset.Now.TruncateMilliseconds();

                repo.Reset(ResetMode.Mixed, tag.CanonicalName);

                Assert.Equal(FileStatus.ModifiedInWorkdir, repo.RetrieveStatus("a.txt"));

                AssertRefLogEntry(repo, "HEAD",
                                  string.Format("reset: moving to {0}", tag.Target.Sha),
                                  oldHeadId,
                                  tag.Target.Id,
                                  Constants.Identity, before);

                AssertRefLogEntry(repo, "refs/heads/mybranch",
                                  string.Format("reset: moving to {0}", tag.Target.Sha),
                                  oldHeadId,
                                  tag.Target.Id,
                                  Constants.Identity, before);
            }
        }
开发者ID:PKRoma,项目名称:libgit2sharp,代码行数:31,代码来源:ResetHeadFixture.cs

示例5: HardResetUpdatesTheContentOfTheWorkingDirectory

        public void HardResetUpdatesTheContentOfTheWorkingDirectory()
        {
            bool progressCalled = false;

            string path = SandboxStandardTestRepo();
            using (var repo = new Repository(path))
            {
                var names = new DirectoryInfo(repo.Info.WorkingDirectory).GetFileSystemInfos().Select(fsi => fsi.Name).ToList();

                File.Delete(Path.Combine(repo.Info.WorkingDirectory, "README"));
                Touch(repo.Info.WorkingDirectory, "WillNotBeRemoved.txt", "content\n");

                Assert.True(names.Count > 4);

                var commit = repo.Lookup<Commit>("HEAD~3");
                repo.Reset(ResetMode.Hard, commit, new CheckoutOptions()
                {
                    OnCheckoutProgress = (_path, _completed, _total) => { progressCalled = true; },
                });

                names = new DirectoryInfo(repo.Info.WorkingDirectory).GetFileSystemInfos().Select(fsi => fsi.Name).ToList();
                names.Sort(StringComparer.Ordinal);

                Assert.Equal(true, progressCalled);
                Assert.Equal(new[] { ".git", "README", "WillNotBeRemoved.txt", "branch_file.txt", "new.txt", "new_untracked_file.txt" }, names);
            }
        }
开发者ID:PKRoma,项目名称:libgit2sharp,代码行数:27,代码来源:ResetHeadFixture.cs

示例6: MixedResetRefreshesTheIndex

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

            using (var repo = new Repository(repoPath))
            {
                FeedTheRepository(repo);

                var oldHeadId = repo.Head.Tip.Id;

                Tag tag = repo.Tags["mytag"];

                repo.Reset(ResetMode.Mixed, tag.CanonicalName);

                Assert.Equal(FileStatus.Modified, repo.RetrieveStatus("a.txt"));

                AssertRefLogEntry(repo, "HEAD",
                                  tag.Target.Id,
                                  string.Format("reset: moving to {0}", tag.Target.Sha),
                                  oldHeadId);

                AssertRefLogEntry(repo, "refs/heads/mybranch",
                                  tag.Target.Id,
                                  string.Format("reset: moving to {0}", tag.Target.Sha),
                                  oldHeadId);
            }
        }
开发者ID:nulltoken,项目名称:libgit2sharp,代码行数:27,代码来源:ResetHeadFixture.cs

示例7: MixedResetInABareRepositoryThrows

 public void MixedResetInABareRepositoryThrows()
 {
     using (var repo = new Repository(BareTestRepoPath))
     {
         Assert.Throws<BareRepositoryException>(() => repo.Reset(ResetOptions.Mixed));
     }
 }
开发者ID:TiThompson,项目名称:libgit2sharp,代码行数:7,代码来源:ResetHeadFixture.cs

示例8: ResettingInABareRepositoryThrows

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

示例9: CanAmendACommitWithMoreThanOneParent

        public void CanAmendACommitWithMoreThanOneParent()
        {
            string path = CloneStandardTestRepo();
            using (var repo = new Repository(path))
            {
                var mergedCommit = repo.Lookup<Commit>("be3563a");
                Assert.NotNull(mergedCommit);
                Assert.Equal(2, mergedCommit.Parents.Count());

                repo.Reset(ResetOptions.Soft, mergedCommit.Sha);

                CreateAndStageANewFile(repo);
                const string commitMessage = "I'm rewriting the history!";

                Commit amendedCommit = repo.Commit(commitMessage, DummySignature, DummySignature, true);

                AssertCommitHasBeenAmended(repo, amendedCommit, mergedCommit);

                // Assert a reflog entry is created
                var reflogEntry = repo.Refs.Log("HEAD").First();
                Assert.Equal(amendedCommit.Committer, reflogEntry.Commiter);
                Assert.Equal(amendedCommit.Id, reflogEntry.To);
                Assert.Equal(string.Format("commit (amend): {0}", commitMessage), reflogEntry.Message);
            }
        }
开发者ID:TiThompson,项目名称:libgit2sharp,代码行数:25,代码来源:CommitFixture.cs

示例10: MixedResetInABareRepositoryThrows

 public void MixedResetInABareRepositoryThrows()
 {
     using (var repo = new Repository(BareTestRepoPath))
     {
         Assert.Throws<LibGit2Exception>(() => repo.Reset(ResetOptions.Mixed, repo.Head.Tip.Sha));
     }
 }
开发者ID:kcomkar,项目名称:libgit2sharp,代码行数:7,代码来源:ResetFixture.cs

示例11: CanAmendACommitWithMoreThanOneParent

        public void CanAmendACommitWithMoreThanOneParent()
        {
            string path = CloneStandardTestRepo();
            using (var repo = new Repository(path))
            {
                var mergedCommit = repo.Lookup<Commit>("be3563a");
                Assert.NotNull(mergedCommit);
                Assert.Equal(2, mergedCommit.Parents.Count());

                repo.Reset(ResetMode.Soft, mergedCommit.Sha);

                CreateAndStageANewFile(repo);
                const string commitMessage = "I'm rewriting the history!";

                Commit amendedCommit = repo.Commit(commitMessage, Constants.Signature, Constants.Signature,
                    new CommitOptions { AmendPreviousCommit = true });

                AssertCommitHasBeenAmended(repo, amendedCommit, mergedCommit);

                AssertRefLogEntry(repo, "HEAD",
                                  amendedCommit.Id,
                                  string.Format("commit (amend): {0}", commitMessage),
                                  mergedCommit.Id,
                                  amendedCommit.Committer);
            }
        }
开发者ID:nulltoken,项目名称:libgit2sharp,代码行数:26,代码来源:CommitFixture.cs

示例12: ResettingInABareRepositoryThrows

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

示例13: ResetANewlyInitializedRepositoryThrows

        public void ResetANewlyInitializedRepositoryThrows(bool isBare)
        {
            string repoPath = InitNewRepository(isBare);

            using (var repo = new Repository(repoPath))
            {
                Assert.Throws<UnbornBranchException>(() => repo.Reset(ResetMode.Soft));
            }
        }
开发者ID:beulah444,项目名称:libgit2sharp,代码行数:9,代码来源:ResetHeadFixture.cs

示例14: ResetANewlyInitializedRepositoryThrows

        public void ResetANewlyInitializedRepositoryThrows(bool isBare)
        {
            string repoPath = InitNewRepository(isBare);

            using (var repo = new Repository(repoPath))
            {
                Assert.Throws<LibGit2SharpException>(() => repo.Reset(ResetOptions.Soft));
            }
        }
开发者ID:JenekX,项目名称:libgit2sharp,代码行数:9,代码来源:ResetHeadFixture.cs

示例15: ResetANewlyInitializedNonBareRepositoryThrows

        public void ResetANewlyInitializedNonBareRepositoryThrows()
        {
            string repoPath = InitNewRepository(false);

            using (var repo = new Repository(repoPath))
            {
                Assert.Throws<UnbornBranchException>(() => repo.Reset());
            }
        }
开发者ID:beulah444,项目名称:libgit2sharp,代码行数:9,代码来源:ResetIndexFixture.cs


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