{"action":"created","comment":{"url":"https://api.github.com/repos/Homebrew/homebrew/pulls/comments/37061793","id":37061793,"diff_hunk":"@@ -101,6 +102,19 @@ def initialize(path)\n     @name = path.parent.basename.to_s\n     @linked_keg_record = HOMEBREW_LIBRARY.join(\"LinkedKegs\", name)\n     @opt_record = HOMEBREW_PREFIX.join(\"opt\", name)\n+    begin\n+      tab = Tab.from_file(path/\"INSTALL_RECEIPT.json\")\n+      tap = tab.tap\n+\n+      oldname = if tap.nil? || tap == \"Homebrew/homebrew\"\n+        Formulary.factory(name)\n+      else\n+        Formulary.factory(\"#{tap.sub(\"homebrew-\", \"\")}/#{name}\")\n+      end.oldname\n+\n+      @oldname_opt_record = HOMEBREW_PREFIX.join(\"opt\", oldname) if oldname\n+    rescue Exception\n+    end","path":"Library/Homebrew/keg.rb","position":33,"original_position":33,"commit_id":"073ff63e06fd35cb59fd21f8988f1ba34a8305ef","original_commit_id":"073ff63e06fd35cb59fd21f8988f1ba34a8305ef","user":{"login":"vladshablinsky","id":4408920,"avatar_url":"https://avatars.githubusercontent.com/u/4408920?v=3","gravatar_id":"","url":"https://api.github.com/users/vladshablinsky","html_url":"https://github.com/vladshablinsky","followers_url":"https://api.github.com/users/vladshablinsky/followers","following_url":"https://api.github.com/users/vladshablinsky/following{/other_user}","gists_url":"https://api.github.com/users/vladshablinsky/gists{/gist_id}","starred_url":"https://api.github.com/users/vladshablinsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vladshablinsky/subscriptions","organizations_url":"https://api.github.com/users/vladshablinsky/orgs","repos_url":"https://api.github.com/users/vladshablinsky/repos","events_url":"https://api.github.com/users/vladshablinsky/events{/privacy}","received_events_url":"https://api.github.com/users/vladshablinsky/received_events","type":"User","site_admin":false},"body":"@xu-cheng I don't completely understand your idea:\r\n\r\n* To get `oldname_opt_record` we need to:\r\n```ruby\r\n(opt_dir = HOMEBREW_PREFIX/\"opt\").directory?\r\n  opt_dir.subdirs.detect do |dir|\r\n    dir.symlink? && dir.resolved_path.parent == path.parent\r\n  end\r\nend\r\n```\r\n There can be several `dir`s, so we have to exclude `opt_record` from `opt_dir.subdirs` before detecting.\r\n* Before we can do the step above, the formula have to be migrated, so `oldname_opt_record` isn't `nil`.\r\nIs this what you mean?","created_at":"2015-08-14T09:29:12Z","updated_at":"2015-08-14T09:29:12Z","html_url":"https://github.com/Homebrew/homebrew/pull/42857#discussion_r37061793","pull_request_url":"https://api.github.com/repos/Homebrew/homebrew/pulls/42857","_links":{"self":{"href":"https://api.github.com/repos/Homebrew/homebrew/pulls/comments/37061793"},"html":{"href":"https://github.com/Homebrew/homebrew/pull/42857#discussion_r37061793"},"pull_request":{"href":"https://api.github.com/repos/Homebrew/homebrew/pulls/42857"}}},"pull_request":{"url":"https://api.github.com/repos/Homebrew/homebrew/pulls/42857","id":42242768,"html_url":"https://github.com/Homebrew/homebrew/pull/42857","diff_url":"https://github.com/Homebrew/homebrew/pull/42857.diff","patch_url":"https://github.com/Homebrew/homebrew/pull/42857.patch","issue_url":"https://api.github.com/repos/Homebrew/homebrew/issues/42857","number":42857,"state":"open","locked":false,"title":"fix migrator bug","user":{"login":"vladshablinsky","id":4408920,"avatar_url":"https://avatars.githubusercontent.com/u/4408920?v=3","gravatar_id":"","url":"https://api.github.com/users/vladshablinsky","html_url":"https://github.com/vladshablinsky","followers_url":"https://api.github.com/users/vladshablinsky/followers","following_url":"https://api.github.com/users/vladshablinsky/following{/other_user}","gists_url":"https://api.github.com/users/vladshablinsky/gists{/gist_id}","starred_url":"https://api.github.com/users/vladshablinsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vladshablinsky/subscriptions","organizations_url":"https://api.github.com/users/vladshablinsky/orgs","repos_url":"https://api.github.com/users/vladshablinsky/repos","events_url":"https://api.github.com/users/vladshablinsky/events{/privacy}","received_events_url":"https://api.github.com/users/vladshablinsky/received_events","type":"User","site_admin":false},"body":"```\r\nbrew install go-app-engine-32\r\nbrew unlink go-app-engine-32\r\nbrew install go-app-engine-64\r\n```\r\n\r\nthen rename `go-app-engine-32` to `app-engine-go-32`\r\nand `migrate` or `update` and we have:\r\n\r\n```\r\n==> Migrating go-app-engine-32 to app-engine-go-32\r\n==> Unlinking go-app-engine-32\r\nMoving to: /usr/local/Cellar/app-engine-go-32\r\n==> Linking app-engine-go-32\r\nError: Error while executing `brew link` step on app-engine-go-32\r\nCould not symlink bin/appcfg.py\r\nTarget /usr/local/bin/appcfg.py\r\nis a symlink belonging to go-app-engine-64. You can unlink it:\r\n  brew unlink go-app-engine-64\r\n\r\nTo force the link and overwrite all conflicting files:\r\n  brew link --overwrite app-engine-go-32\r\n\r\nTo list all files that would be deleted:\r\n  brew link --overwrite --dry-run app-engine-go-32\r\n\r\nPossible conflicting files are:\r\n/usr/local/bin/appcfg.py -> /usr/local/Cellar/go-app-engine-64/1.9.24/bin/appcfg.py\r\n/usr/local/bin/bulkload_client.py -> /usr/local/Cellar/go-app-engine-64/1.9.24/bin/bulkload_client.py\r\n/usr/local/bin/bulkloader.py -> /usr/local/Cellar/go-app-engine-64/1.9.24/bin/bulkloader.py\r\n/usr/local/bin/dev_appserver.py -> /usr/local/Cellar/go-app-engine-64/1.9.24/bin/dev_appserver.py\r\n/usr/local/bin/download_appstats.py -> /usr/local/Cellar/go-app-engine-64/1.9.24/bin/download_appstats.py\r\n/usr/local/bin/goapp -> /usr/local/Cellar/go-app-engine-64/1.9.24/bin/goapp\r\nError: error occured while migrating.\r\nBackuping...\r\nError: No such file or directory - /usr/local/Cellar/go-app-engine-32\r\n```\r\n\r\nThis happens because we try to link app-engine-go-32\r\n even if go-app-engine-32 wasn’t linked.\r\n\r\nBackup fails because it uses realpath on the file that doesn't exist.\r\n\r\n* Fix backup\r\n* Don't link unlinked kegs.\r\n\r\ncc @mikemcquaid @xu-cheng ","created_at":"2015-08-12T14:00:50Z","updated_at":"2015-08-14T09:29:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"877a0703b051fc33bea709c87c346d0f795addb8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Homebrew/homebrew/pulls/42857/commits","review_comments_url":"https://api.github.com/repos/Homebrew/homebrew/pulls/42857/comments","review_comment_url":"https://api.github.com/repos/Homebrew/homebrew/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Homebrew/homebrew/issues/42857/comments","statuses_url":"https://api.github.com/repos/Homebrew/homebrew/statuses/073ff63e06fd35cb59fd21f8988f1ba34a8305ef","head":{"label":"vladshablinsky:migrator-fix","ref":"migrator-fix","sha":"073ff63e06fd35cb59fd21f8988f1ba34a8305ef","user":{"login":"vladshablinsky","id":4408920,"avatar_url":"https://avatars.githubusercontent.com/u/4408920?v=3","gravatar_id":"","url":"https://api.github.com/users/vladshablinsky","html_url":"https://github.com/vladshablinsky","followers_url":"https://api.github.com/users/vladshablinsky/followers","following_url":"https://api.github.com/users/vladshablinsky/following{/other_user}","gists_url":"https://api.github.com/users/vladshablinsky/gists{/gist_id}","starred_url":"https://api.github.com/users/vladshablinsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vladshablinsky/subscriptions","organizations_url":"https://api.github.com/users/vladshablinsky/orgs","repos_url":"https://api.github.com/users/vladshablinsky/repos","events_url":"https://api.github.com/users/vladshablinsky/events{/privacy}","received_events_url":"https://api.github.com/users/vladshablinsky/received_events","type":"User","site_admin":false},"repo":{"id":31970155,"name":"homebrew","full_name":"vladshablinsky/homebrew","owner":{"login":"vladshablinsky","id":4408920,"avatar_url":"https://avatars.githubusercontent.com/u/4408920?v=3","gravatar_id":"","url":"https://api.github.com/users/vladshablinsky","html_url":"https://github.com/vladshablinsky","followers_url":"https://api.github.com/users/vladshablinsky/followers","following_url":"https://api.github.com/users/vladshablinsky/following{/other_user}","gists_url":"https://api.github.com/users/vladshablinsky/gists{/gist_id}","starred_url":"https://api.github.com/users/vladshablinsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vladshablinsky/subscriptions","organizations_url":"https://api.github.com/users/vladshablinsky/orgs","repos_url":"https://api.github.com/users/vladshablinsky/repos","events_url":"https://api.github.com/users/vladshablinsky/events{/privacy}","received_events_url":"https://api.github.com/users/vladshablinsky/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vladshablinsky/homebrew","description":":beer: The missing package manager for OS X.","fork":true,"url":"https://api.github.com/repos/vladshablinsky/homebrew","forks_url":"https://api.github.com/repos/vladshablinsky/homebrew/forks","keys_url":"https://api.github.com/repos/vladshablinsky/homebrew/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vladshablinsky/homebrew/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vladshablinsky/homebrew/teams","hooks_url":"https://api.github.com/repos/vladshablinsky/homebrew/hooks","issue_events_url":"https://api.github.com/repos/vladshablinsky/homebrew/issues/events{/number}","events_url":"https://api.github.com/repos/vladshablinsky/homebrew/events","assignees_url":"https://api.github.com/repos/vladshablinsky/homebrew/assignees{/user}","branches_url":"https://api.github.com/repos/vladshablinsky/homebrew/branches{/branch}","tags_url":"https://api.github.com/repos/vladshablinsky/homebrew/tags","blobs_url":"https://api.github.com/repos/vladshablinsky/homebrew/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vladshablinsky/homebrew/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vladshablinsky/homebrew/git/refs{/sha}","trees_url":"https://api.github.com/repos/vladshablinsky/homebrew/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vladshablinsky/homebrew/statuses/{sha}","languages_url":"https://api.github.com/repos/vladshablinsky/homebrew/languages","stargazers_url":"https://api.github.com/repos/vladshablinsky/homebrew/stargazers","contributors_url":"https://api.github.com/repos/vladshablinsky/homebrew/contributors","subscribers_url":"https://api.github.com/repos/vladshablinsky/homebrew/subscribers","subscription_url":"https://api.github.com/repos/vladshablinsky/homebrew/subscription","commits_url":"https://api.github.com/repos/vladshablinsky/homebrew/commits{/sha}","git_commits_url":"https://api.github.com/repos/vladshablinsky/homebrew/git/commits{/sha}","comments_url":"https://api.github.com/repos/vladshablinsky/homebrew/comments{/number}","issue_comment_url":"https://api.github.com/repos/vladshablinsky/homebrew/issues/comments{/number}","contents_url":"https://api.github.com/repos/vladshablinsky/homebrew/contents/{+path}","compare_url":"https://api.github.com/repos/vladshablinsky/homebrew/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vladshablinsky/homebrew/merges","archive_url":"https://api.github.com/repos/vladshablinsky/homebrew/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vladshablinsky/homebrew/downloads","issues_url":"https://api.github.com/repos/vladshablinsky/homebrew/issues{/number}","pulls_url":"https://api.github.com/repos/vladshablinsky/homebrew/pulls{/number}","milestones_url":"https://api.github.com/repos/vladshablinsky/homebrew/milestones{/number}","notifications_url":"https://api.github.com/repos/vladshablinsky/homebrew/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vladshablinsky/homebrew/labels{/name}","releases_url":"https://api.github.com/repos/vladshablinsky/homebrew/releases{/id}","created_at":"2015-03-10T17:03:18Z","updated_at":"2015-07-10T15:03:18Z","pushed_at":"2015-08-13T16:20:49Z","git_url":"git://github.com/vladshablinsky/homebrew.git","ssh_url":"git@github.com:vladshablinsky/homebrew.git","clone_url":"https://github.com/vladshablinsky/homebrew.git","svn_url":"https://github.com/vladshablinsky/homebrew","homepage":"http://brew.sh","size":51237,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":false,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Homebrew:master","ref":"master","sha":"01799a9f26f63f99647363142a97ff710f3b2f51","user":{"login":"Homebrew","id":1503512,"avatar_url":"https://avatars.githubusercontent.com/u/1503512?v=3","gravatar_id":"","url":"https://api.github.com/users/Homebrew","html_url":"https://github.com/Homebrew","followers_url":"https://api.github.com/users/Homebrew/followers","following_url":"https://api.github.com/users/Homebrew/following{/other_user}","gists_url":"https://api.github.com/users/Homebrew/gists{/gist_id}","starred_url":"https://api.github.com/users/Homebrew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Homebrew/subscriptions","organizations_url":"https://api.github.com/users/Homebrew/orgs","repos_url":"https://api.github.com/users/Homebrew/repos","events_url":"https://api.github.com/users/Homebrew/events{/privacy}","received_events_url":"https://api.github.com/users/Homebrew/received_events","type":"Organization","site_admin":false},"repo":{"id":206084,"name":"homebrew","full_name":"Homebrew/homebrew","owner":{"login":"Homebrew","id":1503512,"avatar_url":"https://avatars.githubusercontent.com/u/1503512?v=3","gravatar_id":"","url":"https://api.github.com/users/Homebrew","html_url":"https://github.com/Homebrew","followers_url":"https://api.github.com/users/Homebrew/followers","following_url":"https://api.github.com/users/Homebrew/following{/other_user}","gists_url":"https://api.github.com/users/Homebrew/gists{/gist_id}","starred_url":"https://api.github.com/users/Homebrew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Homebrew/subscriptions","organizations_url":"https://api.github.com/users/Homebrew/orgs","repos_url":"https://api.github.com/users/Homebrew/repos","events_url":"https://api.github.com/users/Homebrew/events{/privacy}","received_events_url":"https://api.github.com/users/Homebrew/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Homebrew/homebrew","description":":beer: The missing package manager for OS X.","fork":false,"url":"https://api.github.com/repos/Homebrew/homebrew","forks_url":"https://api.github.com/repos/Homebrew/homebrew/forks","keys_url":"https://api.github.com/repos/Homebrew/homebrew/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Homebrew/homebrew/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Homebrew/homebrew/teams","hooks_url":"https://api.github.com/repos/Homebrew/homebrew/hooks","issue_events_url":"https://api.github.com/repos/Homebrew/homebrew/issues/events{/number}","events_url":"https://api.github.com/repos/Homebrew/homebrew/events","assignees_url":"https://api.github.com/repos/Homebrew/homebrew/assignees{/user}","branches_url":"https://api.github.com/repos/Homebrew/homebrew/branches{/branch}","tags_url":"https://api.github.com/repos/Homebrew/homebrew/tags","blobs_url":"https://api.github.com/repos/Homebrew/homebrew/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Homebrew/homebrew/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Homebrew/homebrew/git/refs{/sha}","trees_url":"https://api.github.com/repos/Homebrew/homebrew/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Homebrew/homebrew/statuses/{sha}","languages_url":"https://api.github.com/repos/Homebrew/homebrew/languages","stargazers_url":"https://api.github.com/repos/Homebrew/homebrew/stargazers","contributors_url":"https://api.github.com/repos/Homebrew/homebrew/contributors","subscribers_url":"https://api.github.com/repos/Homebrew/homebrew/subscribers","subscription_url":"https://api.github.com/repos/Homebrew/homebrew/subscription","commits_url":"https://api.github.com/repos/Homebrew/homebrew/commits{/sha}","git_commits_url":"https://api.github.com/repos/Homebrew/homebrew/git/commits{/sha}","comments_url":"https://api.github.com/repos/Homebrew/homebrew/comments{/number}","issue_comment_url":"https://api.github.com/repos/Homebrew/homebrew/issues/comments{/number}","contents_url":"https://api.github.com/repos/Homebrew/homebrew/contents/{+path}","compare_url":"https://api.github.com/repos/Homebrew/homebrew/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Homebrew/homebrew/merges","archive_url":"https://api.github.com/repos/Homebrew/homebrew/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Homebrew/homebrew/downloads","issues_url":"https://api.github.com/repos/Homebrew/homebrew/issues{/number}","pulls_url":"https://api.github.com/repos/Homebrew/homebrew/pulls{/number}","milestones_url":"https://api.github.com/repos/Homebrew/homebrew/milestones{/number}","notifications_url":"https://api.github.com/repos/Homebrew/homebrew/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Homebrew/homebrew/labels{/name}","releases_url":"https://api.github.com/repos/Homebrew/homebrew/releases{/id}","created_at":"2009-05-20T19:38:37Z","updated_at":"2015-08-14T07:37:29Z","pushed_at":"2015-08-14T08:55:40Z","git_url":"git://github.com/Homebrew/homebrew.git","ssh_url":"git@github.com:Homebrew/homebrew.git","clone_url":"https://github.com/Homebrew/homebrew.git","svn_url":"https://github.com/Homebrew/homebrew","homepage":"http://brew.sh","size":1591071,"stargazers_count":24629,"watchers_count":24629,"language":"Ruby","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":true,"forks_count":12372,"mirror_url":null,"open_issues_count":388,"forks":12372,"open_issues":388,"watchers":24629,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Homebrew/homebrew/pulls/42857"},"html":{"href":"https://github.com/Homebrew/homebrew/pull/42857"},"issue":{"href":"https://api.github.com/repos/Homebrew/homebrew/issues/42857"},"comments":{"href":"https://api.github.com/repos/Homebrew/homebrew/issues/42857/comments"},"review_comments":{"href":"https://api.github.com/repos/Homebrew/homebrew/pulls/42857/comments"},"review_comment":{"href":"https://api.github.com/repos/Homebrew/homebrew/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Homebrew/homebrew/pulls/42857/commits"},"statuses":{"href":"https://api.github.com/repos/Homebrew/homebrew/statuses/073ff63e06fd35cb59fd21f8988f1ba34a8305ef"}}}}