Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 5
0
 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));
 }