private ProcessResults ExecuteHgCommand(SourceRepository repo, string hgCommand, params string[] options) { if (repo == null) { throw new ArgumentNullException("repo"); } string repositoryPath = repo.GetDiskPath(this.Agent); if (!repo.IsBuildMasterManaged && !this.Agent.DirectoryExists(this.Agent.CombinePath(repositoryPath, ".hg"))) { throw new NotAvailableException("A local repository was not found at: " + repositoryPath); } var args = new StringBuilder(); args.AppendFormat("{0} -R \"{1}\" -y -v ", hgCommand, repositoryPath); args.Append(string.Join(" ", (options ?? new string[0]))); var results = this.ExecuteCommandLine(this.HgExecutablePath, args.ToString(), repositoryPath); if (results.ExitCode != 0) { throw new InvalidOperationException(string.Join(Environment.NewLine, results.Error)); } else { return(results); } }
public TfsSourceControlContext(TfsSourceControlProvider provider, string sourcePath, string label) { this.Label = label; if (string.IsNullOrEmpty(sourcePath)) { this.SourcePath = EmptyPathString; } else { this.SourcePath = sourcePath.TrimStart(provider.DirectorySeparator); } this.SplitPath = SplitPathParts(this.SourcePath); this.LastSubDirectoryName = this.SplitPath.LastOrDefault() ?? string.Empty; var tmpRepo = new SourceRepository() { RemoteUrl = BuildAbsoluteDiskPath(provider.BaseUrl, this.SplitPath) }; this.WorkspaceDiskPath = tmpRepo.GetDiskPath(provider.Agent.GetService <IFileOperationsExecuter>()); //this.RepositoryRelativePath = this.SourcePath.TrimStart(EmptyPathString.ToCharArray()); //this.AbsoluteDiskPath = BuildAbsoluteDiskPath(this.WorkspaceDiskPath, this.SplitPath); this.WorkspaceName = BuildWorkspaceName(this.WorkspaceDiskPath); }
public TfsSourceControlContext(TfsSourceControlProvider provider, string sourcePath, string label) { this.Label = label; if (string.IsNullOrEmpty(sourcePath)) this.SourcePath = EmptyPathString; else this.SourcePath = sourcePath.TrimStart(provider.DirectorySeparator); this.SplitPath = SplitPathParts(this.SourcePath); this.LastSubDirectoryName = this.SplitPath.LastOrDefault() ?? string.Empty; var tmpRepo = new SourceRepository() { RemoteUrl = BuildAbsoluteDiskPath(provider.BaseUrl, this.SplitPath) }; this.WorkspaceDiskPath = tmpRepo.GetDiskPath(provider.Agent.GetService<IFileOperationsExecuter>()); //this.RepositoryRelativePath = this.SourcePath.TrimStart(EmptyPathString.ToCharArray()); //this.AbsoluteDiskPath = BuildAbsoluteDiskPath(this.WorkspaceDiskPath, this.SplitPath); this.WorkspaceName = BuildWorkspaceName(this.WorkspaceDiskPath); }
private void CreateAndCloneRepoIfNecessary(SourceRepository repo) { string repoDiskPath = repo.GetDiskPath(this.Agent); if (!this.Agent.DirectoryExists(repoDiskPath)) { this.Agent.CreateDirectory(repoDiskPath); this.GitClient.CloneRepo(repo); } else { var entry = this.Agent.GetDirectoryEntry(new GetDirectoryEntryCommand() { IncludeRootPath = false, Path = repoDiskPath, Recurse = false }).Entry; if (entry.FlattenWithFiles().Take(2).Count() < 2) this.GitClient.CloneRepo(repo); } }
protected ProcessResults ExecuteGitCommand(SourceRepository repo, string command, params string[] args) { return this.Provider.ExecuteCommandLine(this.GitExePath, command + " " + string.Join(" ", args), repo.GetDiskPath(this.Provider.Agent)); }