{"action":"created","comment":{"url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/pulls/comments/127779721","pull_request_review_id":50390892,"id":127779721,"diff_hunk":"@@ -0,0 +1,183 @@\n+package unitylauncher\n+\n+import (\n+\t\"fmt\"\n+\t\"golang.org/x/sys/windows/registry\"\n+\t\"io/ioutil\"\n+\t\"os\"\n+\t\"path\"\n+\t\"path/filepath\"\n+\t\"regexp\"\n+\t\"sort\"\n+\t\"strconv\"\n+\t\"strings\"\n+)\n+\n+var registryKeyPath = `Software\\Unity Technologies\\Unity Editor 5.x`\n+var recentlyUsedProjectKey = \"RecentlyUsedProjectPaths\"\n+\n+var unityLaunchPath = `Editor\\Unity.exe`\n+var defaultUnityEditor = `c:\\Unity\\Unity-5.5.2f1\\Editor\\unity.exe`\n+var fallbackUnityInstance = PathAndVersion{Path: defaultUnityEditor, Version: ExtractUnityVersion(defaultUnityEditor, regexp.MustCompile(VersionRegexString))}\n+\n+type UnityInstallations struct {\n+\tInstallations map[UnityVersion]PathAndVersion\n+\tVersions      []UnityVersion\n+}\n+\n+func (ui *UnityInstallations) AddInstallation(installation PathAndVersion) {\n+\tui.Installations[installation.Version] = installation\n+\tui.Versions = append(ui.Versions, installation.Version)\n+\tsort.Sort(ByVersion(ui.Versions))\n+}\n+\n+type PathAndVersion struct {\n+\tPath    string\n+\tVersion UnityVersion\n+}\n+\n+type ProjectLaunch struct {\n+\tProject PathAndVersion\n+\tEditor  PathAndVersion\n+}\n+\n+func LocateRecentUnityProjects() (projects []*PathAndVersion) {\n+\tk, err := registry.OpenKey(registry.CURRENT_USER, registryKeyPath, registry.QUERY_VALUE)\n+\tdefer k.Close()\n+\n+\tif err != nil {\n+\t\tfmt.Println(err)\n+\t}\n+\n+\tinfo, err := k.Stat()\n+\tif err != nil {\n+\t\tfmt.Println(err)\n+\t}\n+\n+\tkeyNames, err := k.ReadValueNames(int(info.ValueCount))\n+\tfor _, keyName := range keyNames {\n+\t\tif strings.HasPrefix(keyName, recentlyUsedProjectKey) {\n+\t\t\tval, _, err := k.GetBinaryValue(keyName)\n+\t\t\tif err != nil {\n+\t\t\t\tcontinue\n+\t\t\t}\n+\n+\t\t\tprojects = append(projects, &PathAndVersion{Path: strings.Trim(string(val), \"\\x00\")})\n+\t\t}\n+\t}\n+\n+\treturn\n+}\n+\n+func LocateInstalledUnityVersions(unityInstallsPath string) (installations UnityInstallations) {\n+\tinstallations = UnityInstallations{Versions: make([]UnityVersion, 0), Installations: make(map[UnityVersion]PathAndVersion)}\n+\n+\tfileInfos, err := ioutil.ReadDir(unityInstallsPath)\n+\tif err != nil {\n+\t\tfmt.Println(err)\n+\t}\n+\n+\tre := regexp.MustCompile(VersionRegexString)\n+\n+\tfor _, fileInfo := range fileInfos {\n+\t\tif fileInfo.IsDir() {\n+\n+\t\t\tversionName := fileInfo.Name()\n+\t\t\tversion := ExtractUnityVersion(versionName, re)\n+\n+\t\t\tunityExecPath := filepath.Join(unityInstallsPath, versionName, unityLaunchPath)\n+\t\t\tstat, err := os.Stat(unityExecPath)\n+\t\t\tfmt.Println(stat)\n+\n+\t\t\tif !os.IsNotExist(err) {\n+\t\t\t\tinstallations.AddInstallation(PathAndVersion{Version: version, Path: unityExecPath})\n+\t\t\t}\n+\t\t}\n+\t}\n+\n+\treturn\n+}\n+\n+var VersionRegexString = `((?P<Series>\\d+)\\.(?P<Major>\\d+)\\.(?P<Minor>\\d+)\\w(?P<Patch>\\d+))`\n+var versionRegex = regexp.MustCompile(`m_EditorVersion: ` + VersionRegexString)\n+var versionRegexGroupNames = versionRegex.SubexpNames()\n+\n+func ExtractUnityVersion(input string, re *regexp.Regexp) (version UnityVersion) {\n+\tmatch := re.FindStringSubmatch(input)\n+\tresult := make(map[string]string)\n+\n+\tif len(match) < 4 {\n+\t\tfmt.Printf(\"Could not parse v string %s\", input)\n+\t\tversion = UnityVersion{}\n+\t\treturn\n+\t}\n+\n+\tfor i, name := range versionRegexGroupNames {\n+\t\tif i > 0 {\n+\t\t\tresult[name] = match[i]\n+\t\t}\n+\t}\n+\n+\tseries, _ := strconv.ParseUint(result[\"Series\"], 0, 64)","path":"util/unitylauncher_util.go","position":126,"original_position":121,"commit_id":"39801371fa8015c532d84a7e780836907e3640d0","original_commit_id":"52d16d39f6e46434986b281fb33755bcb78a43ab","user":{"login":"improbable-tomasz","id":22596487,"avatar_url":"https://avatars0.githubusercontent.com/u/22596487?v=4","gravatar_id":"","url":"https://api.github.com/users/improbable-tomasz","html_url":"https://github.com/improbable-tomasz","followers_url":"https://api.github.com/users/improbable-tomasz/followers","following_url":"https://api.github.com/users/improbable-tomasz/following{/other_user}","gists_url":"https://api.github.com/users/improbable-tomasz/gists{/gist_id}","starred_url":"https://api.github.com/users/improbable-tomasz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/improbable-tomasz/subscriptions","organizations_url":"https://api.github.com/users/improbable-tomasz/orgs","repos_url":"https://api.github.com/users/improbable-tomasz/repos","events_url":"https://api.github.com/users/improbable-tomasz/events{/privacy}","received_events_url":"https://api.github.com/users/improbable-tomasz/received_events","type":"User","site_admin":false},"body":"OK","created_at":"2017-07-17T18:03:33Z","updated_at":"2017-07-17T18:39:39Z","html_url":"https://github.com/improbable-tomasz/unity-launcher/pull/1#discussion_r127779721","pull_request_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/improbable-tomasz/unity-launcher/pulls/comments/127779721"},"html":{"href":"https://github.com/improbable-tomasz/unity-launcher/pull/1#discussion_r127779721"},"pull_request":{"href":"https://api.github.com/repos/improbable-tomasz/unity-launcher/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/pulls/1","id":130855519,"html_url":"https://github.com/improbable-tomasz/unity-launcher/pull/1","diff_url":"https://github.com/improbable-tomasz/unity-launcher/pull/1.diff","patch_url":"https://github.com/improbable-tomasz/unity-launcher/pull/1.patch","issue_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/issues/1","number":1,"state":"open","locked":false,"title":"V1","user":{"login":"improbable-tomasz","id":22596487,"avatar_url":"https://avatars0.githubusercontent.com/u/22596487?v=4","gravatar_id":"","url":"https://api.github.com/users/improbable-tomasz","html_url":"https://github.com/improbable-tomasz","followers_url":"https://api.github.com/users/improbable-tomasz/followers","following_url":"https://api.github.com/users/improbable-tomasz/following{/other_user}","gists_url":"https://api.github.com/users/improbable-tomasz/gists{/gist_id}","starred_url":"https://api.github.com/users/improbable-tomasz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/improbable-tomasz/subscriptions","organizations_url":"https://api.github.com/users/improbable-tomasz/orgs","repos_url":"https://api.github.com/users/improbable-tomasz/repos","events_url":"https://api.github.com/users/improbable-tomasz/events{/privacy}","received_events_url":"https://api.github.com/users/improbable-tomasz/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-07-17T13:27:02Z","updated_at":"2017-07-17T18:39:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ffe8f14ece14750d69d8aa8ecfa8e5c2fd5bc278","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/pulls/1/commits","review_comments_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/pulls/1/comments","review_comment_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/pulls/comments{/number}","comments_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/issues/1/comments","statuses_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/statuses/39801371fa8015c532d84a7e780836907e3640d0","head":{"label":"improbable-tomasz:v1","ref":"v1","sha":"39801371fa8015c532d84a7e780836907e3640d0","user":{"login":"improbable-tomasz","id":22596487,"avatar_url":"https://avatars0.githubusercontent.com/u/22596487?v=4","gravatar_id":"","url":"https://api.github.com/users/improbable-tomasz","html_url":"https://github.com/improbable-tomasz","followers_url":"https://api.github.com/users/improbable-tomasz/followers","following_url":"https://api.github.com/users/improbable-tomasz/following{/other_user}","gists_url":"https://api.github.com/users/improbable-tomasz/gists{/gist_id}","starred_url":"https://api.github.com/users/improbable-tomasz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/improbable-tomasz/subscriptions","organizations_url":"https://api.github.com/users/improbable-tomasz/orgs","repos_url":"https://api.github.com/users/improbable-tomasz/repos","events_url":"https://api.github.com/users/improbable-tomasz/events{/privacy}","received_events_url":"https://api.github.com/users/improbable-tomasz/received_events","type":"User","site_admin":false},"repo":{"id":97477773,"name":"unity-launcher","full_name":"improbable-tomasz/unity-launcher","owner":{"login":"improbable-tomasz","id":22596487,"avatar_url":"https://avatars0.githubusercontent.com/u/22596487?v=4","gravatar_id":"","url":"https://api.github.com/users/improbable-tomasz","html_url":"https://github.com/improbable-tomasz","followers_url":"https://api.github.com/users/improbable-tomasz/followers","following_url":"https://api.github.com/users/improbable-tomasz/following{/other_user}","gists_url":"https://api.github.com/users/improbable-tomasz/gists{/gist_id}","starred_url":"https://api.github.com/users/improbable-tomasz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/improbable-tomasz/subscriptions","organizations_url":"https://api.github.com/users/improbable-tomasz/orgs","repos_url":"https://api.github.com/users/improbable-tomasz/repos","events_url":"https://api.github.com/users/improbable-tomasz/events{/privacy}","received_events_url":"https://api.github.com/users/improbable-tomasz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/improbable-tomasz/unity-launcher","description":null,"fork":false,"url":"https://api.github.com/repos/improbable-tomasz/unity-launcher","forks_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/forks","keys_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/keys{/key_id}","collaborators_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/teams","hooks_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/hooks","issue_events_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/issues/events{/number}","events_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/events","assignees_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/assignees{/user}","branches_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/branches{/branch}","tags_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/tags","blobs_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/git/refs{/sha}","trees_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/git/trees{/sha}","statuses_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/statuses/{sha}","languages_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/languages","stargazers_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/stargazers","contributors_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/contributors","subscribers_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/subscribers","subscription_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/subscription","commits_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/commits{/sha}","git_commits_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/git/commits{/sha}","comments_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/comments{/number}","issue_comment_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/issues/comments{/number}","contents_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/contents/{+path}","compare_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/compare/{base}...{head}","merges_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/merges","archive_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/downloads","issues_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/issues{/number}","pulls_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/pulls{/number}","milestones_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/milestones{/number}","notifications_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/labels{/name}","releases_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/releases{/id}","deployments_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/deployments","created_at":"2017-07-17T13:12:37Z","updated_at":"2017-07-17T13:12:37Z","pushed_at":"2017-07-17T15:52:02Z","git_url":"git://github.com/improbable-tomasz/unity-launcher.git","ssh_url":"git@github.com:improbable-tomasz/unity-launcher.git","clone_url":"https://github.com/improbable-tomasz/unity-launcher.git","svn_url":"https://github.com/improbable-tomasz/unity-launcher","homepage":null,"size":10,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"improbable-tomasz:master","ref":"master","sha":"4c0758e9d78eb458623ebb33be274a449c7a21dd","user":{"login":"improbable-tomasz","id":22596487,"avatar_url":"https://avatars0.githubusercontent.com/u/22596487?v=4","gravatar_id":"","url":"https://api.github.com/users/improbable-tomasz","html_url":"https://github.com/improbable-tomasz","followers_url":"https://api.github.com/users/improbable-tomasz/followers","following_url":"https://api.github.com/users/improbable-tomasz/following{/other_user}","gists_url":"https://api.github.com/users/improbable-tomasz/gists{/gist_id}","starred_url":"https://api.github.com/users/improbable-tomasz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/improbable-tomasz/subscriptions","organizations_url":"https://api.github.com/users/improbable-tomasz/orgs","repos_url":"https://api.github.com/users/improbable-tomasz/repos","events_url":"https://api.github.com/users/improbable-tomasz/events{/privacy}","received_events_url":"https://api.github.com/users/improbable-tomasz/received_events","type":"User","site_admin":false},"repo":{"id":97477773,"name":"unity-launcher","full_name":"improbable-tomasz/unity-launcher","owner":{"login":"improbable-tomasz","id":22596487,"avatar_url":"https://avatars0.githubusercontent.com/u/22596487?v=4","gravatar_id":"","url":"https://api.github.com/users/improbable-tomasz","html_url":"https://github.com/improbable-tomasz","followers_url":"https://api.github.com/users/improbable-tomasz/followers","following_url":"https://api.github.com/users/improbable-tomasz/following{/other_user}","gists_url":"https://api.github.com/users/improbable-tomasz/gists{/gist_id}","starred_url":"https://api.github.com/users/improbable-tomasz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/improbable-tomasz/subscriptions","organizations_url":"https://api.github.com/users/improbable-tomasz/orgs","repos_url":"https://api.github.com/users/improbable-tomasz/repos","events_url":"https://api.github.com/users/improbable-tomasz/events{/privacy}","received_events_url":"https://api.github.com/users/improbable-tomasz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/improbable-tomasz/unity-launcher","description":null,"fork":false,"url":"https://api.github.com/repos/improbable-tomasz/unity-launcher","forks_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/forks","keys_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/keys{/key_id}","collaborators_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/teams","hooks_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/hooks","issue_events_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/issues/events{/number}","events_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/events","assignees_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/assignees{/user}","branches_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/branches{/branch}","tags_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/tags","blobs_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/git/refs{/sha}","trees_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/git/trees{/sha}","statuses_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/statuses/{sha}","languages_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/languages","stargazers_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/stargazers","contributors_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/contributors","subscribers_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/subscribers","subscription_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/subscription","commits_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/commits{/sha}","git_commits_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/git/commits{/sha}","comments_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/comments{/number}","issue_comment_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/issues/comments{/number}","contents_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/contents/{+path}","compare_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/compare/{base}...{head}","merges_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/merges","archive_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/downloads","issues_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/issues{/number}","pulls_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/pulls{/number}","milestones_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/milestones{/number}","notifications_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/labels{/name}","releases_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/releases{/id}","deployments_url":"https://api.github.com/repos/improbable-tomasz/unity-launcher/deployments","created_at":"2017-07-17T13:12:37Z","updated_at":"2017-07-17T13:12:37Z","pushed_at":"2017-07-17T15:52:02Z","git_url":"git://github.com/improbable-tomasz/unity-launcher.git","ssh_url":"git@github.com:improbable-tomasz/unity-launcher.git","clone_url":"https://github.com/improbable-tomasz/unity-launcher.git","svn_url":"https://github.com/improbable-tomasz/unity-launcher","homepage":null,"size":10,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/improbable-tomasz/unity-launcher/pulls/1"},"html":{"href":"https://github.com/improbable-tomasz/unity-launcher/pull/1"},"issue":{"href":"https://api.github.com/repos/improbable-tomasz/unity-launcher/issues/1"},"comments":{"href":"https://api.github.com/repos/improbable-tomasz/unity-launcher/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/improbable-tomasz/unity-launcher/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/improbable-tomasz/unity-launcher/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/improbable-tomasz/unity-launcher/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/improbable-tomasz/unity-launcher/statuses/39801371fa8015c532d84a7e780836907e3640d0"}}}}
{"actor":{"display_login":"improbable-tomasz"}}