コード例 #1
0
        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();
        }
コード例 #2
0
ファイル: HomeController.cs プロジェクト: hahmed/Sprint
 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);
 }
コード例 #3
0
ファイル: GithubPoller.cs プロジェクト: tritao/BuildSharp
 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;
 }
コード例 #4
0
ファイル: GithubTileBuilder.cs プロジェクト: rikkit/homepage
        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);
            }
        }
コード例 #5
0
        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);
        }