本文整理汇总了C#中IRepository.ClearLock方法的典型用法代码示例。如果您正苦于以下问题:C# IRepository.ClearLock方法的具体用法?C# IRepository.ClearLock怎么用?C# IRepository.ClearLock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRepository
的用法示例。
在下文中一共展示了IRepository.ClearLock方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Deploy
public void Deploy(IRepository repository, ChangeSet changeSet, string deployer, bool clean)
{
ITracer tracer = _traceFactory.GetTracer();
IDisposable deployStep = null;
ILogger innerLogger = null;
string targetBranch = null;
// If we don't get a changeset, find out what branch we should be deploying and get the commit ID from it
if (changeSet == null)
{
targetBranch = _settings.GetBranch();
changeSet = repository.GetChangeSet(targetBranch);
}
string id = changeSet.Id;
IDeploymentStatusFile statusFile = null;
try
{
deployStep = tracer.Step("DeploymentManager.Deploy(id)");
// Remove the old log file for this deployment id
string logPath = GetLogPath(id);
FileSystemHelpers.DeleteFileSafe(logPath);
statusFile = GetOrCreateStatusFile(changeSet, tracer, deployer);
statusFile.MarkPending();
ILogger logger = GetLogger(changeSet.Id);
using (tracer.Step("Updating to specific changeset"))
{
innerLogger = logger.Log(Resources.Log_UpdatingBranch, targetBranch ?? id);
using (var writer = new ProgressWriter())
{
// Update to the the specific changeset
repository.ClearLock();
repository.Update(id);
}
}
using (tracer.Step("Updating submodules"))
{
innerLogger = logger.Log(Resources.Log_UpdatingSubmodules);
repository.UpdateSubmodules();
}
if (clean)
{
tracer.Trace("Cleaning {0} repository", repository.RepositoryType);
innerLogger = logger.Log(Resources.Log_CleaningRepository, repository.RepositoryType);
repository.Clean();
}
// set to null as Build() below takes over logging
innerLogger = null;
// Perform the build deployment of this changeset
Build(id, tracer, deployStep);
}
catch (Exception ex)
{
if (innerLogger != null)
{
innerLogger.Log(ex);
}
if (statusFile != null)
{
statusFile.MarkFailed();
}
tracer.TraceError(ex);
if (deployStep != null)
{
deployStep.Dispose();
}
throw;
}
}
示例2: Fetch
public Task Fetch(IRepository repository, DeploymentInfo deploymentInfo, string targetBranch, ILogger logger)
{
repository.ClearLock();
repository.FetchWithoutConflict(deploymentInfo.RepositoryUrl, targetBranch);
return TaskHelpers.Completed();
}
示例3: Fetch
public void Fetch(IRepository repository, DeploymentInfo deploymentInfo, string targetBranch, ILogger logger)
{
repository.ClearLock();
repository.FetchWithoutConflict(deploymentInfo.RepositoryUrl, targetBranch);
}
示例4: Sync
internal ChangeSet Sync(DropboxHandler.DropboxInfo deploymentInfo, string branch, ILogger logger, IRepository repository)
{
DropboxDeployInfo info = deploymentInfo.DeployInfo;
_logger = logger;
_successCount = 0;
_fileCount = 0;
_failedCount = 0;
_retriedCount = 0;
if (_settings.GetValue(CursorKey) != info.OldCursor)
{
throw new InvalidOperationException(Resources.Error_MismatchDropboxCursor);
}
if (!repository.IsEmpty())
{
// git checkout --force <branch>
repository.ClearLock();
repository.Update(branch);
}
ChangeSet changeSet;
string message = null;
try
{
using (_tracer.Step("Synch with Dropbox"))
{
// Sync dropbox => repository directory
ApplyChanges(deploymentInfo);
}
message = String.Format(CultureInfo.CurrentCulture,
Resources.Dropbox_Synchronized,
deploymentInfo.DeployInfo.Deltas.Count());
}
catch (Exception)
{
message = String.Format(CultureInfo.CurrentCulture,
Resources.Dropbox_SynchronizedWithFailure,
_successCount,
deploymentInfo.DeployInfo.Deltas.Count(),
_failedCount);
throw;
}
finally
{
_logger.Log(message);
_logger.Log(String.Format("{0} downloaded files, {1} successful retries.", _fileCount, _retriedCount));
_status.Open(deploymentInfo.TargetChangeset.Id).UpdateMessage(message);
_status.Open(deploymentInfo.TargetChangeset.Id).UpdateProgress(String.Format(CultureInfo.CurrentCulture, Resources.Dropbox_Committing, _successCount));
// Commit anyway even partial change
changeSet = repository.Commit(message, String.Format("{0} <{1}>", info.UserName, info.Email));
}
// Save new dropboc cursor
LogInfo("Update dropbox cursor");
_settings.SetValue(CursorKey, info.NewCursor);
return changeSet;
}
示例5: Sync
internal async Task<ChangeSet> Sync(DropboxInfo dropboxInfo, string branch, IRepository repository)
{
DropboxDeployInfo deployInfo = dropboxInfo.DeployInfo;
ResetStats();
if (_settings.GetValue(CursorKey) != deployInfo.OldCursor)
{
throw new InvalidOperationException(Resources.Error_MismatchDropboxCursor);
}
// initial sync, remove default content
// for simplicity, we do it blindly whether or not in-place
// given the end result is the same
if (String.IsNullOrEmpty(deployInfo.OldCursor) && DeploymentHelper.IsDefaultWebRootContent(_environment.WebRootPath, _fileSystem))
{
string hoststarthtml = Path.Combine(_environment.WebRootPath, Constants.HostingStartHtml);
FileSystemHelpers.DeleteFileSafe(_fileSystem, hoststarthtml);
}
if (!repository.IsEmpty())
{
// git checkout --force <branch>
repository.ClearLock();
repository.Update(branch);
}
ChangeSet changeSet = null;
string message = null;
try
{
using (_tracer.Step("Sync with Dropbox"))
{
if (dropboxInfo.OAuthVersion == 2)
{
// Fetch the deltas
await UpdateDropboxDeployInfo(deployInfo);
}
// Sync dropbox => repository directory
await ApplyChanges(dropboxInfo, useOAuth20: dropboxInfo.OAuthVersion == 2);
}
message = String.Format(CultureInfo.CurrentCulture,
Resources.Dropbox_Synchronized,
deployInfo.Deltas.Count);
}
catch (Exception)
{
message = String.Format(CultureInfo.CurrentCulture,
Resources.Dropbox_SynchronizedWithFailure,
_successCount,
deployInfo.Deltas.Count,
_failedCount);
throw;
}
finally
{
Logger.Log(message);
Logger.Log(String.Format("{0} downloaded files, {1} successful retries.", _fileCount, _retriedCount));
IDeploymentStatusFile statusFile = _status.Open(dropboxInfo.TargetChangeset.Id);
statusFile.UpdateMessage(message);
statusFile.UpdateProgress(String.Format(CultureInfo.CurrentCulture, Resources.Dropbox_Committing, _successCount));
// Commit anyway even partial change
if (repository.Commit(message, String.Format("{0} <{1}>", deployInfo.UserName, deployInfo.Email ?? deployInfo.UserName)))
{
changeSet = repository.GetChangeSet("HEAD");
}
}
// Save new dropboc cursor
LogInfo("Update dropbox cursor");
_settings.SetValue(CursorKey, deployInfo.NewCursor);
return changeSet;
}
示例6: DeployAsync
public async Task DeployAsync(IRepository repository, ChangeSet changeSet, string deployer, bool clean, bool needFileUpdate)
{
using (var deploymentAnalytics = new DeploymentAnalytics(_analytics, _settings))
{
Exception exception = null;
ITracer tracer = _traceFactory.GetTracer();
IDisposable deployStep = null;
ILogger innerLogger = null;
string targetBranch = null;
// If we don't get a changeset, find out what branch we should be deploying and get the commit ID from it
if (changeSet == null)
{
targetBranch = _settings.GetBranch();
changeSet = repository.GetChangeSet(targetBranch);
}
string id = changeSet.Id;
IDeploymentStatusFile statusFile = null;
try
{
deployStep = tracer.Step("DeploymentManager.Deploy(id)");
// Remove the old log file for this deployment id
string logPath = GetLogPath(id);
FileSystemHelpers.DeleteFileSafe(logPath);
statusFile = GetOrCreateStatusFile(changeSet, tracer, deployer);
statusFile.MarkPending();
ILogger logger = GetLogger(changeSet.Id);
repository.ClearLock();
if (needFileUpdate)
{
using (tracer.Step("Updating to specific changeset"))
{
innerLogger = logger.Log(Resources.Log_UpdatingBranch, targetBranch ?? id);
using (var writer = new ProgressWriter())
{
// Update to the specific changeset or branch
repository.Update(targetBranch ?? id);
}
}
}
using (tracer.Step("Updating submodules"))
{
innerLogger = logger.Log(Resources.Log_UpdatingSubmodules);
repository.UpdateSubmodules();
}
if (clean)
{
tracer.Trace("Cleaning {0} repository", repository.RepositoryType);
innerLogger = logger.Log(Resources.Log_CleaningRepository, repository.RepositoryType);
repository.Clean();
}
// set to null as Build() below takes over logging
innerLogger = null;
// Perform the build deployment of this changeset
await Build(id, tracer, deployStep, repository, deploymentAnalytics);
}
catch (Exception ex)
{
exception = ex;
if (innerLogger != null)
{
innerLogger.Log(ex);
}
if (statusFile != null)
{
MarkStatusComplete(statusFile, success: false);
}
tracer.TraceError(ex);
deploymentAnalytics.Error = ex.ToString();
if (deployStep != null)
{
deployStep.Dispose();
}
}
// Reload status file with latest updates
statusFile = _status.Open(id);
if (statusFile != null)
{
await _hooksManager.PublishEventAsync(HookEventTypes.PostDeployment, statusFile);
//.........这里部分代码省略.........