{"action":"created","comment":{"url":"https://api.github.com/repos/koding/koding/pulls/comments/76511919","id":76511919,"diff_hunk":"@@ -0,0 +1,61 @@\n+package open\n+\n+import (\n+\t\"os\"\n+\t\"path/filepath\"\n+)\n+\n+// Prepare a slice of paths to be absolute and/or in a format\n+// that is friendly to the Koding IDE.\n+//\n+// Returns the same list as in, for an easy API.\n+func PreparePaths(paths []string) ([]string, error) {\n+\tfor i, path := range paths {\n+\t\tpath, err := filepath.Abs(path)\n+\t\tif err != nil {\n+\t\t\treturn nil, err\n+\t\t}\n+\t\tpaths[i] = path\n+\t}\n+\treturn paths, nil\n+}\n+\n+// Like MkdirAll, Mkfiles creates any files as needed.\n+func Mkfiles(paths []string, perm os.FileMode) (err error) {\n+\tfor _, path := range paths {\n+\t\tif _, err := os.Stat(path); err != nil {\n+\t\t\tif os.IsNotExist(err) {\n+\t\t\t\tos.MkdirAll(filepath.Dir(path), perm)\n+\t\t\t\t// The file doesn't exist, create it.\n+\t\t\t\tf, err := os.Create(path)\n+\t\t\t\tif err != nil {\n+\t\t\t\t\treturn err\n+\t\t\t\t}\n+\t\t\t\tf.Chmod(perm)\n+\t\t\t\tf.Close()\n+\t\t\t} else {\n+\t\t\t\t// If we don't know what to do with the error, it might be\n+\t\t\t\t// permissions/etc. Return it.\n+\t\t\t\treturn err\n+\t\t\t}","path":"go/src/koding/klientctl/open/util.go","position":40,"original_position":40,"commit_id":"13b35bdf2a145b60b26174a7ce750d1b5b60dd04","original_commit_id":"13b35bdf2a145b60b26174a7ce750d1b5b60dd04","user":{"login":"rjeczalik","id":1162017,"avatar_url":"https://avatars.githubusercontent.com/u/1162017?v=3","gravatar_id":"","url":"https://api.github.com/users/rjeczalik","html_url":"https://github.com/rjeczalik","followers_url":"https://api.github.com/users/rjeczalik/followers","following_url":"https://api.github.com/users/rjeczalik/following{/other_user}","gists_url":"https://api.github.com/users/rjeczalik/gists{/gist_id}","starred_url":"https://api.github.com/users/rjeczalik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rjeczalik/subscriptions","organizations_url":"https://api.github.com/users/rjeczalik/orgs","repos_url":"https://api.github.com/users/rjeczalik/repos","events_url":"https://api.github.com/users/rjeczalik/events{/privacy}","received_events_url":"https://api.github.com/users/rjeczalik/received_events","type":"User","site_admin":false},"body":"I assume the `paths` are never sorted. If a slice of paths contains one elements that could not be created, the Mkfiles method is not deterministic - it will fail on that element successfully creating different number of files, depending on position of the broken path within the slice.\r\n\r\nWhat if we try to create all the paths instead and don't early return? Also what happens, when path is a directory at line 26, do we care?\r\n\r\nCode-style nitpick - make the code to have less branches, improves readability:\r\n\r\n```go\r\n\t\t_, err := os.Stat(path)\r\n\t\tif os.IsNotExist(err) {\r\n \t\t\tos.MkdirAll(filepath.Dir(path), perm)\r\n \t\t\t// The file doesn't exist, create it.\r\n \t\t\tf, err := os.Create(path)\r\n \t\t\tif err != nil {\r\n \t\t\t\treturn err\r\n \t\t\t}\r\n \t\t\tf.Chmod(perm)\r\n \t\t\tf.Close()\r\n \t\t} else if err != nil {\r\n \t\t\t// If we don't know what to do with the error, it might be\r\n \t\t\t// permissions/etc. Return it.\r\n \t\t\treturn err\r\n \t\t}\r\n```","created_at":"2016-08-27T07:11:34Z","updated_at":"2016-08-27T07:11:34Z","html_url":"https://github.com/koding/koding/pull/8758#discussion_r76511919","pull_request_url":"https://api.github.com/repos/koding/koding/pulls/8758","_links":{"self":{"href":"https://api.github.com/repos/koding/koding/pulls/comments/76511919"},"html":{"href":"https://github.com/koding/koding/pull/8758#discussion_r76511919"},"pull_request":{"href":"https://api.github.com/repos/koding/koding/pulls/8758"}}},"pull_request":{"url":"https://api.github.com/repos/koding/koding/pulls/8758","id":80485492,"html_url":"https://github.com/koding/koding/pull/8758","diff_url":"https://github.com/koding/koding/pull/8758.diff","patch_url":"https://github.com/koding/koding/pull/8758.patch","issue_url":"https://api.github.com/repos/koding/koding/issues/8758","number":8758,"state":"open","locked":false,"title":"klientctl: Added kdopen","user":{"login":"leeola","id":47556,"avatar_url":"https://avatars.githubusercontent.com/u/47556?v=3","gravatar_id":"","url":"https://api.github.com/users/leeola","html_url":"https://github.com/leeola","followers_url":"https://api.github.com/users/leeola/followers","following_url":"https://api.github.com/users/leeola/following{/other_user}","gists_url":"https://api.github.com/users/leeola/gists{/gist_id}","starred_url":"https://api.github.com/users/leeola/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leeola/subscriptions","organizations_url":"https://api.github.com/users/leeola/orgs","repos_url":"https://api.github.com/users/leeola/repos","events_url":"https://api.github.com/users/leeola/events{/privacy}","received_events_url":"https://api.github.com/users/leeola/received_events","type":"User","site_admin":false},"body":"Implements item 1 on #8757","created_at":"2016-08-08T16:57:54Z","updated_at":"2016-08-27T07:11:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2d71da30c046a2b94ce9b81937ffc5308c3ea45e","assignee":{"login":"rjeczalik","id":1162017,"avatar_url":"https://avatars.githubusercontent.com/u/1162017?v=3","gravatar_id":"","url":"https://api.github.com/users/rjeczalik","html_url":"https://github.com/rjeczalik","followers_url":"https://api.github.com/users/rjeczalik/followers","following_url":"https://api.github.com/users/rjeczalik/following{/other_user}","gists_url":"https://api.github.com/users/rjeczalik/gists{/gist_id}","starred_url":"https://api.github.com/users/rjeczalik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rjeczalik/subscriptions","organizations_url":"https://api.github.com/users/rjeczalik/orgs","repos_url":"https://api.github.com/users/rjeczalik/repos","events_url":"https://api.github.com/users/rjeczalik/events{/privacy}","received_events_url":"https://api.github.com/users/rjeczalik/received_events","type":"User","site_admin":false},"assignees":[{"login":"rjeczalik","id":1162017,"avatar_url":"https://avatars.githubusercontent.com/u/1162017?v=3","gravatar_id":"","url":"https://api.github.com/users/rjeczalik","html_url":"https://github.com/rjeczalik","followers_url":"https://api.github.com/users/rjeczalik/followers","following_url":"https://api.github.com/users/rjeczalik/following{/other_user}","gists_url":"https://api.github.com/users/rjeczalik/gists{/gist_id}","starred_url":"https://api.github.com/users/rjeczalik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rjeczalik/subscriptions","organizations_url":"https://api.github.com/users/rjeczalik/orgs","repos_url":"https://api.github.com/users/rjeczalik/repos","events_url":"https://api.github.com/users/rjeczalik/events{/privacy}","received_events_url":"https://api.github.com/users/rjeczalik/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/koding/koding/pulls/8758/commits","review_comments_url":"https://api.github.com/repos/koding/koding/pulls/8758/comments","review_comment_url":"https://api.github.com/repos/koding/koding/pulls/comments{/number}","comments_url":"https://api.github.com/repos/koding/koding/issues/8758/comments","statuses_url":"https://api.github.com/repos/koding/koding/statuses/13b35bdf2a145b60b26174a7ce750d1b5b60dd04","head":{"label":"koding:klientctl-kdopen","ref":"klientctl-kdopen","sha":"13b35bdf2a145b60b26174a7ce750d1b5b60dd04","user":{"login":"koding","id":1066754,"avatar_url":"https://avatars.githubusercontent.com/u/1066754?v=3","gravatar_id":"","url":"https://api.github.com/users/koding","html_url":"https://github.com/koding","followers_url":"https://api.github.com/users/koding/followers","following_url":"https://api.github.com/users/koding/following{/other_user}","gists_url":"https://api.github.com/users/koding/gists{/gist_id}","starred_url":"https://api.github.com/users/koding/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/koding/subscriptions","organizations_url":"https://api.github.com/users/koding/orgs","repos_url":"https://api.github.com/users/koding/repos","events_url":"https://api.github.com/users/koding/events{/privacy}","received_events_url":"https://api.github.com/users/koding/received_events","type":"Organization","site_admin":false},"repo":{"id":21317360,"name":"koding","full_name":"koding/koding","owner":{"login":"koding","id":1066754,"avatar_url":"https://avatars.githubusercontent.com/u/1066754?v=3","gravatar_id":"","url":"https://api.github.com/users/koding","html_url":"https://github.com/koding","followers_url":"https://api.github.com/users/koding/followers","following_url":"https://api.github.com/users/koding/following{/other_user}","gists_url":"https://api.github.com/users/koding/gists{/gist_id}","starred_url":"https://api.github.com/users/koding/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/koding/subscriptions","organizations_url":"https://api.github.com/users/koding/orgs","repos_url":"https://api.github.com/users/koding/repos","events_url":"https://api.github.com/users/koding/events{/privacy}","received_events_url":"https://api.github.com/users/koding/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/koding/koding","description":"KODING IS NOW OPEN SOURCE!","fork":false,"url":"https://api.github.com/repos/koding/koding","forks_url":"https://api.github.com/repos/koding/koding/forks","keys_url":"https://api.github.com/repos/koding/koding/keys{/key_id}","collaborators_url":"https://api.github.com/repos/koding/koding/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/koding/koding/teams","hooks_url":"https://api.github.com/repos/koding/koding/hooks","issue_events_url":"https://api.github.com/repos/koding/koding/issues/events{/number}","events_url":"https://api.github.com/repos/koding/koding/events","assignees_url":"https://api.github.com/repos/koding/koding/assignees{/user}","branches_url":"https://api.github.com/repos/koding/koding/branches{/branch}","tags_url":"https://api.github.com/repos/koding/koding/tags","blobs_url":"https://api.github.com/repos/koding/koding/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/koding/koding/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/koding/koding/git/refs{/sha}","trees_url":"https://api.github.com/repos/koding/koding/git/trees{/sha}","statuses_url":"https://api.github.com/repos/koding/koding/statuses/{sha}","languages_url":"https://api.github.com/repos/koding/koding/languages","stargazers_url":"https://api.github.com/repos/koding/koding/stargazers","contributors_url":"https://api.github.com/repos/koding/koding/contributors","subscribers_url":"https://api.github.com/repos/koding/koding/subscribers","subscription_url":"https://api.github.com/repos/koding/koding/subscription","commits_url":"https://api.github.com/repos/koding/koding/commits{/sha}","git_commits_url":"https://api.github.com/repos/koding/koding/git/commits{/sha}","comments_url":"https://api.github.com/repos/koding/koding/comments{/number}","issue_comment_url":"https://api.github.com/repos/koding/koding/issues/comments{/number}","contents_url":"https://api.github.com/repos/koding/koding/contents/{+path}","compare_url":"https://api.github.com/repos/koding/koding/compare/{base}...{head}","merges_url":"https://api.github.com/repos/koding/koding/merges","archive_url":"https://api.github.com/repos/koding/koding/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/koding/koding/downloads","issues_url":"https://api.github.com/repos/koding/koding/issues{/number}","pulls_url":"https://api.github.com/repos/koding/koding/pulls{/number}","milestones_url":"https://api.github.com/repos/koding/koding/milestones{/number}","notifications_url":"https://api.github.com/repos/koding/koding/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/koding/koding/labels{/name}","releases_url":"https://api.github.com/repos/koding/koding/releases{/id}","deployments_url":"https://api.github.com/repos/koding/koding/deployments","created_at":"2014-06-29T05:46:24Z","updated_at":"2016-08-27T05:03:32Z","pushed_at":"2016-08-27T01:05:30Z","git_url":"git://github.com/koding/koding.git","ssh_url":"git@github.com:koding/koding.git","clone_url":"https://github.com/koding/koding.git","svn_url":"https://github.com/koding/koding","homepage":"http://venturebeat.com/2016/07/26/koding-gitlab/","size":610358,"stargazers_count":378,"watchers_count":378,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":33,"mirror_url":null,"open_issues_count":145,"forks":33,"open_issues":145,"watchers":378,"default_branch":"master"}},"base":{"label":"koding:master","ref":"master","sha":"d87f9c51a1df213f4b315057823993682a191233","user":{"login":"koding","id":1066754,"avatar_url":"https://avatars.githubusercontent.com/u/1066754?v=3","gravatar_id":"","url":"https://api.github.com/users/koding","html_url":"https://github.com/koding","followers_url":"https://api.github.com/users/koding/followers","following_url":"https://api.github.com/users/koding/following{/other_user}","gists_url":"https://api.github.com/users/koding/gists{/gist_id}","starred_url":"https://api.github.com/users/koding/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/koding/subscriptions","organizations_url":"https://api.github.com/users/koding/orgs","repos_url":"https://api.github.com/users/koding/repos","events_url":"https://api.github.com/users/koding/events{/privacy}","received_events_url":"https://api.github.com/users/koding/received_events","type":"Organization","site_admin":false},"repo":{"id":21317360,"name":"koding","full_name":"koding/koding","owner":{"login":"koding","id":1066754,"avatar_url":"https://avatars.githubusercontent.com/u/1066754?v=3","gravatar_id":"","url":"https://api.github.com/users/koding","html_url":"https://github.com/koding","followers_url":"https://api.github.com/users/koding/followers","following_url":"https://api.github.com/users/koding/following{/other_user}","gists_url":"https://api.github.com/users/koding/gists{/gist_id}","starred_url":"https://api.github.com/users/koding/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/koding/subscriptions","organizations_url":"https://api.github.com/users/koding/orgs","repos_url":"https://api.github.com/users/koding/repos","events_url":"https://api.github.com/users/koding/events{/privacy}","received_events_url":"https://api.github.com/users/koding/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/koding/koding","description":"KODING IS NOW OPEN SOURCE!","fork":false,"url":"https://api.github.com/repos/koding/koding","forks_url":"https://api.github.com/repos/koding/koding/forks","keys_url":"https://api.github.com/repos/koding/koding/keys{/key_id}","collaborators_url":"https://api.github.com/repos/koding/koding/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/koding/koding/teams","hooks_url":"https://api.github.com/repos/koding/koding/hooks","issue_events_url":"https://api.github.com/repos/koding/koding/issues/events{/number}","events_url":"https://api.github.com/repos/koding/koding/events","assignees_url":"https://api.github.com/repos/koding/koding/assignees{/user}","branches_url":"https://api.github.com/repos/koding/koding/branches{/branch}","tags_url":"https://api.github.com/repos/koding/koding/tags","blobs_url":"https://api.github.com/repos/koding/koding/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/koding/koding/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/koding/koding/git/refs{/sha}","trees_url":"https://api.github.com/repos/koding/koding/git/trees{/sha}","statuses_url":"https://api.github.com/repos/koding/koding/statuses/{sha}","languages_url":"https://api.github.com/repos/koding/koding/languages","stargazers_url":"https://api.github.com/repos/koding/koding/stargazers","contributors_url":"https://api.github.com/repos/koding/koding/contributors","subscribers_url":"https://api.github.com/repos/koding/koding/subscribers","subscription_url":"https://api.github.com/repos/koding/koding/subscription","commits_url":"https://api.github.com/repos/koding/koding/commits{/sha}","git_commits_url":"https://api.github.com/repos/koding/koding/git/commits{/sha}","comments_url":"https://api.github.com/repos/koding/koding/comments{/number}","issue_comment_url":"https://api.github.com/repos/koding/koding/issues/comments{/number}","contents_url":"https://api.github.com/repos/koding/koding/contents/{+path}","compare_url":"https://api.github.com/repos/koding/koding/compare/{base}...{head}","merges_url":"https://api.github.com/repos/koding/koding/merges","archive_url":"https://api.github.com/repos/koding/koding/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/koding/koding/downloads","issues_url":"https://api.github.com/repos/koding/koding/issues{/number}","pulls_url":"https://api.github.com/repos/koding/koding/pulls{/number}","milestones_url":"https://api.github.com/repos/koding/koding/milestones{/number}","notifications_url":"https://api.github.com/repos/koding/koding/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/koding/koding/labels{/name}","releases_url":"https://api.github.com/repos/koding/koding/releases{/id}","deployments_url":"https://api.github.com/repos/koding/koding/deployments","created_at":"2014-06-29T05:46:24Z","updated_at":"2016-08-27T05:03:32Z","pushed_at":"2016-08-27T01:05:30Z","git_url":"git://github.com/koding/koding.git","ssh_url":"git@github.com:koding/koding.git","clone_url":"https://github.com/koding/koding.git","svn_url":"https://github.com/koding/koding","homepage":"http://venturebeat.com/2016/07/26/koding-gitlab/","size":610358,"stargazers_count":378,"watchers_count":378,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":33,"mirror_url":null,"open_issues_count":145,"forks":33,"open_issues":145,"watchers":378,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/koding/koding/pulls/8758"},"html":{"href":"https://github.com/koding/koding/pull/8758"},"issue":{"href":"https://api.github.com/repos/koding/koding/issues/8758"},"comments":{"href":"https://api.github.com/repos/koding/koding/issues/8758/comments"},"review_comments":{"href":"https://api.github.com/repos/koding/koding/pulls/8758/comments"},"review_comment":{"href":"https://api.github.com/repos/koding/koding/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/koding/koding/pulls/8758/commits"},"statuses":{"href":"https://api.github.com/repos/koding/koding/statuses/13b35bdf2a145b60b26174a7ce750d1b5b60dd04"}}}}
{"actor":{"display_login":"rjeczalik"}}