{"action":"created","comment":{"url":"https://api.github.com/repos/docker/docker/pulls/comments/44837070","id":44837070,"diff_hunk":"@@ -117,6 +119,101 @@ func OptimizedMatches(file string, patterns []string, patDirs [][]string) (bool,\n \treturn matched, nil\n }\n \n+// regexpMatch tries to match the logic of filepath.Match but\n+// does so using regexp logic. We do this so that we can expand the\n+// wildcard set to include other things, like \"**\" to mean any number\n+// of directories.  This means that we should be backwards compatible\n+// with filepath.Match(). We'll end up supporting more stuff, due to\n+// the fact that we're using regexp, but that's ok - it does no harm.\n+func regexpMatch(pattern, path string) (bool, error) {\n+\tregStr := \"^\"\n+\n+\t// Do some syntax checking on the pattern.\n+\t// filepath's Match() has some really weird rules that are inconsistent\n+\t// so instead of trying to dup their logic, just call Match() for its\n+\t// error state and if there is an error in the pattern return it.\n+\t// If this becomes an issue we can remove this since its really only\n+\t// needed in the error (syntax) case - which isn't really critical.\n+\tif _, err := filepath.Match(pattern, path); err != nil {\n+\t\treturn false, err\n+\t}\n+\n+\t// Go through the pattern and convert it to a regexp.\n+\t// We use a scanner so we can support utf-8 chars.\n+\tvar scan scanner.Scanner\n+\tscan.Init(strings.NewReader(pattern))\n+\n+\tsl := string(os.PathSeparator)\n+\tescSL := sl\n+\tif sl == `\\` {\n+\t\tescSL += `\\`\n+\t}\n+\n+\tfor scan.Peek() != scanner.EOF {\n+\t\tch := scan.Next()\n+\n+\t\tif ch == '*' {\n+\t\t\tif scan.Peek() == '*' {\n+\t\t\t\t// is some flavor of \"**\"\n+\t\t\t\tscan.Next()\n+\n+\t\t\t\tif scan.Peek() == scanner.EOF {\n+\t\t\t\t\t// is \"**EOF\" - to align with .gitignore just accept all\n+\t\t\t\t\tregStr += \".*\"\n+\t\t\t\t} else {\n+\t\t\t\t\t// is \"**\"\n+\t\t\t\t\tregStr += \"((.*\" + escSL + \")|([^\" + escSL + \"]*))\"\n+\t\t\t\t}\n+\n+\t\t\t\t// Treat **/ as ** so eat the \"/\"\n+\t\t\t\tif string(scan.Peek()) == sl {\n+\t\t\t\t\tscan.Next()\n+\t\t\t\t}\n+\t\t\t} else {\n+\t\t\t\t// is \"*\" so map it to anything but \"/\"\n+\t\t\t\tregStr += \"[^\" + escSL + \"]*\"\n+\t\t\t}\n+\t\t} else if ch == '?' {\n+\t\t\t// \"?\" is any char except \"/\"\n+\t\t\tregStr += \"[^\" + escSL + \"]\"\n+\t\t} else if strings.Index(\".$\", string(ch)) != -1 {\n+\t\t\t// Escape some regexp special chars that have no meaning\n+\t\t\t// in golang's filepath.Match\n+\t\t\tregStr += `\\` + string(ch)\n+\t\t} else if ch == '\\\\' {\n+\t\t\t// escape next char. Note that a trailing \\ in the pattern\n+\t\t\t// will be left alone (but need to escape it)\n+\t\t\tif sl == `\\` {\n+\t\t\t\t// On windows map \"\\\" to \"\\\\\", meaning an escaped backslash,\n+\t\t\t\t// and then just continue because filepath.Match on\n+\t\t\t\t// Windows doesn't allow escaping at all\n+\t\t\t\tregStr += escSL\n+\t\t\t\tcontinue\n+\t\t\t}\n+\t\t\tif scan.Peek() != scanner.EOF {\n+\t\t\t\tregStr += `\\` + string(scan.Next())\n+\t\t\t} else {\n+\t\t\t\tregStr += `\\`\n+\t\t\t}\n+\t\t} else {\n+\t\t\tregStr += string(ch)\n+\t\t}\n+\t}\n+\n+\tregStr += \"$\"\n+\n+\tres, err := regexp.MatchString(regStr, path)\n+\n+\t// fmt.Printf(\"(%s->%q,%q) -> (%v,%v)\\n\", pattern, regStr, path, res, err)","path":"pkg/fileutils/fileutils.go","position":118,"original_position":118,"commit_id":"7324b512abe5e66399c6680cb569bfa8a825de3a","original_commit_id":"7324b512abe5e66399c6680cb569bfa8a825de3a","user":{"login":"LK4D4","id":101445,"avatar_url":"https://avatars.githubusercontent.com/u/101445?v=3","gravatar_id":"","url":"https://api.github.com/users/LK4D4","html_url":"https://github.com/LK4D4","followers_url":"https://api.github.com/users/LK4D4/followers","following_url":"https://api.github.com/users/LK4D4/following{/other_user}","gists_url":"https://api.github.com/users/LK4D4/gists{/gist_id}","starred_url":"https://api.github.com/users/LK4D4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LK4D4/subscriptions","organizations_url":"https://api.github.com/users/LK4D4/orgs","repos_url":"https://api.github.com/users/LK4D4/repos","events_url":"https://api.github.com/users/LK4D4/events{/privacy}","received_events_url":"https://api.github.com/users/LK4D4/received_events","type":"User","site_admin":false},"body":"forgotten debug?","created_at":"2015-11-13T21:37:24Z","updated_at":"2015-11-13T21:37:24Z","html_url":"https://github.com/docker/docker/pull/17090#discussion_r44837070","pull_request_url":"https://api.github.com/repos/docker/docker/pulls/17090","_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/comments/44837070"},"html":{"href":"https://github.com/docker/docker/pull/17090#discussion_r44837070"},"pull_request":{"href":"https://api.github.com/repos/docker/docker/pulls/17090"}}},"pull_request":{"url":"https://api.github.com/repos/docker/docker/pulls/17090","id":47847316,"html_url":"https://github.com/docker/docker/pull/17090","diff_url":"https://github.com/docker/docker/pull/17090.diff","patch_url":"https://github.com/docker/docker/pull/17090.patch","issue_url":"https://api.github.com/repos/docker/docker/issues/17090","number":17090,"state":"open","locked":false,"title":"Support multi-dir wildcards in .dockerignore","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":"Closes #13113\r\n\r\nThis adds support for wildcarding multiple levels of dirs in .dockerignore files.\r\n`**` (or `**/`) means zero or more dirs.\r\nSo `**/*.go` will exclude all go files from the build context.\r\n\r\nSigned-off-by: Doug Davis <dug@us.ibm.com>","created_at":"2015-10-15T21:56:22Z","updated_at":"2015-11-13T21:37:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0d3f95e83063b213f75de506885b1c1b85930f89","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/docker/docker/pulls/17090/commits","review_comments_url":"https://api.github.com/repos/docker/docker/pulls/17090/comments","review_comment_url":"https://api.github.com/repos/docker/docker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/docker/docker/issues/17090/comments","statuses_url":"https://api.github.com/repos/docker/docker/statuses/7324b512abe5e66399c6680cb569bfa8a825de3a","head":{"label":"duglin:dockerignoreWildcards","ref":"dockerignoreWildcards","sha":"7324b512abe5e66399c6680cb569bfa8a825de3a","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},"repo":{"id":22769065,"name":"docker","full_name":"duglin/docker","owner":{"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},"private":false,"html_url":"https://github.com/duglin/docker","description":"Docker - the open-source application container engine","fork":true,"url":"https://api.github.com/repos/duglin/docker","forks_url":"https://api.github.com/repos/duglin/docker/forks","keys_url":"https://api.github.com/repos/duglin/docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/duglin/docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/duglin/docker/teams","hooks_url":"https://api.github.com/repos/duglin/docker/hooks","issue_events_url":"https://api.github.com/repos/duglin/docker/issues/events{/number}","events_url":"https://api.github.com/repos/duglin/docker/events","assignees_url":"https://api.github.com/repos/duglin/docker/assignees{/user}","branches_url":"https://api.github.com/repos/duglin/docker/branches{/branch}","tags_url":"https://api.github.com/repos/duglin/docker/tags","blobs_url":"https://api.github.com/repos/duglin/docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/duglin/docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/duglin/docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/duglin/docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/duglin/docker/statuses/{sha}","languages_url":"https://api.github.com/repos/duglin/docker/languages","stargazers_url":"https://api.github.com/repos/duglin/docker/stargazers","contributors_url":"https://api.github.com/repos/duglin/docker/contributors","subscribers_url":"https://api.github.com/repos/duglin/docker/subscribers","subscription_url":"https://api.github.com/repos/duglin/docker/subscription","commits_url":"https://api.github.com/repos/duglin/docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/duglin/docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/duglin/docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/duglin/docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/duglin/docker/contents/{+path}","compare_url":"https://api.github.com/repos/duglin/docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/duglin/docker/merges","archive_url":"https://api.github.com/repos/duglin/docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/duglin/docker/downloads","issues_url":"https://api.github.com/repos/duglin/docker/issues{/number}","pulls_url":"https://api.github.com/repos/duglin/docker/pulls{/number}","milestones_url":"https://api.github.com/repos/duglin/docker/milestones{/number}","notifications_url":"https://api.github.com/repos/duglin/docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/duglin/docker/labels{/name}","releases_url":"https://api.github.com/repos/duglin/docker/releases{/id}","created_at":"2014-08-08T19:24:58Z","updated_at":"2015-05-21T21:18:31Z","pushed_at":"2015-11-13T15:13:42Z","git_url":"git://github.com/duglin/docker.git","ssh_url":"git@github.com:duglin/docker.git","clone_url":"https://github.com/duglin/docker.git","svn_url":"https://github.com/duglin/docker","homepage":"http://www.docker.com","size":76307,"stargazers_count":3,"watchers_count":3,"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":3,"default_branch":"master"}},"base":{"label":"docker:master","ref":"master","sha":"965706245b702c08d23ce7da2e91440ccec74726","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-11-13T21:14:01Z","pushed_at":"2015-11-13T21:24:17Z","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":285834,"stargazers_count":26196,"watchers_count":26196,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7028,"mirror_url":null,"open_issues_count":1210,"forks":7028,"open_issues":1210,"watchers":26196,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/17090"},"html":{"href":"https://github.com/docker/docker/pull/17090"},"issue":{"href":"https://api.github.com/repos/docker/docker/issues/17090"},"comments":{"href":"https://api.github.com/repos/docker/docker/issues/17090/comments"},"review_comments":{"href":"https://api.github.com/repos/docker/docker/pulls/17090/comments"},"review_comment":{"href":"https://api.github.com/repos/docker/docker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/docker/docker/pulls/17090/commits"},"statuses":{"href":"https://api.github.com/repos/docker/docker/statuses/7324b512abe5e66399c6680cb569bfa8a825de3a"}}}}