public void Initialise()
        {
            var httpClientFactory = Substitute.For <IHttpClientFactory>();

            httpClientFactory.CreateClient().Returns(new HttpClient());

            var platform = new AzureDevOpsPlatform(Substitute.For <INuKeeperLogger>(), httpClientFactory);

            platform.Initialise(new AuthSettings(new Uri("https://uri.com"), "token"));
        }
Beispiel #2
0
        private void CreateForPlatform()
        {
            var forkMode = Settings.ForkMode.Value;

            switch (_platform.Value)
            {
            case Platform.AzureDevOps:
                CollaborationPlatform = new AzureDevOpsPlatform(_nuKeeperLogger);
                RepositoryDiscovery   = new AzureDevOpsRepositoryDiscovery(_nuKeeperLogger, Settings.Token);
                ForkFinder            = new AzureDevOpsForkFinder(CollaborationPlatform, _nuKeeperLogger, forkMode);
                break;

            case Platform.GitHub:
                CollaborationPlatform = new OctokitClient(_nuKeeperLogger);
                RepositoryDiscovery   = new GitHubRepositoryDiscovery(_nuKeeperLogger, CollaborationPlatform);
                ForkFinder            = new GitHubForkFinder(CollaborationPlatform, _nuKeeperLogger, forkMode);
                break;

            case Platform.Bitbucket:
                CollaborationPlatform = new BitbucketPlatform(_nuKeeperLogger);
                RepositoryDiscovery   = new BitbucketRepositoryDiscovery(_nuKeeperLogger);
                ForkFinder            = new BitbucketForkFinder(CollaborationPlatform, _nuKeeperLogger, forkMode);
                break;

            case Platform.BitbucketLocal:
                CollaborationPlatform = new BitBucketLocalPlatform(_nuKeeperLogger);
                RepositoryDiscovery   = new BitbucketLocalRepositoryDiscovery(_nuKeeperLogger, CollaborationPlatform, Settings);
                ForkFinder            = new BitbucketForkFinder(CollaborationPlatform, _nuKeeperLogger, forkMode);
                break;

            case Platform.GitLab:
                CollaborationPlatform = new GitlabPlatform(_nuKeeperLogger);
                RepositoryDiscovery   = new GitlabRepositoryDiscovery(_nuKeeperLogger, CollaborationPlatform);
                ForkFinder            = new GitlabForkFinder(CollaborationPlatform, _nuKeeperLogger, forkMode);
                break;

            default:
                throw new NuKeeperException($"Unknown platform: {_platform}");
            }

            var auth = new AuthSettings(Settings.BaseApiUrl, Settings.Token, Settings.Username);

            CollaborationPlatform.Initialise(auth);

            if (ForkFinder == null ||
                RepositoryDiscovery == null ||
                CollaborationPlatform == null)
            {
                throw new NuKeeperException($"Platform {_platform} could not be initialised");
            }
        }
        private void CreateForPlatform()
        {
            var forkMode = Settings.ForkMode.Value;

            switch (_platform.Value)
            {
            case Platform.AzureDevOps:
                CollaborationPlatform = new AzureDevOpsPlatform(_nuKeeperLogger);
                RepositoryDiscovery   = new AzureDevOpsRepositoryDiscovery(_nuKeeperLogger, Settings.Token);
                ForkFinder            = new AzureDevOpsForkFinder(CollaborationPlatform, _nuKeeperLogger, forkMode);

                // We go for the specific platform version of ICommitWorder
                // here since Azure DevOps has different commit message limits compared to other platforms.
                CommitWorder = new AzureDevOpsCommitWorder();
                break;

            case Platform.GitHub:
                CollaborationPlatform = new OctokitClient(_nuKeeperLogger);
                RepositoryDiscovery   = new GitHubRepositoryDiscovery(_nuKeeperLogger, CollaborationPlatform);
                ForkFinder            = new GitHubForkFinder(CollaborationPlatform, _nuKeeperLogger, forkMode);
                CommitWorder          = new DefaultCommitWorder();
                break;

            case Platform.Bitbucket:
                CollaborationPlatform = new BitbucketPlatform(_nuKeeperLogger);
                RepositoryDiscovery   = new BitbucketRepositoryDiscovery(_nuKeeperLogger);
                ForkFinder            = new BitbucketForkFinder(CollaborationPlatform, _nuKeeperLogger, forkMode);
                CommitWorder          = new DefaultCommitWorder();
                break;

            case Platform.BitbucketLocal:
                CollaborationPlatform = new BitBucketLocalPlatform(_nuKeeperLogger);
                RepositoryDiscovery   = new BitbucketLocalRepositoryDiscovery(_nuKeeperLogger, CollaborationPlatform, Settings);
                ForkFinder            = new BitbucketForkFinder(CollaborationPlatform, _nuKeeperLogger, forkMode);
                CommitWorder          = new DefaultCommitWorder();
                break;

            case Platform.GitLab:
                CollaborationPlatform = new GitlabPlatform(_nuKeeperLogger);
                RepositoryDiscovery   = new GitlabRepositoryDiscovery(_nuKeeperLogger, CollaborationPlatform);
                ForkFinder            = new GitlabForkFinder(CollaborationPlatform, _nuKeeperLogger, forkMode);
                CommitWorder          = new DefaultCommitWorder();
                break;

            case Platform.Gitea:
                CollaborationPlatform = new GiteaPlatform(_nuKeeperLogger);
                RepositoryDiscovery   = new GiteaRepositoryDiscovery(_nuKeeperLogger, CollaborationPlatform);
                ForkFinder            = new GiteaForkFinder(CollaborationPlatform, _nuKeeperLogger, forkMode);
                CommitWorder          = new DefaultCommitWorder();
                break;

            default:
                throw new NuKeeperException($"Unknown platform: {_platform}");
            }

            var auth = new AuthSettings(Settings.BaseApiUrl, Settings.Token, Settings.Username);

            CollaborationPlatform.Initialise(auth);

            if (ForkFinder == null ||
                RepositoryDiscovery == null ||
                CollaborationPlatform == null)
            {
                throw new NuKeeperException($"Platform {_platform} could not be initialised");
            }
        }
Beispiel #4
0
        public void Initialise()
        {
            var platform = new AzureDevOpsPlatform(Substitute.For <INuKeeperLogger>());

            platform.Initialise(new AuthSettings(new Uri("https://uri.com"), "token"));
        }