Sep.Git.Tfs.Commands.Branch.CreateRemote C# (CSharp) Method

CreateRemote() private method

private CreateRemote ( string tfsPath, string gitBranchNameExpected = null ) : int
tfsPath string
gitBranchNameExpected string
return int
        private int CreateRemote(string tfsPath, string gitBranchNameExpected = null)
        {
            bool checkInCurrentBranch = false;
            tfsPath.AssertValidTfsPath();
            Trace.WriteLine("Getting commit informations...");
            var commit = _globals.Repository.GetCurrentTfsCommit();
            if (commit == null)
            {
                checkInCurrentBranch = true;
                var parents = _globals.Repository.GetLastParentTfsCommits(_globals.Repository.GetCurrentCommit());
                if (!parents.Any())
                    throw new GitTfsException("error : no tfs remote parent found!");
                commit = parents.First();
            }
            var remote = commit.Remote;
            Trace.WriteLine("Creating branch in TFS...");
            remote.Tfs.CreateBranch(remote.TfsRepositoryPath, tfsPath, commit.ChangesetId, Comment ?? "Creation branch " + tfsPath);
            Trace.WriteLine("Init branch in local repository...");
            _initBranch.DontCreateGitBranch = true;
            var returnCode = _initBranch.Run(tfsPath, gitBranchNameExpected);

            if (returnCode != GitTfsExitCodes.OK || !checkInCurrentBranch)
                return returnCode;

            _rcheckin.RebaseOnto(_initBranch.RemoteCreated.RemoteRef, commit.GitCommit);
            _globals.UserSpecifiedRemoteId = _initBranch.RemoteCreated.Id;
            return _rcheckin.Run();
        }