本文整理汇总了C#中IGitTfsRemote.CleanupWorkspaceDirectory方法的典型用法代码示例。如果您正苦于以下问题:C# IGitTfsRemote.CleanupWorkspaceDirectory方法的具体用法?C# IGitTfsRemote.CleanupWorkspaceDirectory怎么用?C# IGitTfsRemote.CleanupWorkspaceDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGitTfsRemote
的用法示例。
在下文中一共展示了IGitTfsRemote.CleanupWorkspaceDirectory方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoFetch
protected virtual void DoFetch(IGitTfsRemote remote, bool stopOnFailMergeCommit)
{
if (remote.Repository.IsBare)
{
if(string.IsNullOrEmpty(BareBranch))
throw new GitTfsException("error : specify a git branch to fetch on...");
if (!remote.Repository.HasRef(GitRepository.ShortToLocalName(BareBranch)))
throw new GitTfsException("error : the specified git branch doesn't exist...");
if (!ForceFetch && remote.MaxCommitHash != remote.Repository.GetCommit(BareBranch).Sha)
throw new GitTfsException("error : fetch is not allowed when there is ahead commits!",
new List<string>() {"Remove ahead commits and retry", "use the --force option (ahead commits will be lost!)"});
}
// 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)
globals.Repository.MoveTfsRefForwardIfNeeded(remote);
var exportMetadatasFilePath = Path.Combine(globals.GitDir, "git-tfs_workitem_mapping.txt");
if (ExportMetadatas)
{
remote.ExportMetadatas = true;
remote.Repository.SetConfig(GitTfsConstants.ExportMetadatasConfigKey, "true");
if (!string.IsNullOrEmpty(ExportMetadatasFile))
{
if (File.Exists(ExportMetadatasFile))
{
File.Copy(ExportMetadatasFile, exportMetadatasFilePath);
}
else
throw new GitTfsException("error: the work items mapping file doesn't exist!");
}
}
else
{
if(remote.Repository.GetConfig(GitTfsConstants.ExportMetadatasConfigKey) == "true")
remote.ExportMetadatas = true;
}
remote.ExportWorkitemsMapping = new Dictionary<string, string>();
if (remote.ExportMetadatas && File.Exists(exportMetadatasFilePath))
{
try
{
foreach (var lineRead in File.ReadAllLines(exportMetadatasFilePath))
{
if (string.IsNullOrWhiteSpace(lineRead))
continue;
var values = lineRead.Split('|');
var oldWorkitem = values[0].Trim();
if(!remote.ExportWorkitemsMapping.ContainsKey(oldWorkitem))
remote.ExportWorkitemsMapping.Add(oldWorkitem, values[1].Trim());
}
}
catch (Exception)
{
throw new GitTfsException("error: bad format of workitems mapping file! One line format should be: OldWorkItemId|NewWorkItemId");
}
}
try
{
remote.Fetch(stopOnFailMergeCommit);
}
finally
{
Trace.WriteLine("Cleaning...");
remote.CleanupWorkspaceDirectory();
if (remote.Repository.IsBare)
remote.Repository.UpdateRef(GitRepository.ShortToLocalName(BareBranch), remote.MaxCommitHash);
}
}
示例2: DoFetch
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);
}
}
示例3: FetchRemote
private IFetchResult FetchRemote(IGitTfsRemote tfsRemote, bool stopOnFailMergeCommit, bool createBranch = true)
{
Trace.WriteLine("Try fetching changesets...");
var fetchResult = tfsRemote.Fetch(stopOnFailMergeCommit);
Trace.WriteLine("Changesets fetched!");
if (createBranch && fetchResult.IsSuccess && tfsRemote.Id != GitTfsConstants.DefaultRepositoryId)
{
Trace.WriteLine("Try creating the local branch...");
if (!_globals.Repository.CreateBranch("refs/heads/" + tfsRemote.Id, tfsRemote.MaxCommitHash))
_stdout.WriteLine("warning: Fail to create local branch ref file!");
else
Trace.WriteLine("Local branch created!");
}
Trace.WriteLine("Cleaning...");
tfsRemote.CleanupWorkspaceDirectory();
return fetchResult;
}
示例4: FetchRemote
private IFetchResult FetchRemote(IGitTfsRemote tfsRemote, bool stopOnFailMergeCommit, bool createBranch = true, IRenameResult renameResult = null)
{
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))
_stdout.WriteLine("warning: Fail to create local branch ref file!");
else
Trace.WriteLine("Local branch created!");
}
else
{
_stdout.WriteLine("info: local branch ref already exists!");
}
}
return fetchResult;
}
finally
{
Trace.WriteLine("Cleaning...");
tfsRemote.CleanupWorkspaceDirectory();
}
}
示例5: DoFetch
protected virtual void DoFetch(IGitTfsRemote remote)
{
if (remote.Repository.IsBare)
{
if(string.IsNullOrEmpty(BareBranch))
throw new GitTfsException("error : specify a git branch to fetch on...");
if (!remote.Repository.HasRef(GitRepository.ShortToLocalName(BareBranch)))
throw new GitTfsException("error : the specified git branch doesn't exist...");
if (!ForceFetchBare && remote.MaxCommitHash != remote.Repository.GetCommit(BareBranch).Sha)
throw new GitTfsException("error : fetch is not allowed when there is ahead commits!",
new List<string>() {"Remove ahead commits and retry", "use the --force option (ahead commits will be lost!)"});
}
// 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.
globals.Repository.MoveTfsRefForwardIfNeeded(remote);
remote.Fetch();
Trace.WriteLine("Cleaning...");
remote.CleanupWorkspaceDirectory();
if(remote.Repository.IsBare)
remote.Repository.UpdateRef(GitRepository.ShortToLocalName(BareBranch), remote.MaxCommitHash);
}
示例6: Cleanup
private void Cleanup(IGitTfsRemote remote)
{
Trace.TraceInformation("Cleaning up workspaces directory for TFS remote " + remote.Id);
remote.CleanupWorkspaceDirectory();
}
示例7: Cleanup
private void Cleanup(IGitTfsRemote remote)
{
_stdout.WriteLine("Cleaning up workspaces directory for TFS remote " + remote.Id);
remote.CleanupWorkspaceDirectory();
}
示例8: DoFetch
protected virtual void DoFetch(IGitTfsRemote remote)
{
// 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.
globals.Repository.MoveTfsRefForwardIfNeeded(remote);
remote.Fetch();
Trace.WriteLine("Cleaning...");
remote.CleanupWorkspaceDirectory();
}