/// <summary>
 /// Creates a new instance of the <see cref="IssuesContext"/> class.
 /// </summary>
 /// <param name="context">The Cake context.</param>
 /// <param name="repositoryInfoProviderType">Defines how information about the Git repository should be determined.</param>
 public IssuesContext(
     ICakeContext context,
     RepositoryInfoProviderType repositoryInfoProviderType)
     : base(context)
 {
     this.Parameters = new IssuesParameters();
     this.State      = new IssuesState(this, repositoryInfoProviderType);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Determines the repository info provider to use.
        /// </summary>
        /// <param name="context">The Cake context.</param>
        /// <param name="repositoryInfoProviderType">Defines how information about the Git repository should be determined.</param>
        /// <returns>The repository info provider which should be used.</returns>
        private static IRepositoryInfoProvider DetermineRepositoryInfoProvider(
            IssuesContext context,
            RepositoryInfoProviderType repositoryInfoProviderType)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            switch (repositoryInfoProviderType)
            {
            case RepositoryInfoProviderType.CakeGit:
                context.Information("Using Cake.Git for providing repository information");
                return(new CliRepositoryInfoProvider());

            case RepositoryInfoProviderType.Cli:
                context.Information("Using Git CLI for providing repository information");
                return(new CliRepositoryInfoProvider());

            default:
                throw new NotImplementedException("Unsupported repository info provider");
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a new instance of the <see cref="IssuesState"/> class.
        /// </summary>
        /// <param name="context">The Cake context.</param>
        /// <param name="repositoryInfoProviderType">Defines how information about the Git repository should be determined.</param>
        public IssuesState(
            IssuesContext context,
            RepositoryInfoProviderType repositoryInfoProviderType)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            this.BuildRootDirectory = context.MakeAbsolute(context.Directory("./"));
            context.Information("Build script root directory: {0}", this.BuildRootDirectory);

            this.ProjectRootDirectory = this.BuildRootDirectory.Combine("..").Collapse();
            context.Information("Project root directory: {0}", this.ProjectRootDirectory);

            this.RepositoryInfo = DetermineRepositoryInfoProvider(context, repositoryInfoProviderType);

            this.RepositoryRootDirectory = this.RepositoryInfo.GetRepositoryRootDirectory(context, this.BuildRootDirectory);
            context.Information("Repository root directory: {0}", this.RepositoryRootDirectory);

            this.BuildServer = DetermineBuildServer(context);
            if (this.BuildServer != null)
            {
                this.RepositoryRemoteUrl =
                    BuildServer.DetermineRepositoryRemoteUrl(context, this.RepositoryRootDirectory);
                context.Information("Repository remote URL: {0}", this.RepositoryRemoteUrl);

                this.CommitId =
                    BuildServer.DetermineCommitId(context, this.RepositoryRootDirectory);
                context.Information("CommitId: {0}", this.CommitId);

                this.PullRequestSystem =
                    DeterminePullRequestSystem(
                        context,
                        this.RepositoryRemoteUrl);
            }
        }