Example #1
0
        public async Task <IRepositoryContext> CreateContext(int identifier)
        {
            var botRepository = await gitHubService.GetRepository(RepositoryTarget.Bot);

            var taskDirectory = Path.Combine(TaskRepositoriesDataDirectory, $"task-{identifier}");

            // Ensure we get a clean start each time
            diskService.DeleteDirectory(taskDirectory);

            await gitService.CloneRepository(MasterRepositoryDirectory, taskDirectory);

            var gitCredentials = new LibGit2Sharp.UsernamePasswordCredentials();

            switch (gitHubService.Credentials.AuthenticationType)
            {
            case Octokit.AuthenticationType.Oauth: {
                gitCredentials.Username = gitHubService.Credentials.Password;
                gitCredentials.Password = "";
            }
            break;

            case Octokit.AuthenticationType.Basic: {
                gitCredentials.Username = gitHubService.Credentials.Login;
                gitCredentials.Password = gitHubService.Credentials.Password;
            }
            break;
            }

            await gitService.CreateRemote(taskDirectory, "bot", botRepository.HtmlUrl);

            return(new RepositoryContext(taskDirectory, botRepository.Url, gitCredentials, gitService, diskService));
        }
Example #2
0
 public void Dispose()
 {
     diskService.DeleteDirectory(RepositoryDirectory);
 }