{"action":"created","comment":{"url":"https://api.github.com/repos/kubernetes/contrib/pulls/comments/69367430","id":69367430,"diff_hunk":"@@ -0,0 +1,118 @@\n+/*\n+Copyright 2015 The Kubernetes Authors All rights reserved.\n+\n+Licensed under the Apache License, Version 2.0 (the \"License\");\n+you may not use this file except in compliance with the License.\n+You may obtain a copy of the License at\n+\n+    http://www.apache.org/licenses/LICENSE-2.0\n+\n+Unless required by applicable law or agreed to in writing, software\n+distributed under the License is distributed on an \"AS IS\" BASIS,\n+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+See the License for the specific language governing permissions and\n+limitations under the License.\n+*/\n+\n+package mungers\n+\n+import (\n+\t\"fmt\"\n+\t\"github.com/golang/glog\"\n+\t\"github.com/google/go-github/github\"\n+\t\"reflect\"\n+\t\"runtime\"\n+\t\"testing\"\n+)\n+\n+var (\n+\t_                              = fmt.Printf\n+\t_                              = glog.Errorf\n+\trepoLabelNames []string        = []string{\"team/abc\", \"team/def\", \"team/ghi\"}\n+\trepoColors     []string        = []string{\"d4c5f9\", \"fef2c0\", \"c7def8\"}\n+\tfileLabelNames []string        = []string{\"release-note\", \"dependency/rkt\", \"team/ghi\"}\n+\tfileColors     []string        = []string{\"d4c5f9\", \"fbfa04\", \"c7def8\"}\n+\trepoLabels     []*github.Label = make([]*github.Label, 0, 0)\n+\tfileLabels     []*github.Label = make([]*github.Label, 0, 0)\n+)\n+\n+type LabelAccessorTest struct {\n+\tAddedLabels []*github.Label\n+\tRepoLabels  []*github.Label\n+}\n+\n+func (l *LabelAccessorTest) AddLabel(label *github.Label) error {\n+\tl.AddedLabels = append(l.AddedLabels, label)\n+\treturn nil\n+}\n+\n+func (l *LabelAccessorTest) GetLabels() ([]*github.Label, error) {\n+\treturn l.RepoLabels, nil\n+}\n+\n+func (l *LabelAccessorTest) GetFileContents(string) (string, string, error) {\n+\treturn `- color: d4c5f9\n+  name: release-note\n+- color: fbfa04\n+  name: dependency/rkt\n+- color: c7def8\n+  name: team/ghi`, \"sha\", nil\n+}\n+\n+func makeCheckLabelsMunger() *CheckLabelsMunger {\n+\treturn &CheckLabelsMunger{\n+\t\tlabelAccessor: &LabelAccessorTest{},\n+\t}\n+}\n+\n+func TestEachLoop(t *testing.T) {\n+\truntime.GOMAXPROCS(runtime.NumCPU())\n+\n+\t// setup some labels for the test.\n+\tfor i := 0; i < len(fileLabelNames); i++ {\n+\t\tg := github.Label{Name: &fileLabelNames[i], Color: &fileColors[i]}\n+\t\tfileLabels = append(fileLabels, &g)\n+\t}\n+\n+\tfor i := 0; i < len(repoLabelNames); i++ {\n+\t\tg := github.Label{Name: &repoLabelNames[i], Color: &repoColors[i]}\n+\t\trepoLabels = append(repoLabels, &g)\n+\t}\n+\n+\ttests := []struct {\n+\t\tname       string\n+\t\trepoLabels []*github.Label\n+\t\texpected   []*github.Label\n+\t}{\n+\t\t{\n+\t\t\tname:       \"No labels in repository.\",\n+\t\t\trepoLabels: []*github.Label{},\n+\t\t\texpected:   fileLabels,\n+\t\t},\n+\t\t{\n+\t\t\tname:       \"Identical labels in repository and file.\",\n+\t\t\trepoLabels: fileLabels,\n+\t\t\texpected:   []*github.Label{},\n+\t\t},\n+\t\t{\n+\t\t\tname:       \"Adding new labels with existing labels in repository.\",\n+\t\t\trepoLabels: repoLabels,\n+\t\t\texpected:   fileLabels[0:2],\n+\t\t},","path":"mungegithub/mungers/check-labels_test.go","position":101,"original_position":101,"commit_id":"d6ff9bf9494587441eb06d2c7fbc69e7b9739b97","original_commit_id":"d6ff9bf9494587441eb06d2c7fbc69e7b9739b97","user":{"login":"foxish","id":906471,"avatar_url":"https://avatars.githubusercontent.com/u/906471?v=3","gravatar_id":"","url":"https://api.github.com/users/foxish","html_url":"https://github.com/foxish","followers_url":"https://api.github.com/users/foxish/followers","following_url":"https://api.github.com/users/foxish/following{/other_user}","gists_url":"https://api.github.com/users/foxish/gists{/gist_id}","starred_url":"https://api.github.com/users/foxish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/foxish/subscriptions","organizations_url":"https://api.github.com/users/foxish/orgs","repos_url":"https://api.github.com/users/foxish/repos","events_url":"https://api.github.com/users/foxish/events{/privacy}","received_events_url":"https://api.github.com/users/foxish/received_events","type":"User","site_admin":false},"body":"As far as I checked, the label name needs to be unique, or github won't let us add it, even with a different color. In check-labels.go:103, the name of the label is checked for uniqueness and we don't add it in the above case.","created_at":"2016-07-01T23:49:36Z","updated_at":"2016-07-01T23:49:36Z","html_url":"https://github.com/kubernetes/contrib/pull/1306#discussion_r69367430","pull_request_url":"https://api.github.com/repos/kubernetes/contrib/pulls/1306","_links":{"self":{"href":"https://api.github.com/repos/kubernetes/contrib/pulls/comments/69367430"},"html":{"href":"https://github.com/kubernetes/contrib/pull/1306#discussion_r69367430"},"pull_request":{"href":"https://api.github.com/repos/kubernetes/contrib/pulls/1306"}}},"pull_request":{"url":"https://api.github.com/repos/kubernetes/contrib/pulls/1306","id":76027432,"html_url":"https://github.com/kubernetes/contrib/pull/1306","diff_url":"https://github.com/kubernetes/contrib/pull/1306.diff","patch_url":"https://github.com/kubernetes/contrib/pull/1306.patch","issue_url":"https://api.github.com/repos/kubernetes/contrib/issues/1306","number":1306,"state":"open","locked":false,"title":"Added check-labels munger and corresponding tests.","user":{"login":"foxish","id":906471,"avatar_url":"https://avatars.githubusercontent.com/u/906471?v=3","gravatar_id":"","url":"https://api.github.com/users/foxish","html_url":"https://github.com/foxish","followers_url":"https://api.github.com/users/foxish/followers","following_url":"https://api.github.com/users/foxish/following{/other_user}","gists_url":"https://api.github.com/users/foxish/gists{/gist_id}","starred_url":"https://api.github.com/users/foxish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/foxish/subscriptions","organizations_url":"https://api.github.com/users/foxish/orgs","repos_url":"https://api.github.com/users/foxish/repos","events_url":"https://api.github.com/users/foxish/events{/privacy}","received_events_url":"https://api.github.com/users/foxish/received_events","type":"User","site_admin":false},"body":"The munger checks for changes in label config yaml file and creates labels as necessary in the repository.","created_at":"2016-07-01T19:39:35Z","updated_at":"2016-07-01T23:49:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c90ed3923915cbf0e74a6abc80a5c957ba9eaa60","assignee":{"login":"lavalamp","id":647318,"avatar_url":"https://avatars.githubusercontent.com/u/647318?v=3","gravatar_id":"","url":"https://api.github.com/users/lavalamp","html_url":"https://github.com/lavalamp","followers_url":"https://api.github.com/users/lavalamp/followers","following_url":"https://api.github.com/users/lavalamp/following{/other_user}","gists_url":"https://api.github.com/users/lavalamp/gists{/gist_id}","starred_url":"https://api.github.com/users/lavalamp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lavalamp/subscriptions","organizations_url":"https://api.github.com/users/lavalamp/orgs","repos_url":"https://api.github.com/users/lavalamp/repos","events_url":"https://api.github.com/users/lavalamp/events{/privacy}","received_events_url":"https://api.github.com/users/lavalamp/received_events","type":"User","site_admin":false},"assignees":[{"login":"lavalamp","id":647318,"avatar_url":"https://avatars.githubusercontent.com/u/647318?v=3","gravatar_id":"","url":"https://api.github.com/users/lavalamp","html_url":"https://github.com/lavalamp","followers_url":"https://api.github.com/users/lavalamp/followers","following_url":"https://api.github.com/users/lavalamp/following{/other_user}","gists_url":"https://api.github.com/users/lavalamp/gists{/gist_id}","starred_url":"https://api.github.com/users/lavalamp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lavalamp/subscriptions","organizations_url":"https://api.github.com/users/lavalamp/orgs","repos_url":"https://api.github.com/users/lavalamp/repos","events_url":"https://api.github.com/users/lavalamp/events{/privacy}","received_events_url":"https://api.github.com/users/lavalamp/received_events","type":"User","site_admin":false},{"login":"janetkuo","id":4876867,"avatar_url":"https://avatars.githubusercontent.com/u/4876867?v=3","gravatar_id":"","url":"https://api.github.com/users/janetkuo","html_url":"https://github.com/janetkuo","followers_url":"https://api.github.com/users/janetkuo/followers","following_url":"https://api.github.com/users/janetkuo/following{/other_user}","gists_url":"https://api.github.com/users/janetkuo/gists{/gist_id}","starred_url":"https://api.github.com/users/janetkuo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janetkuo/subscriptions","organizations_url":"https://api.github.com/users/janetkuo/orgs","repos_url":"https://api.github.com/users/janetkuo/repos","events_url":"https://api.github.com/users/janetkuo/events{/privacy}","received_events_url":"https://api.github.com/users/janetkuo/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/kubernetes/contrib/pulls/1306/commits","review_comments_url":"https://api.github.com/repos/kubernetes/contrib/pulls/1306/comments","review_comment_url":"https://api.github.com/repos/kubernetes/contrib/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kubernetes/contrib/issues/1306/comments","statuses_url":"https://api.github.com/repos/kubernetes/contrib/statuses/d6ff9bf9494587441eb06d2c7fbc69e7b9739b97","head":{"label":"foxish:master","ref":"master","sha":"d6ff9bf9494587441eb06d2c7fbc69e7b9739b97","user":{"login":"foxish","id":906471,"avatar_url":"https://avatars.githubusercontent.com/u/906471?v=3","gravatar_id":"","url":"https://api.github.com/users/foxish","html_url":"https://github.com/foxish","followers_url":"https://api.github.com/users/foxish/followers","following_url":"https://api.github.com/users/foxish/following{/other_user}","gists_url":"https://api.github.com/users/foxish/gists{/gist_id}","starred_url":"https://api.github.com/users/foxish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/foxish/subscriptions","organizations_url":"https://api.github.com/users/foxish/orgs","repos_url":"https://api.github.com/users/foxish/repos","events_url":"https://api.github.com/users/foxish/events{/privacy}","received_events_url":"https://api.github.com/users/foxish/received_events","type":"User","site_admin":false},"repo":{"id":62414944,"name":"contrib","full_name":"foxish/contrib","owner":{"login":"foxish","id":906471,"avatar_url":"https://avatars.githubusercontent.com/u/906471?v=3","gravatar_id":"","url":"https://api.github.com/users/foxish","html_url":"https://github.com/foxish","followers_url":"https://api.github.com/users/foxish/followers","following_url":"https://api.github.com/users/foxish/following{/other_user}","gists_url":"https://api.github.com/users/foxish/gists{/gist_id}","starred_url":"https://api.github.com/users/foxish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/foxish/subscriptions","organizations_url":"https://api.github.com/users/foxish/orgs","repos_url":"https://api.github.com/users/foxish/repos","events_url":"https://api.github.com/users/foxish/events{/privacy}","received_events_url":"https://api.github.com/users/foxish/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/foxish/contrib","description":"This is a place for various components in the Kubernetes ecosystem that aren't part of the Kubernetes core. Consider creating a new repo instead.","fork":true,"url":"https://api.github.com/repos/foxish/contrib","forks_url":"https://api.github.com/repos/foxish/contrib/forks","keys_url":"https://api.github.com/repos/foxish/contrib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/foxish/contrib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/foxish/contrib/teams","hooks_url":"https://api.github.com/repos/foxish/contrib/hooks","issue_events_url":"https://api.github.com/repos/foxish/contrib/issues/events{/number}","events_url":"https://api.github.com/repos/foxish/contrib/events","assignees_url":"https://api.github.com/repos/foxish/contrib/assignees{/user}","branches_url":"https://api.github.com/repos/foxish/contrib/branches{/branch}","tags_url":"https://api.github.com/repos/foxish/contrib/tags","blobs_url":"https://api.github.com/repos/foxish/contrib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/foxish/contrib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/foxish/contrib/git/refs{/sha}","trees_url":"https://api.github.com/repos/foxish/contrib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/foxish/contrib/statuses/{sha}","languages_url":"https://api.github.com/repos/foxish/contrib/languages","stargazers_url":"https://api.github.com/repos/foxish/contrib/stargazers","contributors_url":"https://api.github.com/repos/foxish/contrib/contributors","subscribers_url":"https://api.github.com/repos/foxish/contrib/subscribers","subscription_url":"https://api.github.com/repos/foxish/contrib/subscription","commits_url":"https://api.github.com/repos/foxish/contrib/commits{/sha}","git_commits_url":"https://api.github.com/repos/foxish/contrib/git/commits{/sha}","comments_url":"https://api.github.com/repos/foxish/contrib/comments{/number}","issue_comment_url":"https://api.github.com/repos/foxish/contrib/issues/comments{/number}","contents_url":"https://api.github.com/repos/foxish/contrib/contents/{+path}","compare_url":"https://api.github.com/repos/foxish/contrib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/foxish/contrib/merges","archive_url":"https://api.github.com/repos/foxish/contrib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/foxish/contrib/downloads","issues_url":"https://api.github.com/repos/foxish/contrib/issues{/number}","pulls_url":"https://api.github.com/repos/foxish/contrib/pulls{/number}","milestones_url":"https://api.github.com/repos/foxish/contrib/milestones{/number}","notifications_url":"https://api.github.com/repos/foxish/contrib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/foxish/contrib/labels{/name}","releases_url":"https://api.github.com/repos/foxish/contrib/releases{/id}","deployments_url":"https://api.github.com/repos/foxish/contrib/deployments","created_at":"2016-07-01T19:19:18Z","updated_at":"2016-07-01T19:19:21Z","pushed_at":"2016-07-01T21:13:30Z","git_url":"git://github.com/foxish/contrib.git","ssh_url":"git@github.com:foxish/contrib.git","clone_url":"https://github.com/foxish/contrib.git","svn_url":"https://github.com/foxish/contrib","homepage":"","size":29827,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"kubernetes:master","ref":"master","sha":"e2a88154e54dc2ed9ad97b14bd435476a5368849","user":{"login":"kubernetes","id":13629408,"avatar_url":"https://avatars.githubusercontent.com/u/13629408?v=3","gravatar_id":"","url":"https://api.github.com/users/kubernetes","html_url":"https://github.com/kubernetes","followers_url":"https://api.github.com/users/kubernetes/followers","following_url":"https://api.github.com/users/kubernetes/following{/other_user}","gists_url":"https://api.github.com/users/kubernetes/gists{/gist_id}","starred_url":"https://api.github.com/users/kubernetes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kubernetes/subscriptions","organizations_url":"https://api.github.com/users/kubernetes/orgs","repos_url":"https://api.github.com/users/kubernetes/repos","events_url":"https://api.github.com/users/kubernetes/events{/privacy}","received_events_url":"https://api.github.com/users/kubernetes/received_events","type":"Organization","site_admin":false},"repo":{"id":40686014,"name":"contrib","full_name":"kubernetes/contrib","owner":{"login":"kubernetes","id":13629408,"avatar_url":"https://avatars.githubusercontent.com/u/13629408?v=3","gravatar_id":"","url":"https://api.github.com/users/kubernetes","html_url":"https://github.com/kubernetes","followers_url":"https://api.github.com/users/kubernetes/followers","following_url":"https://api.github.com/users/kubernetes/following{/other_user}","gists_url":"https://api.github.com/users/kubernetes/gists{/gist_id}","starred_url":"https://api.github.com/users/kubernetes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kubernetes/subscriptions","organizations_url":"https://api.github.com/users/kubernetes/orgs","repos_url":"https://api.github.com/users/kubernetes/repos","events_url":"https://api.github.com/users/kubernetes/events{/privacy}","received_events_url":"https://api.github.com/users/kubernetes/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kubernetes/contrib","description":"This is a place for various components in the Kubernetes ecosystem that aren't part of the Kubernetes core. Consider creating a new repo instead.","fork":false,"url":"https://api.github.com/repos/kubernetes/contrib","forks_url":"https://api.github.com/repos/kubernetes/contrib/forks","keys_url":"https://api.github.com/repos/kubernetes/contrib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kubernetes/contrib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kubernetes/contrib/teams","hooks_url":"https://api.github.com/repos/kubernetes/contrib/hooks","issue_events_url":"https://api.github.com/repos/kubernetes/contrib/issues/events{/number}","events_url":"https://api.github.com/repos/kubernetes/contrib/events","assignees_url":"https://api.github.com/repos/kubernetes/contrib/assignees{/user}","branches_url":"https://api.github.com/repos/kubernetes/contrib/branches{/branch}","tags_url":"https://api.github.com/repos/kubernetes/contrib/tags","blobs_url":"https://api.github.com/repos/kubernetes/contrib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kubernetes/contrib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kubernetes/contrib/git/refs{/sha}","trees_url":"https://api.github.com/repos/kubernetes/contrib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kubernetes/contrib/statuses/{sha}","languages_url":"https://api.github.com/repos/kubernetes/contrib/languages","stargazers_url":"https://api.github.com/repos/kubernetes/contrib/stargazers","contributors_url":"https://api.github.com/repos/kubernetes/contrib/contributors","subscribers_url":"https://api.github.com/repos/kubernetes/contrib/subscribers","subscription_url":"https://api.github.com/repos/kubernetes/contrib/subscription","commits_url":"https://api.github.com/repos/kubernetes/contrib/commits{/sha}","git_commits_url":"https://api.github.com/repos/kubernetes/contrib/git/commits{/sha}","comments_url":"https://api.github.com/repos/kubernetes/contrib/comments{/number}","issue_comment_url":"https://api.github.com/repos/kubernetes/contrib/issues/comments{/number}","contents_url":"https://api.github.com/repos/kubernetes/contrib/contents/{+path}","compare_url":"https://api.github.com/repos/kubernetes/contrib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kubernetes/contrib/merges","archive_url":"https://api.github.com/repos/kubernetes/contrib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kubernetes/contrib/downloads","issues_url":"https://api.github.com/repos/kubernetes/contrib/issues{/number}","pulls_url":"https://api.github.com/repos/kubernetes/contrib/pulls{/number}","milestones_url":"https://api.github.com/repos/kubernetes/contrib/milestones{/number}","notifications_url":"https://api.github.com/repos/kubernetes/contrib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kubernetes/contrib/labels{/name}","releases_url":"https://api.github.com/repos/kubernetes/contrib/releases{/id}","deployments_url":"https://api.github.com/repos/kubernetes/contrib/deployments","created_at":"2015-08-13T23:18:26Z","updated_at":"2016-07-01T17:37:24Z","pushed_at":"2016-07-01T23:18:54Z","git_url":"git://github.com/kubernetes/contrib.git","ssh_url":"git@github.com:kubernetes/contrib.git","clone_url":"https://github.com/kubernetes/contrib.git","svn_url":"https://github.com/kubernetes/contrib","homepage":"","size":54338,"stargazers_count":351,"watchers_count":351,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":351,"mirror_url":null,"open_issues_count":242,"forks":351,"open_issues":242,"watchers":351,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kubernetes/contrib/pulls/1306"},"html":{"href":"https://github.com/kubernetes/contrib/pull/1306"},"issue":{"href":"https://api.github.com/repos/kubernetes/contrib/issues/1306"},"comments":{"href":"https://api.github.com/repos/kubernetes/contrib/issues/1306/comments"},"review_comments":{"href":"https://api.github.com/repos/kubernetes/contrib/pulls/1306/comments"},"review_comment":{"href":"https://api.github.com/repos/kubernetes/contrib/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kubernetes/contrib/pulls/1306/commits"},"statuses":{"href":"https://api.github.com/repos/kubernetes/contrib/statuses/d6ff9bf9494587441eb06d2c7fbc69e7b9739b97"}}}}
{"actor":{"display_login":"foxish"}}