Sep.Git.Tfs.Commands.InitBranch.CloneAll C# (CSharp) Method

CloneAll() private method

private CloneAll ( string gitRemote ) : int
gitRemote string
return int
        private int CloneAll(string gitRemote)
        {
            if (CloneAllBranches && NoFetch)
                throw new GitTfsException("error: --no-fetch cannot be used with --all");

            _globals.Repository.SetConfig(GitTfsConstants.IgnoreBranches, false.ToString());

            var defaultRemote = InitFromDefaultRemote();

            List<BranchDatas> childBranchesToInit;
            if (gitRemote == null)
            {
                childBranchesToInit = GetChildBranchesToInit(defaultRemote);
            }
            else
            {
                var gitRepositoryBranchRemotes = defaultRemote.Repository.GetGitRemoteBranches(gitRemote);
                var childBranchPaths = new Dictionary<string, BranchDatas>();
                foreach (var branchRemote in gitRepositoryBranchRemotes)
                {
                    var branchRemoteChangesetInfos = _globals.Repository.GetLastParentTfsCommits(branchRemote);
                    var firstRemoteChangesetInfo = branchRemoteChangesetInfos.FirstOrDefault();

                    if (firstRemoteChangesetInfo == null)
                    {
                        continue;
                    }

                    var branchRemoteTfsPath = firstRemoteChangesetInfo.Remote.TfsRepositoryPath;

                    if (!childBranchPaths.ContainsKey(branchRemoteTfsPath))
                        childBranchPaths.Add(branchRemoteTfsPath, new BranchDatas { TfsRepositoryPath = branchRemoteTfsPath });
                }

                childBranchesToInit = childBranchPaths.Values.ToList();
            }

            if (!childBranchesToInit.Any())
            {
                Trace.TraceInformation("No other Tfs branches found.");
            }
            else
            {
                InitializeBranches(defaultRemote, childBranchesToInit);
            }

            return GitTfsExitCodes.OK;
        }