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

FetchRemote() private method

Fetch changesets from tfsRemote, optionally stopping on failed merge commits.
private FetchRemote ( IGitTfsRemote tfsRemote, bool stopOnFailMergeCommit, bool createBranch = true, IRenameResult renameResult = null, int startingChangesetId = -1 ) : IFetchResult
tfsRemote IGitTfsRemote The TFS Remote from which to fetch changesets.
stopOnFailMergeCommit bool /// Indicates whether to stop fetching when encountering a failed merge commit. ///
createBranch bool /// If true, create a local Git branch starting from the earliest possible changeset in the given /// . ///
renameResult IRenameResult
startingChangesetId int
return IFetchResult
        private IFetchResult FetchRemote(IGitTfsRemote tfsRemote, bool stopOnFailMergeCommit, bool createBranch = true, IRenameResult renameResult = null, int startingChangesetId = -1)
        {
            try
            {
                Trace.WriteLine("Try fetching changesets...");
                var fetchResult = tfsRemote.Fetch(stopOnFailMergeCommit, renameResult: renameResult);
                Trace.WriteLine("Changesets fetched!");

                if (fetchResult.IsSuccess && createBranch && tfsRemote.Id != GitTfsConstants.DefaultRepositoryId)
                {
                    Trace.WriteLine("Try creating the local branch...");
                    var branchRef = tfsRemote.Id.ToLocalGitRef();
                    if (!_globals.Repository.HasRef(branchRef))
                    {
                        if (!_globals.Repository.CreateBranch(branchRef, tfsRemote.MaxCommitHash))
                            Trace.TraceWarning("warning: Fail to create local branch ref file!");
                        else
                            Trace.WriteLine("Local branch created!");
                    }
                    else
                    {
                        Trace.TraceInformation("info: local branch ref already exists!");
                    }
                }
                return fetchResult;
            }
            finally
            {
                Trace.WriteLine("Cleaning...");
                tfsRemote.CleanupWorkspaceDirectory();
            }
        }