public GithubMergedBranchSweeper(string owner, string token, string repository)
        {
            Owner      = owner;
            _token     = token;
            Repository = repository;

            client = new OctokitClient(_token, Owner, nameof(GithubMergedBranchSweeper));
        }
Пример #2
0
        private RepositoryFilter MakeRepositoryFilter()
        {
            var collaborationFactory = Substitute.For <ICollaborationFactory>();
            var gitHubClient         = new OctokitClient(NukeeperLogger);

            gitHubClient.Initialise(new AuthSettings(new Uri("https://api.github.com"), ""));
            collaborationFactory.CollaborationPlatform.Returns(gitHubClient);

            return(new RepositoryFilter(collaborationFactory, NukeeperLogger));
        }
Пример #3
0
        private static RepositoryFilter MakeRepositoryFilter()
        {
            const string testKeyWithOnlyPublicAccess = "c13d2ce7774d39ae99ddaad46bd69c3d459b9992";
            var          logger = Substitute.For <INuKeeperLogger>();

            var gitHubClient = new OctokitClient(logger);

            gitHubClient.Initialise(new GithubAuthSettings(new Uri("https://api.github.com"), testKeyWithOnlyPublicAccess));

            return(new RepositoryFilter(gitHubClient, logger));
        }
Пример #4
0
        private RepositoryFilter MakeRepositoryFilter()
        {
            const string testKeyWithOnlyPublicAccess = "c13d2ce7774d39ae99ddaad46bd69c3d459b9992";

            var collaborationFactory = Substitute.For <ICollaborationFactory>();
            var gitHubClient         = new OctokitClient(NukeeperLogger);

            gitHubClient.Initialise(new AuthSettings(new Uri("https://api.github.com"), testKeyWithOnlyPublicAccess));
            collaborationFactory.CollaborationPlatform.Returns(gitHubClient);

            return(new RepositoryFilter(collaborationFactory, NukeeperLogger));
        }
Пример #5
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");
            }
        }
Пример #6
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);

                // 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");
            }
        }