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


C# Index.Checkout方法代码示例

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


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

示例1: Execute

        public override void Execute()
        {
            if (Patch && (Track || BranchCreate.Length > 0 || RefLog || Merge || Force))
                throw new ArgumentException("--patch is incompatible with all other options");

            if (Force && Merge)
                throw new ArgumentException("git checkout: -f and -m are incompatible");

            if (Track && !(BranchCreate.Length > 0))
                throw new ArgumentException("Missing branch name; try -b");

            if (Arguments.Count == 0)
                Arguments.Add("HEAD");

            //Create a new branch and reassign the Repository to the new location before checkout.
            if (BranchCreate.Length > 0)
            {
                Branch.Create(Repository, BranchCreate);
                Arguments[0] = BranchCreate;
            }

            if (Arguments.Count == 1)
            {
                //Checkout the branch using the SHA1 or the name such as HEAD or master/HEAD
                Branch b = new Branch(Repository, Arguments[0]);
                if (b != null)
                {
                    b.Checkout();
                    return;
                }
            }

            //Todo: Add FileNameMatcher support. To be added when fnmatch is completed.
            //For now, pattern matching is not allowed. Please specify the files only.

            //Gain access to the Git index using the repository determined before command execution
            Index index = new Index(Repository);

            foreach (string arg in Arguments)
            {
                //Use full paths only to eliminate platform-based directory differences
                string path = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), arg));

                //Perform the validity tests outside of the index to handle the error messages
                if ((new FileInfo(path).Exists) || (new DirectoryInfo(path).Exists))
                    index.Checkout(path);
                else
                    results.FileNotFoundList.Add(path);
            }
        }
开发者ID:dev218,项目名称:GitSharp,代码行数:50,代码来源:CheckoutCommand.cs


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