Esempio n. 1
0
        public async override Task <object> ExecuteAsync(CancellationToken cancellationToken)
        {
            GitRepositoryInfo repo;

            if (!string.IsNullOrEmpty(this.Context.LocalRepositoryPath))
            {
                repo = new GitRepositoryInfo(
                    new WorkspacePath(this.Context.LocalRepositoryPath),
                    this.Context.RemoteRepositoryUrl,
                    this.Context.UserName,
                    AH.CreateSecureString(this.Context.Password)
                    );
            }
            else
            {
                repo = new GitRepositoryInfo(
                    this.Context.RemoteRepositoryUrl,
                    this.Context.UserName,
                    AH.CreateSecureString(this.Context.Password)
                    );
            }

            var client = new LibGitSharpClient(repo, this);

            switch (this.Command)
            {
            case ClientCommand.Archive:
                await client.ArchiveAsync(this.Context.TargetDirectory, this.Context.KeepInternals).ConfigureAwait(false);

                return(null);

            case ClientCommand.Clone:
                await client.CloneAsync(this.Context.CloneOptions).ConfigureAwait(false);

                return(null);

            case ClientCommand.EnumerateRemoteBranches:
                return((await client.EnumerateRemoteBranchesAsync().ConfigureAwait(false)).ToArray());

            case ClientCommand.IsRepositoryValid:
                return(await client.IsRepositoryValidAsync().ConfigureAwait(false));

            case ClientCommand.Tag:
                await client.TagAsync(this.Context.Tag, this.Context.Commit, this.Context.TagMessage, this.Context.Force).ConfigureAwait(false);

                return(null);

            case ClientCommand.Update:
                return(await client.UpdateAsync(this.Context.UpdateOptions).ConfigureAwait(false));

            default:
                throw new InvalidOperationException("Invalid remote LibGitSharp job type: " + this.Command);
            }
        }
Esempio n. 2
0
        public async override Task <object> ExecuteAsync(CancellationToken cancellationToken)
        {
            var repo = new GitRepositoryInfo(
                new WorkspacePath(this.Context.LocalRepositoryPath),
                this.Context.RemoteRepositoryUrl,
                this.Context.UserName,
                this.Context.Password != null ? this.Context.Password.ToSecureString() : null
                );

            var client = new LibGitSharpClient(repo, this);

            switch (this.Command)
            {
            case ClientCommand.Archive:
                await client.ArchiveAsync(this.Context.TargetDirectory).ConfigureAwait(false);

                return(null);

            case ClientCommand.Clone:
                await client.CloneAsync(this.Context.CloneOptions).ConfigureAwait(false);

                return(null);

            case ClientCommand.EnumerateRemoteBranches:
                return((await client.EnumerateRemoteBranchesAsync().ConfigureAwait(false)).ToArray());

            case ClientCommand.IsRepositoryValid:
                return(await client.IsRepositoryValidAsync().ConfigureAwait(false));

            case ClientCommand.Tag:
                await client.TagAsync(this.Context.Tag);

                return(null);

            case ClientCommand.Update:
                await client.UpdateAsync(this.Context.UpdateOptions);

                return(null);

            default:
                throw new InvalidOperationException("Invalid remote LibGitSharp job type: " + this.Command);
            }
        }