{"action":"created","comment":{"url":"https://api.github.com/repos/docker/docker/pulls/comments/27298618","id":27298618,"diff_hunk":"@@ -1,26 +1,56 @@\n package fileutils\n \n import (\n-\t\"github.com/Sirupsen/logrus\"\n \t\"path/filepath\"\n+\n+\t\"github.com/Sirupsen/logrus\"\n )\n \n // Matches returns true if relFilePath matches any of the patterns\n+// and isn't excluded by any of the subsequent patterns.\n func Matches(relFilePath string, patterns []string) (bool, error) {\n-\tfor _, exclude := range patterns {\n-\t\tmatched, err := filepath.Match(exclude, relFilePath)\n+\n+\tmatched := false\n+\n+\tfor _, pattern := range patterns {\n+\n+\t\tvar negative bool\n+\t\tif pattern == \"\" {\n+\t\t\tcontinue\n+\t\t}\n+\n+\t\tif pattern[0] == '!' {\n+\t\t\tif len(pattern) == 1 {\n+\t\t\t\tcontinue\n+\t\t\t}\n+\t\t\tnegative = true\n+\t\t\tpattern = pattern[1:]\n+\t\t}","path":"pkg/fileutils/fileutils.go","position":31,"original_position":31,"commit_id":"eb01a70ab65d1c1b6c03c5df6bed620649330c13","original_commit_id":"aebbcdaf87f0570bb09853e5ebe44db236339312","user":{"login":"duglin","id":1944671,"avatar_url":"https://avatars.githubusercontent.com/u/1944671?v=3","gravatar_id":"","url":"https://api.github.com/users/duglin","html_url":"https://github.com/duglin","followers_url":"https://api.github.com/users/duglin/followers","following_url":"https://api.github.com/users/duglin/following{/other_user}","gists_url":"https://api.github.com/users/duglin/gists{/gist_id}","starred_url":"https://api.github.com/users/duglin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duglin/subscriptions","organizations_url":"https://api.github.com/users/duglin/orgs","repos_url":"https://api.github.com/users/duglin/repos","events_url":"https://api.github.com/users/duglin/events{/privacy}","received_events_url":"https://api.github.com/users/duglin/received_events","type":"User","site_admin":false},"body":"But, let's add a testcase for it no matter which direction we go so that we make sure we get the expected behavior ","created_at":"2015-03-27T14:28:45Z","updated_at":"2015-03-27T14:28:45Z","html_url":"https://github.com/docker/docker/pull/11823#discussion_r27298618","pull_request_url":"https://api.github.com/repos/docker/docker/pulls/11823","_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/comments/27298618"},"html":{"href":"https://github.com/docker/docker/pull/11823#discussion_r27298618"},"pull_request":{"href":"https://api.github.com/repos/docker/docker/pulls/11823"}}},"pull_request":{"url":"https://api.github.com/repos/docker/docker/pulls/11823","id":32027986,"html_url":"https://github.com/docker/docker/pull/11823","diff_url":"https://github.com/docker/docker/pull/11823.diff","patch_url":"https://github.com/docker/docker/pull/11823.patch","issue_url":"https://api.github.com/repos/docker/docker/issues/11823","number":11823,"state":"open","locked":false,"title":".dockerignore ignore support. Fixes #9171","user":{"login":"omeid","id":1453118,"avatar_url":"https://avatars.githubusercontent.com/u/1453118?v=3","gravatar_id":"","url":"https://api.github.com/users/omeid","html_url":"https://github.com/omeid","followers_url":"https://api.github.com/users/omeid/followers","following_url":"https://api.github.com/users/omeid/following{/other_user}","gists_url":"https://api.github.com/users/omeid/gists{/gist_id}","starred_url":"https://api.github.com/users/omeid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/omeid/subscriptions","organizations_url":"https://api.github.com/users/omeid/orgs","repos_url":"https://api.github.com/users/omeid/repos","events_url":"https://api.github.com/users/omeid/events{/privacy}","received_events_url":"https://api.github.com/users/omeid/received_events","type":"User","site_admin":false},"body":"Signed-off-by: omeid <public@omeid.me>","created_at":"2015-03-26T15:23:59Z","updated_at":"2015-03-27T14:28:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a79360de0b06f0663c5807df03c568dbd56f8bcd","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/docker/docker/pulls/11823/commits","review_comments_url":"https://api.github.com/repos/docker/docker/pulls/11823/comments","review_comment_url":"https://api.github.com/repos/docker/docker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/docker/docker/issues/11823/comments","statuses_url":"https://api.github.com/repos/docker/docker/statuses/eb01a70ab65d1c1b6c03c5df6bed620649330c13","head":{"label":"omeid:dockerignore-ignores","ref":"dockerignore-ignores","sha":"eb01a70ab65d1c1b6c03c5df6bed620649330c13","user":{"login":"omeid","id":1453118,"avatar_url":"https://avatars.githubusercontent.com/u/1453118?v=3","gravatar_id":"","url":"https://api.github.com/users/omeid","html_url":"https://github.com/omeid","followers_url":"https://api.github.com/users/omeid/followers","following_url":"https://api.github.com/users/omeid/following{/other_user}","gists_url":"https://api.github.com/users/omeid/gists{/gist_id}","starred_url":"https://api.github.com/users/omeid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/omeid/subscriptions","organizations_url":"https://api.github.com/users/omeid/orgs","repos_url":"https://api.github.com/users/omeid/repos","events_url":"https://api.github.com/users/omeid/events{/privacy}","received_events_url":"https://api.github.com/users/omeid/received_events","type":"User","site_admin":false},"repo":{"id":29858812,"name":"docker","full_name":"omeid/docker","owner":{"login":"omeid","id":1453118,"avatar_url":"https://avatars.githubusercontent.com/u/1453118?v=3","gravatar_id":"","url":"https://api.github.com/users/omeid","html_url":"https://github.com/omeid","followers_url":"https://api.github.com/users/omeid/followers","following_url":"https://api.github.com/users/omeid/following{/other_user}","gists_url":"https://api.github.com/users/omeid/gists{/gist_id}","starred_url":"https://api.github.com/users/omeid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/omeid/subscriptions","organizations_url":"https://api.github.com/users/omeid/orgs","repos_url":"https://api.github.com/users/omeid/repos","events_url":"https://api.github.com/users/omeid/events{/privacy}","received_events_url":"https://api.github.com/users/omeid/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/omeid/docker","description":"Docker - the open-source application container engine","fork":true,"url":"https://api.github.com/repos/omeid/docker","forks_url":"https://api.github.com/repos/omeid/docker/forks","keys_url":"https://api.github.com/repos/omeid/docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/omeid/docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/omeid/docker/teams","hooks_url":"https://api.github.com/repos/omeid/docker/hooks","issue_events_url":"https://api.github.com/repos/omeid/docker/issues/events{/number}","events_url":"https://api.github.com/repos/omeid/docker/events","assignees_url":"https://api.github.com/repos/omeid/docker/assignees{/user}","branches_url":"https://api.github.com/repos/omeid/docker/branches{/branch}","tags_url":"https://api.github.com/repos/omeid/docker/tags","blobs_url":"https://api.github.com/repos/omeid/docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/omeid/docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/omeid/docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/omeid/docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/omeid/docker/statuses/{sha}","languages_url":"https://api.github.com/repos/omeid/docker/languages","stargazers_url":"https://api.github.com/repos/omeid/docker/stargazers","contributors_url":"https://api.github.com/repos/omeid/docker/contributors","subscribers_url":"https://api.github.com/repos/omeid/docker/subscribers","subscription_url":"https://api.github.com/repos/omeid/docker/subscription","commits_url":"https://api.github.com/repos/omeid/docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/omeid/docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/omeid/docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/omeid/docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/omeid/docker/contents/{+path}","compare_url":"https://api.github.com/repos/omeid/docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/omeid/docker/merges","archive_url":"https://api.github.com/repos/omeid/docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/omeid/docker/downloads","issues_url":"https://api.github.com/repos/omeid/docker/issues{/number}","pulls_url":"https://api.github.com/repos/omeid/docker/pulls{/number}","milestones_url":"https://api.github.com/repos/omeid/docker/milestones{/number}","notifications_url":"https://api.github.com/repos/omeid/docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/omeid/docker/labels{/name}","releases_url":"https://api.github.com/repos/omeid/docker/releases{/id}","created_at":"2015-01-26T11:49:57Z","updated_at":"2015-03-24T14:32:17Z","pushed_at":"2015-03-27T10:29:57Z","git_url":"git://github.com/omeid/docker.git","ssh_url":"git@github.com:omeid/docker.git","clone_url":"https://github.com/omeid/docker.git","svn_url":"https://github.com/omeid/docker","homepage":"http://www.docker.com","size":46960,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"docker:master","ref":"master","sha":"d2df901be3c5c964900de41286ba0c67aebfb5d1","user":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"repo":{"id":7691631,"name":"docker","full_name":"docker/docker","owner":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/docker/docker","description":"Docker - the open-source application container engine","fork":false,"url":"https://api.github.com/repos/docker/docker","forks_url":"https://api.github.com/repos/docker/docker/forks","keys_url":"https://api.github.com/repos/docker/docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/docker/docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/docker/docker/teams","hooks_url":"https://api.github.com/repos/docker/docker/hooks","issue_events_url":"https://api.github.com/repos/docker/docker/issues/events{/number}","events_url":"https://api.github.com/repos/docker/docker/events","assignees_url":"https://api.github.com/repos/docker/docker/assignees{/user}","branches_url":"https://api.github.com/repos/docker/docker/branches{/branch}","tags_url":"https://api.github.com/repos/docker/docker/tags","blobs_url":"https://api.github.com/repos/docker/docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/docker/docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/docker/docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/docker/docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/docker/docker/statuses/{sha}","languages_url":"https://api.github.com/repos/docker/docker/languages","stargazers_url":"https://api.github.com/repos/docker/docker/stargazers","contributors_url":"https://api.github.com/repos/docker/docker/contributors","subscribers_url":"https://api.github.com/repos/docker/docker/subscribers","subscription_url":"https://api.github.com/repos/docker/docker/subscription","commits_url":"https://api.github.com/repos/docker/docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/docker/docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/docker/docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/docker/docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/docker/docker/contents/{+path}","compare_url":"https://api.github.com/repos/docker/docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/docker/docker/merges","archive_url":"https://api.github.com/repos/docker/docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/docker/docker/downloads","issues_url":"https://api.github.com/repos/docker/docker/issues{/number}","pulls_url":"https://api.github.com/repos/docker/docker/pulls{/number}","milestones_url":"https://api.github.com/repos/docker/docker/milestones{/number}","notifications_url":"https://api.github.com/repos/docker/docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/docker/docker/labels{/name}","releases_url":"https://api.github.com/repos/docker/docker/releases{/id}","created_at":"2013-01-18T18:10:57Z","updated_at":"2015-03-27T14:12:28Z","pushed_at":"2015-03-27T13:25:27Z","git_url":"git://github.com/docker/docker.git","ssh_url":"git@github.com:docker/docker.git","clone_url":"https://github.com/docker/docker.git","svn_url":"https://github.com/docker/docker","homepage":"http://www.docker.com","size":161597,"stargazers_count":20331,"watchers_count":20331,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4531,"mirror_url":null,"open_issues_count":887,"forks":4531,"open_issues":887,"watchers":20331,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/11823"},"html":{"href":"https://github.com/docker/docker/pull/11823"},"issue":{"href":"https://api.github.com/repos/docker/docker/issues/11823"},"comments":{"href":"https://api.github.com/repos/docker/docker/issues/11823/comments"},"review_comments":{"href":"https://api.github.com/repos/docker/docker/pulls/11823/comments"},"review_comment":{"href":"https://api.github.com/repos/docker/docker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/docker/docker/pulls/11823/commits"},"statuses":{"href":"https://api.github.com/repos/docker/docker/statuses/eb01a70ab65d1c1b6c03c5df6bed620649330c13"}}}}