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


C# IRepository.Reset方法代码示例

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


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

示例1: 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(IRepository repo)
        {
            // Reset the index and the working tree.
            repo.Reset(ResetMode.Hard);

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

示例2: AssertStage

 private static void AssertStage(bool? ignorecase, IRepository repo, string path)
 {
     try
     {
         repo.Index.Stage(path);
         Assert.Equal(FileStatus.Added, repo.Index.RetrieveStatus(path));
         repo.Reset();
         Assert.Equal(FileStatus.Untracked, repo.Index.RetrieveStatus(path));
     }
     catch (ArgumentException)
     {
         Assert.False(ignorecase ?? true);
     }
 }
开发者ID:KindDragon,项目名称:libgit2sharp,代码行数:14,代码来源:StageFixture.cs

示例3: UpdateGit

        bool UpdateGit(IRepository repo)
        {
            var recompileNeeded = true;
            using (var _ = new ChangingOutput("Updating source code . . ."))
            {
                _.FinishLine();

                using (var t = new ChangingOutput("Fetching updates from GitHub . . ."))
                {
                    repo.Fetch("origin", new FetchOptions()
                    {
                        OnTransferProgress = (x) =>
                        {
                            t.PrintProgress((double) x.ReceivedObjects/x.TotalObjects);
                            return true;
                        }
                    });

                    t.PrintResult(true);
                }

                var currentCommit = repo.Head.Tip;
                MergeResult result;
                try
                {
                    using (var t = new ChangingOutput("Merging in updates . . ."))
                    {
                        result = repo.Merge(repo.Head.TrackedBranch, new Signature(Environment.UserName, "[email protected]", DateTime.Now),
                            new MergeOptions
                            {
                                CommitOnSuccess = true,
                                FileConflictStrategy = CheckoutFileConflictStrategy.Ours,
                                MergeFileFavor = MergeFileFavor.Normal,
                                OnCheckoutProgress = (n, processed, total) =>
                                {
                                    t.PrintProgress((double) processed/total);
                                },
                            });

                        t.PrintResult(result.Status != MergeStatus.Conflicts);

                    }

                    if (result.Status == MergeStatus.UpToDate)
                    {
                        Console.WriteLine("Source was already up to date");
                        recompileNeeded = RestoreDeleteFiles(repo);
                        _.PrintResult(true);
                    }
                    else if (result.Status == MergeStatus.Conflicts)
                    {
                        throw new MergeConflictException();
                    }
                    else
                    {
                        Console.WriteLine("Updated to {0} : {1}", result.Commit.Sha.Substring(0, 10), result.Commit.MessageShort);
                        _.PrintResult(true);
                    }
                }
                catch (MergeConflictException)
                {
                    Console.WriteLine("Merge resulted in conflicts. This usually indictates a user-edited source");
                    Console.WriteLine("Your Aura will NOT be updated until you undo your changes to the files.");
                    Console.WriteLine("This is a bad thing, so fix it ASAP.");
                    Console.WriteLine("NOTE: If you're trying to make configuration changes, use the \"user\" folders instead.");
                    Console.WriteLine("Rolling back merge...");
                    repo.Reset(currentCommit);
                    recompileNeeded = false;
                    _.PrintResult(false);
                }

                return recompileNeeded;
            }
        }
开发者ID:Xcelled,项目名称:aura-frontend,代码行数:74,代码来源:UpdateSource.cs


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