public void ToStringPrivateGeneratesPublicString() { PrivateString hidden = "private"; var args = new PrivateArguments("public", hidden); Assert.AreEqual("public private", args.ToString(SecureDataMode.Private)); }
// tf get itemspec [/version:versionspec] [/all] [/overwrite] [/force] // [/preview] [/recursive] [/noprompt] private ProcessInfo GetWorkSpaceProcessInfo(IIntegrationResult result) { var buffer = new PrivateArguments( "get", "/recursive", "/noprompt"); if (All) { buffer.Add("/all"); } if (Overwrite) { buffer.Add("/overwrite"); } if (Force) { buffer.Add("/force"); } buffer.AddQuote(WorkingDirectory); AppendSourceControlAuthentication(buffer); return(NewProcessInfo(buffer, result)); }
/// <summary> /// When getting by label, the vault command-line client requires a disk path even if you're retrieving /// into a working folder. This retrieves that working path so we can specify it in the get command. We also /// need to know the working directory before we retrieve source if we're going to clean it out, when cleanCopy is true. /// Returns true if a working folder was found and WorkingDirectory was set, false if not. /// </summary> /// <param name="result"></param> /// <returns></returns> protected string GetVaultWorkingFolder(IIntegrationResult result) { var builder = new PrivateArguments("listworkingfolders"); AddCommonOptionalArguments(builder); ProcessInfo processInfo = ProcessInfoFor(builder, result); ProcessResult processResult = Execute(processInfo); // parse list of working folders XmlDocument xml = GetVaultResponse(processResult, processInfo); XmlNodeList workingFolderNodes = xml.SelectNodes("/vault/listworkingfolders/workingfolder"); XmlAttribute repositoryFolderAtt; XmlAttribute localFolderAtt; foreach (XmlNode workingFolderNode in workingFolderNodes) { repositoryFolderAtt = workingFolderNode.Attributes["reposfolder"]; localFolderAtt = workingFolderNode.Attributes["localfolder"]; if (repositoryFolderAtt != null && localFolderAtt != null) { if (repositoryFolderAtt.InnerText == _shim.Folder) { return(localFolderAtt.InnerText); } } } return(null); }
public void ToStringGeneratesPublicString() { PrivateString hidden = "private"; var args = new PrivateArguments("public", hidden); Assert.AreEqual("public " + hidden.PublicValue, args.ToString()); }
private void AppendSourceControlAuthentication(PrivateArguments buffer) { if (!string.IsNullOrEmpty(Username) && !string.IsNullOrEmpty(Password.PrivateValue)) { buffer.Add("/login:" + this.BuildTfsAuthenticationString()); } }
public void ImplicitOperatorGeneratesInstance() { PrivateArguments args = "test args"; Assert.AreEqual(1, args.Count); Assert.AreEqual("test args", args.ToString()); }
public void ConstructorWithTwoArgumentsInitialises() { var args = new PrivateArguments("first", "second"); Assert.AreEqual(2, args.Count); Assert.AreEqual("first second", args.ToString()); }
public void ConstructorWithOneArgumentInitialises() { var args = new PrivateArguments("test"); Assert.AreEqual(1, args.Count); Assert.AreEqual("test", args.ToString()); }
private ProcessInfo NewProcessInfo(PrivateArguments args, IIntegrationResult result) { string workingDirectory = Path.GetFullPath(result.BaseFromWorkingDirectory(WorkingDirectory)); if (!Directory.Exists(workingDirectory)) { Directory.CreateDirectory(workingDirectory); } var processInfo = new ProcessInfo(Executable, args, workingDirectory); processInfo.StreamEncoding = Encoding.UTF8; if (!string.IsNullOrEmpty(CodePage)) { int codePage; if (int.TryParse(CodePage, out codePage)) { processInfo.StreamEncoding = Encoding.GetEncoding(codePage); } else { throw new CruiseControlException(string.Format(System.Globalization.CultureInfo.CurrentCulture, "Code page {0} could not be parsed to an encoding via instruction : Encoding.GetEncoding(codePage)", CodePage)); } } processInfo.TimeOut = 600000; return(processInfo); }
private ProcessInfo VersionHistoryProcessInfo(IIntegrationResult from, IIntegrationResult to, bool bForceGetLatestVersion) { var builder = new PrivateArguments(); builder.Add("versionhistory ", _shim.Folder); // Look only for changes, unless caller asked us to get the latest folder // version regardless of whether there's been a change. if (!bForceGetLatestVersion) { // use folderVersion when possible because it's faster and more accurate if (_folderVersion != 0) { builder.Add("-beginversion ", (_folderVersion + 1).ToString(CultureInfo.CurrentCulture)); } else { builder.Add("-begindate ", from.StartTime.ToString("s", CultureInfo.CurrentCulture)); builder.Add("-enddate ", to.StartTime.ToString("s", CultureInfo.CurrentCulture)); } } // we only ever need the most recent change builder.Add("-rowlimit ", "1"); AddCommonOptionalArguments(builder); return(ProcessInfoFor(builder, from)); }
private ProcessInfo RevertWorkingCopy(IIntegrationResult result) { var buffer = new PrivateArguments("revert", "--recursive"); buffer.Add(null, Path.GetFullPath(result.BaseFromWorkingDirectory(WorkingDirectory)), true); return(NewProcessInfo(buffer, result)); }
/// <summary> /// Prepare an AccuRev command for execution. /// </summary> /// <param name="args">arguments for the "accurev" command</param> /// <param name="result">IntegrationResult for which the command will be run</param> /// <returns>a ProcessInfo object primed to execute the specified command</returns> private ProcessInfo PrepCommand(PrivateArguments args, IIntegrationResult result) { Log.Debug(string.Format(System.Globalization.CultureInfo.CurrentCulture, "Preparing to run AccuRev command: {0} {1}", Executable, args)); ProcessInfo command = new ProcessInfo(Executable, args, result.BaseFromWorkingDirectory(Workspace)); SetEnvironmentVariables(command.EnvironmentVariables, result); return(command); }
private void AppendUsernameAndPassword(PrivateArguments builder) { if (!string.IsNullOrEmpty(Username)) { PrivateString userPlusPass = "******"-Y" + Username + "," + Password.PrivateValue + "\""; builder.Add(userPlusPass); } }
private ProcessInfo CleanupWorkingCopy(IIntegrationResult result) { var buffer = new PrivateArguments("cleanup"); buffer.Add(null, Path.GetFullPath(result.BaseFromWorkingDirectory(WorkingDirectory)), true); return(NewProcessInfo(buffer, result)); }
public void AddQuoteWithPrefixedValueAdds() { var args = new PrivateArguments(); args.AddQuote("pre=", "test Value"); Assert.AreEqual(1, args.Count); Assert.AreEqual("pre=\"test Value\"", args.ToString()); }
public void AddIfWithAutoQuoteValueAddsOnTrue() { var args = new PrivateArguments(); args.AddIf(true, "pre=", "test Value", true); Assert.AreEqual(1, args.Count); Assert.AreEqual("pre=\"test Value\"", args.ToString()); }
public void PlusOperatorAddsPublicValue() { PrivateArguments args = "test args"; args += "value"; Assert.AreEqual(2, args.Count); Assert.AreEqual("test args value", args.ToString()); }
public void AddIfWithAutoQuoteValueDoesNotAddOnFalse() { var args = new PrivateArguments(); args.AddIf(false, "pre=", "test Value", true); Assert.AreEqual(0, args.Count); Assert.AreEqual(string.Empty, args.ToString()); }
public void AddWithValueAdds() { var args = new PrivateArguments(); args.Add("testValue"); Assert.AreEqual(1, args.Count); Assert.AreEqual("testValue", args.ToString()); }
public void AddIfWithPrefixedValueAddsOnTrue() { var args = new PrivateArguments(); args.AddIf(true, "pre=", "test Value"); Assert.AreEqual(1, args.Count); Assert.AreEqual("pre=test Value", args.ToString()); }
private ProcessInfo RemoveLabelProcessInfo(IIntegrationResult result) { var builder = new PrivateArguments(); builder.Add("deletelabel ", _shim.Folder); builder.Add(result.Label); AddCommonOptionalArguments(builder); return(ProcessInfoFor(builder, result)); }
private ProcessInfo NewCheckoutProcessInfo(IIntegrationResult result) { var buffer = new PrivateArguments("checkout"); buffer.Add(string.Empty, TrunkUrl, true); buffer.Add(null, Path.GetFullPath(result.BaseFromWorkingDirectory(WorkingDirectory)), true); AppendCommonSwitches(buffer); return(NewProcessInfo(buffer, result)); }
private void AppendCommonSwitches(PrivateArguments buffer, bool isExternal) { if ((this.AuthCaching != AuthCachingMode.Always) && (!isExternal || (this.AuthCaching == AuthCachingMode.None))) { buffer.AddIf(!string.IsNullOrEmpty(this.Username), "--username ", this.Username, true); buffer.AddIf(this.Password != null, "--password ", this.Password, true); buffer.Add("--no-auth-cache"); } buffer.Add("--non-interactive"); }
// HISTORY_COMMAND_FORMAT = "log url --revision {LastRevision}:HEAD --verbose --xml --non-interactive"; private ProcessInfo NewHistoryProcessInfoFromRevision(string lastRevision, IIntegrationResult to, string url) { var buffer = new PrivateArguments("log"); buffer.Add(null, url, true); buffer.Add(string.Format(System.Globalization.CultureInfo.CurrentCulture, "-r {0}:HEAD", string.IsNullOrEmpty(lastRevision) ? "0" : lastRevision)); buffer.Add("--verbose --xml"); AppendCommonSwitches(buffer, url != this.TrunkUrl); return(NewProcessInfo(buffer, to)); }
// HISTORY_COMMAND_FORMAT = "log url --revision \"{{{StartDate}}}:{{{EndDate}}}\" --verbose --xml --non-interactive"; private ProcessInfo NewHistoryProcessInfo(IIntegrationResult from, IIntegrationResult to, string url) { var buffer = new PrivateArguments("log"); buffer.Add(null, url, true); buffer.Add(string.Format(System.Globalization.CultureInfo.CurrentCulture, "-r \"{{{0}}}:{{{1}}}\"", FormatCommandDate(from.StartTime), FormatCommandDate(to.StartTime))); buffer.Add("--verbose --xml"); AppendCommonSwitches(buffer, url != this.TrunkUrl); return(NewProcessInfo(buffer, to)); }
private ProcessInfo PropGetProcessInfo(IIntegrationResult result) { var buffer = new PrivateArguments("propget"); buffer.AddIf(CheckExternalsRecursive, "-R"); AppendCommonSwitches(buffer); buffer.Add("svn:externals"); buffer.Add(TrunkUrl); return(NewProcessInfo(buffer, result)); }
private PrivateArguments LabelProcessInfoArgs(string label, string oldLabel) { var builder = new PrivateArguments(); builder.Add("label ", Project, true); builder.Add("-L", label); builder.AddIf(!string.IsNullOrEmpty(oldLabel), "-VL", oldLabel); AppendUsernameAndPassword(builder); builder.Add("-I-Y"); return(builder); }
// "history ""{0}"" -excludeactions label,obliterate -rowlimit 0 -begindate {1:s} -enddate {2:s} // rowlimit 0 or -1 means unlimited (default is 1000 if not specified) // TODO: might want to make rowlimit configurable? private PrivateArguments BuildHistoryProcessArgs(DateTime from, DateTime to) { var builder = new PrivateArguments(); builder.Add("history ", _shim.Folder); builder.Add(_shim.HistoryArgs); builder.Add("-begindate ", from.ToString("s", CultureInfo.CurrentCulture)); builder.Add("-enddate ", to.ToString("s", CultureInfo.CurrentCulture)); AddCommonOptionalArguments(builder); return(builder); }
// tf dir [/server:servername] itemspec [/version:versionspec] // [/recursive] [/folders] [/deleted] private ProcessInfo CheckProjectProcessInfo(IIntegrationResult result) { var buffer = new PrivateArguments("dir", "/folders"); buffer.Add("/server:", Server); buffer.AddQuote(ProjectPath); AppendSourceControlAuthentication(buffer); return(NewProcessInfo(buffer, result)); }
// tf workspaces /delete [/owner:ownername] [/computer:computername] // [/server:servername] workspacename private ProcessInfo DeleteWorkSpaceProcessInfo(IIntegrationResult result) { var buffer = new PrivateArguments("workspace", "/delete"); buffer.Add("-server:", Server); buffer.AddQuote(Workspace); AppendSourceControlAuthentication(buffer); return(NewProcessInfo(buffer, result)); }