private void SetupMetadataExport(IGitTfsRemote remote) { var exportInitializer = new ExportMetadatasInitializer(_globals); var shouldExport = _globals.Repository.GetConfig(GitTfsConstants.ExportMetadatasConfigKey) == "true"; exportInitializer.InitializeRemote(remote, shouldExport); }
protected virtual void DoFetch(IGitTfsRemote remote, bool stopOnFailMergeCommit) { var bareBranch = string.IsNullOrEmpty(BareBranch) ? remote.Id : BareBranch; // It is possible that we have outdated refs/remotes/tfs/<id>. // E.g. someone already fetched changesets from TFS into another git repository and we've pulled it since // in that case tfs fetch will retrieve same changes again unnecessarily. To prevent it we will scan tree from HEAD and see if newer changesets from // TFS exists (by checking git-tfs-id mark in commit's comments). // The process is similar to bootstrapping. if (!ForceFetch) { if (!remote.Repository.IsBare) remote.Repository.MoveTfsRefForwardIfNeeded(remote); else remote.Repository.MoveTfsRefForwardIfNeeded(remote, bareBranch); } if (!ForceFetch && remote.Repository.IsBare && remote.Repository.HasRef(GitRepository.ShortToLocalName(bareBranch)) && remote.MaxCommitHash != remote.Repository.GetCommit(bareBranch).Sha) { throw new GitTfsException("error : fetch is not allowed when there is ahead commits!", new[] {"Remove ahead commits and retry", "use the --force option (ahead commits will be lost!)"}); } var metadataExportInitializer = new ExportMetadatasInitializer(globals); bool shouldExport = ExportMetadatas || remote.Repository.GetConfig(GitTfsConstants.ExportMetadatasConfigKey) == "true"; if (ExportMetadatas) { metadataExportInitializer.InitializeConfig(remote.Repository, ExportMetadatasFile); } metadataExportInitializer.InitializeRemote(remote, shouldExport); try { if (InitialChangeset.HasValue) { properties.InitialChangeset = InitialChangeset.Value; properties.PersistAllOverrides(); remote.QuickFetch(InitialChangeset.Value); remote.Fetch(stopOnFailMergeCommit); } else { remote.Fetch(stopOnFailMergeCommit,upToChangeSet); } } finally { Trace.WriteLine("Cleaning..."); remote.CleanupWorkspaceDirectory(); if (remote.Repository.IsBare) remote.Repository.UpdateRef(GitRepository.ShortToLocalName(bareBranch), remote.MaxCommitHash); } }