public void Initialize() { string asmDir = PathEx.GetDirectoryName(typeof(GitTests).Assembly.Location); this.rootDir = PathEx.Combine(asmDir, "test-root"); DirectoryEx.Create(this.rootDir); DirectoryEx.Clear(this.rootDir); if (FileEx.Exists(credentialsFilePath)) { var lines = File.ReadAllLines(credentialsFilePath); this.userName = lines[0]; this.password = SecureStringExtensions.ToSecureString(lines[1]); } var fileOps = new TestFileOperationsExecuter(Path.Combine(this.rootDir, "agent")); //var fileOps = new SimulatedFileOperationsExecuter(fileOps); //fileOps.MessageLogged += (s, e) => TestLogger.Instance.Log(e.Level, e.Message); this.fileOps = fileOps; this.processExecuter = new TestRemoteProcessExecuter(); this.jobExecuter = new TestRemoteJobExecuter(); }
public void DeleteWorkspace(SourceControlContext context) { DirectoryEx.Clear(context.WorkspaceDiskPath); }
private void DeleteWorkspaceInternal(SourceControlContext context) { DirectoryEx.Clear(context.WorkspaceDiskPath); }
protected override async Task <object> RemoteExecuteAsync(IRemoteOperationExecutionContext context) { var fullPath = context.ResolvePath(this.FileName); this.LogInformation($"Changing \"{fullPath}\" package version to {AH.CoalesceString(this.NewVersion, "remove pre-release label")}..."); var tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("n")); try { DirectoryEx.Create(tempPath); UniversalPackageMetadata currentMetadata; using (var upack = new UniversalPackage(fullPath)) { currentMetadata = upack.GetFullMetadata(); await upack.ExtractAllItemsAsync(tempPath, context.CancellationToken); FileEx.Delete(PathEx.Combine(tempPath, "upack.json")); } var newMetadata = currentMetadata.Clone(); if (string.IsNullOrEmpty(this.NewVersion)) { newMetadata.Version = new UniversalPackageVersion(currentMetadata.Version.Major, currentMetadata.Version.Minor, currentMetadata.Version.Patch); } else { newMetadata.Version = UniversalPackageVersion.Parse(this.NewVersion); } if (currentMetadata.Version == newMetadata.Version) { this.LogWarning($"Current package version {currentMetadata.Version} and the new version {newMetadata.Version} are the same; nothing to do."); return(null); } this.LogInformation("New version: " + newMetadata.Version); this.LogDebug("Adding repacking entry..."); newMetadata.RepackageHistory.Add( new RepackageHistoryEntry { Id = new UniversalPackageId(currentMetadata.Group, currentMetadata.Name) + ":" + currentMetadata.Version, Date = DateTimeOffset.Now, Using = SDK.ProductName + "/" + SDK.ProductVersion, Reason = this.Reason } ); using (var builder = new UniversalPackageBuilder(fullPath, newMetadata)) { await builder.AddRawContentsAsync(tempPath, string.Empty, true, c => true, context.CancellationToken); } this.LogInformation("Package version changed."); return(null); } finally { try { this.LogDebug($"Deleting temporary files from {tempPath}..."); DirectoryEx.Clear(tempPath); DirectoryEx.Delete(tempPath); } catch (Exception ex) { this.LogWarning("Unable to delete temporary files: " + ex.Message); } } }