{"action":"created","comment":{"url":"https://api.github.com/repos/wangkuiyi/ci/pulls/comments/87328445","pull_request_review_id":7944852,"id":87328445,"diff_hunk":"@@ -0,0 +1,64 @@\n+//handle the github API\n+package main\n+\n+import (\n+\t\"fmt\"\n+\n+\t\"github.com/google/go-github/github\"\n+\t\"golang.org/x/oauth2\"\n+)\n+\n+// GithubAPI is used for ci system to access github api.\n+type GithubAPI struct {\n+\topts     *GithubAPIOption\n+\thttpOpts *HTTPOption\n+\tcli      *github.Client\n+}\n+\n+func newGithubAPI(opts *Options) *GithubAPI {\n+\tts := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: opts.Github.Token})\n+\ttc := oauth2.NewClient(oauth2.NoContext, ts)\n+\tgh := github.NewClient(tc)\n+\t_, _, err := gh.Repositories.Get(opts.Github.Owner, opts.Github.Name)\n+\tcheckNoErr(err)\n+\treturn &GithubAPI{\n+\t\topts:     &opts.Github,\n+\t\tcli:      gh,\n+\t\thttpOpts: &opts.HTTP,\n+\t}\n+}\n+\n+const (\n+\t// GithubPending github check status pending\n+\tGithubPending = \"pending\"\n+\t// GithubSuccess github check status success\n+\tGithubSuccess = \"success\"\n+\t// GithubError github check status error\n+\tGithubError = \"error\"\n+\t// GithubFailure github check status failure\n+\tGithubFailure = \"failure\"\n+)\n+\n+// CreateStatus will a check status for version `sha`.\n+func (gh *GithubAPI) CreateStatus(sha string, status string) error {\n+\turl := fmt.Sprintf(\"%s%s%s\", gh.httpOpts.Hostname, gh.httpOpts.StatusURI, sha)\n+\t_, _, err := gh.cli.Repositories.CreateStatus(gh.opts.Owner, gh.opts.Name, sha, &github.RepoStatus{\n+\t\tTargetURL:   &url,\n+\t\tState:       &status,\n+\t\tDescription: &gh.opts.Description,\n+\t})\n+\treturn err\n+}\n+\n+// ListRemoteBranches List all remote branches\n+func (gh *GithubAPI) ListRemoteBranches() ([]*string, error) {","path":"github_api.go","position":54,"original_position":54,"commit_id":"687d74ae5b5f0b0b7c32bfe9aa9f0c99110154c6","original_commit_id":"687d74ae5b5f0b0b7c32bfe9aa9f0c99110154c6","user":{"login":"reyoung","id":728699,"avatar_url":"https://avatars.githubusercontent.com/u/728699?v=3","gravatar_id":"","url":"https://api.github.com/users/reyoung","html_url":"https://github.com/reyoung","followers_url":"https://api.github.com/users/reyoung/followers","following_url":"https://api.github.com/users/reyoung/following{/other_user}","gists_url":"https://api.github.com/users/reyoung/gists{/gist_id}","starred_url":"https://api.github.com/users/reyoung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reyoung/subscriptions","organizations_url":"https://api.github.com/users/reyoung/orgs","repos_url":"https://api.github.com/users/reyoung/repos","events_url":"https://api.github.com/users/reyoung/events{/privacy}","received_events_url":"https://api.github.com/users/reyoung/received_events","type":"User","site_admin":false},"body":"OK，是因为他们返回了指针，所以我就没处理","created_at":"2016-11-10T04:51:41Z","updated_at":"2016-11-10T04:51:41Z","html_url":"https://github.com/wangkuiyi/ci/pull/6#discussion_r87328445","pull_request_url":"https://api.github.com/repos/wangkuiyi/ci/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/wangkuiyi/ci/pulls/comments/87328445"},"html":{"href":"https://github.com/wangkuiyi/ci/pull/6#discussion_r87328445"},"pull_request":{"href":"https://api.github.com/repos/wangkuiyi/ci/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/wangkuiyi/ci/pulls/6","id":91354089,"html_url":"https://github.com/wangkuiyi/ci/pull/6","diff_url":"https://github.com/wangkuiyi/ci/pull/6.diff","patch_url":"https://github.com/wangkuiyi/ci/pull/6.patch","issue_url":"https://api.github.com/repos/wangkuiyi/ci/issues/6","number":6,"state":"open","locked":false,"title":"Refine ci server","user":{"login":"reyoung","id":728699,"avatar_url":"https://avatars.githubusercontent.com/u/728699?v=3","gravatar_id":"","url":"https://api.github.com/users/reyoung","html_url":"https://github.com/reyoung","followers_url":"https://api.github.com/users/reyoung/followers","following_url":"https://api.github.com/users/reyoung/following{/other_user}","gists_url":"https://api.github.com/users/reyoung/gists{/gist_id}","starred_url":"https://api.github.com/users/reyoung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reyoung/subscriptions","organizations_url":"https://api.github.com/users/reyoung/orgs","repos_url":"https://api.github.com/users/reyoung/repos","events_url":"https://api.github.com/users/reyoung/events{/privacy}","received_events_url":"https://api.github.com/users/reyoung/received_events","type":"User","site_admin":false},"body":"还在做。主要是整理了一下code，重新弄了一下数据库。\n\n因为，首先， PushEvent 和 Build是一对多的关系。 其次，不只有PushEvent一种Event，还有PullRequestEvent。最后，把数据库从mysql换成postgresql，因为postgresql支持数组，这样我们读写stdout和stderr是非常方便的。\n\n整理了一下code，不过我也没咋写过golang，差不多按照 ngrok 的结构写的。\n\n还在搞，周末我再看看，不需要现在merge\n","created_at":"2016-10-28T09:59:53Z","updated_at":"2016-11-10T04:51:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4542832091060cebfe74baad8916e127fbea6806","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/wangkuiyi/ci/pulls/6/commits","review_comments_url":"https://api.github.com/repos/wangkuiyi/ci/pulls/6/comments","review_comment_url":"https://api.github.com/repos/wangkuiyi/ci/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wangkuiyi/ci/issues/6/comments","statuses_url":"https://api.github.com/repos/wangkuiyi/ci/statuses/687d74ae5b5f0b0b7c32bfe9aa9f0c99110154c6","head":{"label":"wangkuiyi:refine_ci_server","ref":"refine_ci_server","sha":"687d74ae5b5f0b0b7c32bfe9aa9f0c99110154c6","user":{"login":"wangkuiyi","id":1548775,"avatar_url":"https://avatars.githubusercontent.com/u/1548775?v=3","gravatar_id":"","url":"https://api.github.com/users/wangkuiyi","html_url":"https://github.com/wangkuiyi","followers_url":"https://api.github.com/users/wangkuiyi/followers","following_url":"https://api.github.com/users/wangkuiyi/following{/other_user}","gists_url":"https://api.github.com/users/wangkuiyi/gists{/gist_id}","starred_url":"https://api.github.com/users/wangkuiyi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wangkuiyi/subscriptions","organizations_url":"https://api.github.com/users/wangkuiyi/orgs","repos_url":"https://api.github.com/users/wangkuiyi/repos","events_url":"https://api.github.com/users/wangkuiyi/events{/privacy}","received_events_url":"https://api.github.com/users/wangkuiyi/received_events","type":"User","site_admin":false},"repo":{"id":70202212,"name":"ci","full_name":"wangkuiyi/ci","owner":{"login":"wangkuiyi","id":1548775,"avatar_url":"https://avatars.githubusercontent.com/u/1548775?v=3","gravatar_id":"","url":"https://api.github.com/users/wangkuiyi","html_url":"https://github.com/wangkuiyi","followers_url":"https://api.github.com/users/wangkuiyi/followers","following_url":"https://api.github.com/users/wangkuiyi/following{/other_user}","gists_url":"https://api.github.com/users/wangkuiyi/gists{/gist_id}","starred_url":"https://api.github.com/users/wangkuiyi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wangkuiyi/subscriptions","organizations_url":"https://api.github.com/users/wangkuiyi/orgs","repos_url":"https://api.github.com/users/wangkuiyi/repos","events_url":"https://api.github.com/users/wangkuiyi/events{/privacy}","received_events_url":"https://api.github.com/users/wangkuiyi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/wangkuiyi/ci","description":null,"fork":false,"url":"https://api.github.com/repos/wangkuiyi/ci","forks_url":"https://api.github.com/repos/wangkuiyi/ci/forks","keys_url":"https://api.github.com/repos/wangkuiyi/ci/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wangkuiyi/ci/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wangkuiyi/ci/teams","hooks_url":"https://api.github.com/repos/wangkuiyi/ci/hooks","issue_events_url":"https://api.github.com/repos/wangkuiyi/ci/issues/events{/number}","events_url":"https://api.github.com/repos/wangkuiyi/ci/events","assignees_url":"https://api.github.com/repos/wangkuiyi/ci/assignees{/user}","branches_url":"https://api.github.com/repos/wangkuiyi/ci/branches{/branch}","tags_url":"https://api.github.com/repos/wangkuiyi/ci/tags","blobs_url":"https://api.github.com/repos/wangkuiyi/ci/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wangkuiyi/ci/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wangkuiyi/ci/git/refs{/sha}","trees_url":"https://api.github.com/repos/wangkuiyi/ci/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wangkuiyi/ci/statuses/{sha}","languages_url":"https://api.github.com/repos/wangkuiyi/ci/languages","stargazers_url":"https://api.github.com/repos/wangkuiyi/ci/stargazers","contributors_url":"https://api.github.com/repos/wangkuiyi/ci/contributors","subscribers_url":"https://api.github.com/repos/wangkuiyi/ci/subscribers","subscription_url":"https://api.github.com/repos/wangkuiyi/ci/subscription","commits_url":"https://api.github.com/repos/wangkuiyi/ci/commits{/sha}","git_commits_url":"https://api.github.com/repos/wangkuiyi/ci/git/commits{/sha}","comments_url":"https://api.github.com/repos/wangkuiyi/ci/comments{/number}","issue_comment_url":"https://api.github.com/repos/wangkuiyi/ci/issues/comments{/number}","contents_url":"https://api.github.com/repos/wangkuiyi/ci/contents/{+path}","compare_url":"https://api.github.com/repos/wangkuiyi/ci/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wangkuiyi/ci/merges","archive_url":"https://api.github.com/repos/wangkuiyi/ci/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wangkuiyi/ci/downloads","issues_url":"https://api.github.com/repos/wangkuiyi/ci/issues{/number}","pulls_url":"https://api.github.com/repos/wangkuiyi/ci/pulls{/number}","milestones_url":"https://api.github.com/repos/wangkuiyi/ci/milestones{/number}","notifications_url":"https://api.github.com/repos/wangkuiyi/ci/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wangkuiyi/ci/labels{/name}","releases_url":"https://api.github.com/repos/wangkuiyi/ci/releases{/id}","deployments_url":"https://api.github.com/repos/wangkuiyi/ci/deployments","created_at":"2016-10-06T23:57:27Z","updated_at":"2016-10-26T05:46:25Z","pushed_at":"2016-11-09T15:46:11Z","git_url":"git://github.com/wangkuiyi/ci.git","ssh_url":"git@github.com:wangkuiyi/ci.git","clone_url":"https://github.com/wangkuiyi/ci.git","svn_url":"https://github.com/wangkuiyi/ci","homepage":null,"size":294,"stargazers_count":2,"watchers_count":2,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":5,"forks":1,"open_issues":5,"watchers":2,"default_branch":"develop"}},"base":{"label":"wangkuiyi:develop","ref":"develop","sha":"ce3d71b132aa140b52b232d65cffe21f41ec34e1","user":{"login":"wangkuiyi","id":1548775,"avatar_url":"https://avatars.githubusercontent.com/u/1548775?v=3","gravatar_id":"","url":"https://api.github.com/users/wangkuiyi","html_url":"https://github.com/wangkuiyi","followers_url":"https://api.github.com/users/wangkuiyi/followers","following_url":"https://api.github.com/users/wangkuiyi/following{/other_user}","gists_url":"https://api.github.com/users/wangkuiyi/gists{/gist_id}","starred_url":"https://api.github.com/users/wangkuiyi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wangkuiyi/subscriptions","organizations_url":"https://api.github.com/users/wangkuiyi/orgs","repos_url":"https://api.github.com/users/wangkuiyi/repos","events_url":"https://api.github.com/users/wangkuiyi/events{/privacy}","received_events_url":"https://api.github.com/users/wangkuiyi/received_events","type":"User","site_admin":false},"repo":{"id":70202212,"name":"ci","full_name":"wangkuiyi/ci","owner":{"login":"wangkuiyi","id":1548775,"avatar_url":"https://avatars.githubusercontent.com/u/1548775?v=3","gravatar_id":"","url":"https://api.github.com/users/wangkuiyi","html_url":"https://github.com/wangkuiyi","followers_url":"https://api.github.com/users/wangkuiyi/followers","following_url":"https://api.github.com/users/wangkuiyi/following{/other_user}","gists_url":"https://api.github.com/users/wangkuiyi/gists{/gist_id}","starred_url":"https://api.github.com/users/wangkuiyi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wangkuiyi/subscriptions","organizations_url":"https://api.github.com/users/wangkuiyi/orgs","repos_url":"https://api.github.com/users/wangkuiyi/repos","events_url":"https://api.github.com/users/wangkuiyi/events{/privacy}","received_events_url":"https://api.github.com/users/wangkuiyi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/wangkuiyi/ci","description":null,"fork":false,"url":"https://api.github.com/repos/wangkuiyi/ci","forks_url":"https://api.github.com/repos/wangkuiyi/ci/forks","keys_url":"https://api.github.com/repos/wangkuiyi/ci/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wangkuiyi/ci/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wangkuiyi/ci/teams","hooks_url":"https://api.github.com/repos/wangkuiyi/ci/hooks","issue_events_url":"https://api.github.com/repos/wangkuiyi/ci/issues/events{/number}","events_url":"https://api.github.com/repos/wangkuiyi/ci/events","assignees_url":"https://api.github.com/repos/wangkuiyi/ci/assignees{/user}","branches_url":"https://api.github.com/repos/wangkuiyi/ci/branches{/branch}","tags_url":"https://api.github.com/repos/wangkuiyi/ci/tags","blobs_url":"https://api.github.com/repos/wangkuiyi/ci/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wangkuiyi/ci/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wangkuiyi/ci/git/refs{/sha}","trees_url":"https://api.github.com/repos/wangkuiyi/ci/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wangkuiyi/ci/statuses/{sha}","languages_url":"https://api.github.com/repos/wangkuiyi/ci/languages","stargazers_url":"https://api.github.com/repos/wangkuiyi/ci/stargazers","contributors_url":"https://api.github.com/repos/wangkuiyi/ci/contributors","subscribers_url":"https://api.github.com/repos/wangkuiyi/ci/subscribers","subscription_url":"https://api.github.com/repos/wangkuiyi/ci/subscription","commits_url":"https://api.github.com/repos/wangkuiyi/ci/commits{/sha}","git_commits_url":"https://api.github.com/repos/wangkuiyi/ci/git/commits{/sha}","comments_url":"https://api.github.com/repos/wangkuiyi/ci/comments{/number}","issue_comment_url":"https://api.github.com/repos/wangkuiyi/ci/issues/comments{/number}","contents_url":"https://api.github.com/repos/wangkuiyi/ci/contents/{+path}","compare_url":"https://api.github.com/repos/wangkuiyi/ci/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wangkuiyi/ci/merges","archive_url":"https://api.github.com/repos/wangkuiyi/ci/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wangkuiyi/ci/downloads","issues_url":"https://api.github.com/repos/wangkuiyi/ci/issues{/number}","pulls_url":"https://api.github.com/repos/wangkuiyi/ci/pulls{/number}","milestones_url":"https://api.github.com/repos/wangkuiyi/ci/milestones{/number}","notifications_url":"https://api.github.com/repos/wangkuiyi/ci/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wangkuiyi/ci/labels{/name}","releases_url":"https://api.github.com/repos/wangkuiyi/ci/releases{/id}","deployments_url":"https://api.github.com/repos/wangkuiyi/ci/deployments","created_at":"2016-10-06T23:57:27Z","updated_at":"2016-10-26T05:46:25Z","pushed_at":"2016-11-09T15:46:11Z","git_url":"git://github.com/wangkuiyi/ci.git","ssh_url":"git@github.com:wangkuiyi/ci.git","clone_url":"https://github.com/wangkuiyi/ci.git","svn_url":"https://github.com/wangkuiyi/ci","homepage":null,"size":294,"stargazers_count":2,"watchers_count":2,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":5,"forks":1,"open_issues":5,"watchers":2,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/wangkuiyi/ci/pulls/6"},"html":{"href":"https://github.com/wangkuiyi/ci/pull/6"},"issue":{"href":"https://api.github.com/repos/wangkuiyi/ci/issues/6"},"comments":{"href":"https://api.github.com/repos/wangkuiyi/ci/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/wangkuiyi/ci/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/wangkuiyi/ci/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wangkuiyi/ci/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/wangkuiyi/ci/statuses/687d74ae5b5f0b0b7c32bfe9aa9f0c99110154c6"}}}}
{"actor":{"display_login":"reyoung"}}