Exemplo n.º 1
0
        public override async Task ExecuteAsync(IOperationExecutionContext context)
        {
            string repositoryUrl = this.GetRepositoryUrl();

            string branchDesc = string.IsNullOrEmpty(this.Branch) ? "" : $" on '{this.Branch}' branch";

            this.LogInformation($"Tag '{repositoryUrl}'{branchDesc} as '{this.Tag}'...");

            var  client = this.CreateClient(context, repositoryUrl, WorkspacePath.Resolve(context, repositoryUrl, this.WorkspaceDiskPath));
            bool valid  = await client.IsRepositoryValidAsync().ConfigureAwait(false);

            if (!valid)
            {
                await client.CloneAsync(
                    new GitCloneOptions
                {
                    Branch            = this.Branch,
                    RecurseSubmodules = this.RecurseSubmodules
                }
                    ).ConfigureAwait(false);
            }

            await client.UpdateAsync(
                new GitUpdateOptions
            {
                RecurseSubmodules = this.RecurseSubmodules,
                Branch            = this.Branch,
                Tag = this.Tag
            }
                ).ConfigureAwait(false);

            await client.TagAsync(this.Tag).ConfigureAwait(false);

            this.LogInformation("Tag complete.");
        }
Exemplo n.º 2
0
        public override async Task ExecuteAsync(IOperationExecutionContext context)
        {
            string repositoryUrl = await this.GetRepositoryUrlAsync(context.CancellationToken).ConfigureAwait(false);

            if (string.IsNullOrEmpty(repositoryUrl))
            {
                this.LogError("RepositoryUrl is not specified. It must be included in either the referenced credential or in the RepositoryUrl argument of the operation.");
                return;
            }

            string branchDesc = string.IsNullOrEmpty(this.Branch) ? "" : $" on '{this.Branch}' branch";
            string refDesc    = string.IsNullOrEmpty(this.Ref) ? "" : $", commit '{this.Ref}'";

            this.LogInformation($"Getting source from '{repositoryUrl}'{branchDesc}{refDesc}...");

            var workspacePath = WorkspacePath.Resolve(context, repositoryUrl, this.WorkspaceDiskPath);

            if (this.CleanWorkspace)
            {
                this.LogDebug($"Clearing workspace path '{workspacePath.FullPath}'...");
                var fileOps = context.Agent.GetService <IFileOperationsExecuter>();
                await fileOps.ClearDirectoryAsync(workspacePath.FullPath).ConfigureAwait(false);
            }

            var  client = this.CreateClient(context, repositoryUrl, workspacePath);
            bool valid  = await client.IsRepositoryValidAsync().ConfigureAwait(false);

            if (!valid)
            {
                await client.CloneAsync(
                    new GitCloneOptions
                {
                    Branch            = this.Branch,
                    RecurseSubmodules = this.RecurseSubmodules
                }
                    ).ConfigureAwait(false);
            }

            this.CommitHash = await client.UpdateAsync(
                new GitUpdateOptions
            {
                RecurseSubmodules = this.RecurseSubmodules,
                Branch            = this.Branch,
                Ref = this.Ref
            }
                ).ConfigureAwait(false);

            this.LogDebug($"Current commit is {this.CommitHash}.");

            await client.ArchiveAsync(context.ResolvePath(this.DiskPath), this.KeepInternals).ConfigureAwait(false);

            this.LogInformation("Get source complete.");
        }
        public override async Task ExecuteAsync(IOperationExecutionContext context)
        {
            string repositoryUrl = await this.GetRepositoryUrlAsync().ConfigureAwait(false);

            string branchDesc = string.IsNullOrEmpty(this.Branch) ? "" : $" on '{this.Branch}' branch";
            string tagDesc    = string.IsNullOrEmpty(this.Tag) ? "" : $" tagged '{this.Tag}'";

            this.LogInformation($"Getting source from '{repositoryUrl}'{branchDesc}{tagDesc}...");

            var workspacePath = WorkspacePath.Resolve(context, repositoryUrl, this.WorkspaceDiskPath);

            if (this.CleanWorkspace)
            {
                this.LogDebug($"Clearing workspace path '{workspacePath.FullPath}'...");
                var fileOps = context.Agent.GetService <IFileOperationsExecuter>();
                await fileOps.ClearDirectoryAsync(workspacePath.FullPath).ConfigureAwait(false);
            }

            var  client = this.CreateClient(context, repositoryUrl, workspacePath);
            bool valid  = await client.IsRepositoryValidAsync().ConfigureAwait(false);

            if (!valid)
            {
                await client.CloneAsync(
                    new GitCloneOptions
                {
                    Branch            = this.Branch,
                    RecurseSubmodules = this.RecurseSubmodules
                }
                    ).ConfigureAwait(false);
            }

            await client.UpdateAsync(
                new GitUpdateOptions
            {
                RecurseSubmodules = this.RecurseSubmodules,
                Branch            = this.Branch,
                Tag = this.Tag
            }
                ).ConfigureAwait(false);

            await client.ArchiveAsync(context.ResolvePath(this.DiskPath)).ConfigureAwait(false);

            this.LogInformation("Get source complete.");
        }
Exemplo n.º 4
0
        public override async Task ExecuteAsync(IOperationExecutionContext context)
        {
            string repositoryUrl = await this.GetRepositoryUrlAsync(context.CancellationToken).ConfigureAwait(false);

            if (string.IsNullOrEmpty(repositoryUrl))
            {
                this.LogError("RepositoryUrl is not specified. It must be included in either the referenced credential or in the RepositoryUrl argument of the operation.");
                return;
            }

            string branchDesc = string.IsNullOrEmpty(this.Branch) ? "" : $" on '{this.Branch}' branch";

            this.LogInformation($"Tag '{repositoryUrl}'{branchDesc} as '{this.Tag}'...");

            var  client = this.CreateClient(context, repositoryUrl, WorkspacePath.Resolve(context, repositoryUrl, this.WorkspaceDiskPath));
            bool valid  = await client.IsRepositoryValidAsync().ConfigureAwait(false);

            if (!valid)
            {
                await client.CloneAsync(
                    new GitCloneOptions
                {
                    Branch            = this.Branch,
                    RecurseSubmodules = this.RecurseSubmodules
                }
                    ).ConfigureAwait(false);
            }

            await client.UpdateAsync(
                new GitUpdateOptions
            {
                RecurseSubmodules = this.RecurseSubmodules,
                Branch            = this.Branch,
                Ref = this.CommitHash
            }
                ).ConfigureAwait(false);

            await client.TagAsync(this.Tag, this.CommitHash, this.TagMessage, this.Force).ConfigureAwait(false);

            this.LogInformation("Tag complete.");
        }