public IHttpActionResult ProcessHook(IssueCommentEvent commentEvent)
        {
            _baseUrl = commentEvent.Repository.Url.Scheme + "://" + commentEvent.Repository.Url.Host;
            _owner = commentEvent.Repository.Owner.Login;
            _repoName = commentEvent.Repository.Name;

            var creds = new InMemoryCredentialStore(new Credentials("derp", ApiKey));
            var headerVal = new ProductHeaderValue("GitHooks");
            _github = new GitHubClient(headerVal, creds, new Uri(_baseUrl));

            if (CheckComment(commentEvent.Comment.Body))
            {
                var branchName = GetBranchNameFromComment(commentEvent.Comment.Body);

                try
                {
                    var pullRequest = GetPullRequest(branchName, commentEvent.Issue.Number, commentEvent.Issue.Title);
                    var merge = MergePullRequest(pullRequest, commentEvent.Issue.Number, branchName, true);
                    DeleteBranch(merge, branchName, commentEvent.Issue.Number, pullRequest.Number);
                    LeaveSuccessfulMergeComment(commentEvent.Issue.Number, pullRequest.Number, branchName);
                }
                catch (RobotFallDownException e)
                {
                    return BadRequest();
                }
            }

            return Ok();
        }
Exemplo n.º 2
0
 public HomeController()
 {
     var appSettings = ConfigurationManager.AppSettings;
     _apiKey = appSettings["Sprint.GitHubKey"];
     Ensure.NotNull(_apiKey);
     var creds = new InMemoryCredentialStore(new Credentials(_apiKey));
     _githubClient = new GitHubClient(new ProductHeaderValue("sprint-app"), creds);
 }
Exemplo n.º 3
0
 public GithubPoller(IEnumerable<Project> projects, string user,
     string password)
 {
     var creds = new Credentials(user, password);
     var credsStore = new InMemoryCredentialStore(creds);
     this.github = new GitHubClient(new ProductHeaderValue("BuildSharp"),
         credsStore);
     this.projects = projects;
 }
Exemplo n.º 4
0
        public GithubTileBuilder(GitHubApiConfig config)
        {
            _config = config;

            if (IsValid)
            {
                var credentials = new Credentials(config.Token);
                var credentialStore = new InMemoryCredentialStore(credentials);
                _client = new GitHubClient(new ProductHeaderValue("HomepageTile"), credentialStore);
            }
        }
        public static GitHubClient Build()
        {
            var credentialStore = new InMemoryCredentialStore(Helper.Credentials);

            var httpClient = new HttpClientAdapter(Helper.Proxy);

            var connection = new Connection(
                new ProductHeaderValue("GitReleaseManager"),
                GitHubClient.GitHubApiUrl,
                credentialStore,
                httpClient,
                new SimpleJsonSerializer());

            return new GitHubClient(connection);
        }