{"action":"created","comment":{"url":"https://api.github.com/repos/oppia/oppia/pulls/comments/54345717","id":54345717,"diff_hunk":"@@ -55,6 +55,30 @@\n LINTER_FILE_FLAG = '--files'\n PYTHON_CMD = 'python'\n FRONTEND_TEST_SCRIPT = 'run_frontend_tests.sh'\n+GIT_IS_DIRTY_CMD = 'git status --porcelain --untracked-files=no'\n+\n+\n+class ChangedBranch(object):\n+    def __init__(self, new_branch):\n+        get_branch_cmd = 'git symbolic-ref -q --short HEAD'.split()\n+        self.old_branch = subprocess.check_output(get_branch_cmd).strip()\n+        self.new_branch = new_branch\n+        self.is_same_branch = self.old_branch == self.new_branch\n+\n+    def __enter__(self):\n+        if not self.is_same_branch:\n+            try:\n+                subprocess.check_output(['git', 'checkout', self.new_branch])\n+            except subprocess.CalledProcessError:\n+                print ('\\nCould not change to %s. This is most probably because'\n+                       ' you are in a dirty state. Change to the branch that is'","path":"scripts/pre_push_hook.py","position":20,"original_position":20,"commit_id":"b0fdc462404dc4e48d349a0e508fe21e99cac762","original_commit_id":"b0fdc462404dc4e48d349a0e508fe21e99cac762","user":{"login":"seanlip","id":10575562,"avatar_url":"https://avatars.githubusercontent.com/u/10575562?v=3","gravatar_id":"","url":"https://api.github.com/users/seanlip","html_url":"https://github.com/seanlip","followers_url":"https://api.github.com/users/seanlip/followers","following_url":"https://api.github.com/users/seanlip/following{/other_user}","gists_url":"https://api.github.com/users/seanlip/gists{/gist_id}","starred_url":"https://api.github.com/users/seanlip/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seanlip/subscriptions","organizations_url":"https://api.github.com/users/seanlip/orgs","repos_url":"https://api.github.com/users/seanlip/repos","events_url":"https://api.github.com/users/seanlip/events{/privacy}","received_events_url":"https://api.github.com/users/seanlip/received_events","type":"User","site_admin":false},"body":"Suggest \"Change manually to the branch that is being linted, or stash your changes.\", otherwise it reads as though \"manually\" is modifying \"linted\".","created_at":"2016-02-28T08:09:47Z","updated_at":"2016-02-28T08:09:47Z","html_url":"https://github.com/oppia/oppia/pull/1520#discussion_r54345717","pull_request_url":"https://api.github.com/repos/oppia/oppia/pulls/1520","_links":{"self":{"href":"https://api.github.com/repos/oppia/oppia/pulls/comments/54345717"},"html":{"href":"https://github.com/oppia/oppia/pull/1520#discussion_r54345717"},"pull_request":{"href":"https://api.github.com/repos/oppia/oppia/pulls/1520"}}},"pull_request":{"url":"https://api.github.com/repos/oppia/oppia/pulls/1520","id":60944674,"html_url":"https://github.com/oppia/oppia/pull/1520","diff_url":"https://github.com/oppia/oppia/pull/1520.diff","patch_url":"https://github.com/oppia/oppia/pull/1520.patch","issue_url":"https://api.github.com/repos/oppia/oppia/issues/1520","number":1520,"state":"open","locked":false,"title":"Pre-push hook now switches to the correct branch before linting.","user":{"login":"brunnre8","id":16165454,"avatar_url":"https://avatars.githubusercontent.com/u/16165454?v=3","gravatar_id":"","url":"https://api.github.com/users/brunnre8","html_url":"https://github.com/brunnre8","followers_url":"https://api.github.com/users/brunnre8/followers","following_url":"https://api.github.com/users/brunnre8/following{/other_user}","gists_url":"https://api.github.com/users/brunnre8/gists{/gist_id}","starred_url":"https://api.github.com/users/brunnre8/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brunnre8/subscriptions","organizations_url":"https://api.github.com/users/brunnre8/orgs","repos_url":"https://api.github.com/users/brunnre8/repos","events_url":"https://api.github.com/users/brunnre8/events{/privacy}","received_events_url":"https://api.github.com/users/brunnre8/received_events","type":"User","site_admin":false},"body":"Fixes #1488.\r\n\r\nThe pre_push hook had the issue that he was linting the state of the current active branch and not the actual state of the branch being pushed.\r\n\r\nThis PR fixes this by trying to change to the branch under test.","created_at":"2016-02-27T09:56:22Z","updated_at":"2016-02-28T08:09:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3c94715e8a2c02047c59d78d9b54d7ef0f91348b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/oppia/oppia/pulls/1520/commits","review_comments_url":"https://api.github.com/repos/oppia/oppia/pulls/1520/comments","review_comment_url":"https://api.github.com/repos/oppia/oppia/pulls/comments{/number}","comments_url":"https://api.github.com/repos/oppia/oppia/issues/1520/comments","statuses_url":"https://api.github.com/repos/oppia/oppia/statuses/b0fdc462404dc4e48d349a0e508fe21e99cac762","head":{"label":"brunnre8:hook_not_linting","ref":"hook_not_linting","sha":"b0fdc462404dc4e48d349a0e508fe21e99cac762","user":{"login":"brunnre8","id":16165454,"avatar_url":"https://avatars.githubusercontent.com/u/16165454?v=3","gravatar_id":"","url":"https://api.github.com/users/brunnre8","html_url":"https://github.com/brunnre8","followers_url":"https://api.github.com/users/brunnre8/followers","following_url":"https://api.github.com/users/brunnre8/following{/other_user}","gists_url":"https://api.github.com/users/brunnre8/gists{/gist_id}","starred_url":"https://api.github.com/users/brunnre8/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brunnre8/subscriptions","organizations_url":"https://api.github.com/users/brunnre8/orgs","repos_url":"https://api.github.com/users/brunnre8/repos","events_url":"https://api.github.com/users/brunnre8/events{/privacy}","received_events_url":"https://api.github.com/users/brunnre8/received_events","type":"User","site_admin":false},"repo":{"id":48689605,"name":"oppia","full_name":"brunnre8/oppia","owner":{"login":"brunnre8","id":16165454,"avatar_url":"https://avatars.githubusercontent.com/u/16165454?v=3","gravatar_id":"","url":"https://api.github.com/users/brunnre8","html_url":"https://github.com/brunnre8","followers_url":"https://api.github.com/users/brunnre8/followers","following_url":"https://api.github.com/users/brunnre8/following{/other_user}","gists_url":"https://api.github.com/users/brunnre8/gists{/gist_id}","starred_url":"https://api.github.com/users/brunnre8/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brunnre8/subscriptions","organizations_url":"https://api.github.com/users/brunnre8/orgs","repos_url":"https://api.github.com/users/brunnre8/repos","events_url":"https://api.github.com/users/brunnre8/events{/privacy}","received_events_url":"https://api.github.com/users/brunnre8/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/brunnre8/oppia","description":"Tool for collaboratively building interactive tutors.","fork":true,"url":"https://api.github.com/repos/brunnre8/oppia","forks_url":"https://api.github.com/repos/brunnre8/oppia/forks","keys_url":"https://api.github.com/repos/brunnre8/oppia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/brunnre8/oppia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/brunnre8/oppia/teams","hooks_url":"https://api.github.com/repos/brunnre8/oppia/hooks","issue_events_url":"https://api.github.com/repos/brunnre8/oppia/issues/events{/number}","events_url":"https://api.github.com/repos/brunnre8/oppia/events","assignees_url":"https://api.github.com/repos/brunnre8/oppia/assignees{/user}","branches_url":"https://api.github.com/repos/brunnre8/oppia/branches{/branch}","tags_url":"https://api.github.com/repos/brunnre8/oppia/tags","blobs_url":"https://api.github.com/repos/brunnre8/oppia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/brunnre8/oppia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/brunnre8/oppia/git/refs{/sha}","trees_url":"https://api.github.com/repos/brunnre8/oppia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/brunnre8/oppia/statuses/{sha}","languages_url":"https://api.github.com/repos/brunnre8/oppia/languages","stargazers_url":"https://api.github.com/repos/brunnre8/oppia/stargazers","contributors_url":"https://api.github.com/repos/brunnre8/oppia/contributors","subscribers_url":"https://api.github.com/repos/brunnre8/oppia/subscribers","subscription_url":"https://api.github.com/repos/brunnre8/oppia/subscription","commits_url":"https://api.github.com/repos/brunnre8/oppia/commits{/sha}","git_commits_url":"https://api.github.com/repos/brunnre8/oppia/git/commits{/sha}","comments_url":"https://api.github.com/repos/brunnre8/oppia/comments{/number}","issue_comment_url":"https://api.github.com/repos/brunnre8/oppia/issues/comments{/number}","contents_url":"https://api.github.com/repos/brunnre8/oppia/contents/{+path}","compare_url":"https://api.github.com/repos/brunnre8/oppia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/brunnre8/oppia/merges","archive_url":"https://api.github.com/repos/brunnre8/oppia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/brunnre8/oppia/downloads","issues_url":"https://api.github.com/repos/brunnre8/oppia/issues{/number}","pulls_url":"https://api.github.com/repos/brunnre8/oppia/pulls{/number}","milestones_url":"https://api.github.com/repos/brunnre8/oppia/milestones{/number}","notifications_url":"https://api.github.com/repos/brunnre8/oppia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/brunnre8/oppia/labels{/name}","releases_url":"https://api.github.com/repos/brunnre8/oppia/releases{/id}","deployments_url":"https://api.github.com/repos/brunnre8/oppia/deployments","created_at":"2015-12-28T11:34:00Z","updated_at":"2016-01-11T06:55:43Z","pushed_at":"2016-02-27T09:49:45Z","git_url":"git://github.com/brunnre8/oppia.git","ssh_url":"git@github.com:brunnre8/oppia.git","clone_url":"https://github.com/brunnre8/oppia.git","svn_url":"https://github.com/brunnre8/oppia","homepage":"https://www.oppia.org","size":41271,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"oppia:develop","ref":"develop","sha":"f1d3e571185aadfc0c02f2506304c19e007386e1","user":{"login":"oppia","id":11620230,"avatar_url":"https://avatars.githubusercontent.com/u/11620230?v=3","gravatar_id":"","url":"https://api.github.com/users/oppia","html_url":"https://github.com/oppia","followers_url":"https://api.github.com/users/oppia/followers","following_url":"https://api.github.com/users/oppia/following{/other_user}","gists_url":"https://api.github.com/users/oppia/gists{/gist_id}","starred_url":"https://api.github.com/users/oppia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oppia/subscriptions","organizations_url":"https://api.github.com/users/oppia/orgs","repos_url":"https://api.github.com/users/oppia/repos","events_url":"https://api.github.com/users/oppia/events{/privacy}","received_events_url":"https://api.github.com/users/oppia/received_events","type":"Organization","site_admin":false},"repo":{"id":40687563,"name":"oppia","full_name":"oppia/oppia","owner":{"login":"oppia","id":11620230,"avatar_url":"https://avatars.githubusercontent.com/u/11620230?v=3","gravatar_id":"","url":"https://api.github.com/users/oppia","html_url":"https://github.com/oppia","followers_url":"https://api.github.com/users/oppia/followers","following_url":"https://api.github.com/users/oppia/following{/other_user}","gists_url":"https://api.github.com/users/oppia/gists{/gist_id}","starred_url":"https://api.github.com/users/oppia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oppia/subscriptions","organizations_url":"https://api.github.com/users/oppia/orgs","repos_url":"https://api.github.com/users/oppia/repos","events_url":"https://api.github.com/users/oppia/events{/privacy}","received_events_url":"https://api.github.com/users/oppia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/oppia/oppia","description":"Tool for collaboratively building intelligent tutors.","fork":false,"url":"https://api.github.com/repos/oppia/oppia","forks_url":"https://api.github.com/repos/oppia/oppia/forks","keys_url":"https://api.github.com/repos/oppia/oppia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/oppia/oppia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/oppia/oppia/teams","hooks_url":"https://api.github.com/repos/oppia/oppia/hooks","issue_events_url":"https://api.github.com/repos/oppia/oppia/issues/events{/number}","events_url":"https://api.github.com/repos/oppia/oppia/events","assignees_url":"https://api.github.com/repos/oppia/oppia/assignees{/user}","branches_url":"https://api.github.com/repos/oppia/oppia/branches{/branch}","tags_url":"https://api.github.com/repos/oppia/oppia/tags","blobs_url":"https://api.github.com/repos/oppia/oppia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/oppia/oppia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/oppia/oppia/git/refs{/sha}","trees_url":"https://api.github.com/repos/oppia/oppia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/oppia/oppia/statuses/{sha}","languages_url":"https://api.github.com/repos/oppia/oppia/languages","stargazers_url":"https://api.github.com/repos/oppia/oppia/stargazers","contributors_url":"https://api.github.com/repos/oppia/oppia/contributors","subscribers_url":"https://api.github.com/repos/oppia/oppia/subscribers","subscription_url":"https://api.github.com/repos/oppia/oppia/subscription","commits_url":"https://api.github.com/repos/oppia/oppia/commits{/sha}","git_commits_url":"https://api.github.com/repos/oppia/oppia/git/commits{/sha}","comments_url":"https://api.github.com/repos/oppia/oppia/comments{/number}","issue_comment_url":"https://api.github.com/repos/oppia/oppia/issues/comments{/number}","contents_url":"https://api.github.com/repos/oppia/oppia/contents/{+path}","compare_url":"https://api.github.com/repos/oppia/oppia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/oppia/oppia/merges","archive_url":"https://api.github.com/repos/oppia/oppia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/oppia/oppia/downloads","issues_url":"https://api.github.com/repos/oppia/oppia/issues{/number}","pulls_url":"https://api.github.com/repos/oppia/oppia/pulls{/number}","milestones_url":"https://api.github.com/repos/oppia/oppia/milestones{/number}","notifications_url":"https://api.github.com/repos/oppia/oppia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/oppia/oppia/labels{/name}","releases_url":"https://api.github.com/repos/oppia/oppia/releases{/id}","deployments_url":"https://api.github.com/repos/oppia/oppia/deployments","created_at":"2015-08-14T00:16:14Z","updated_at":"2016-02-27T22:57:00Z","pushed_at":"2016-02-28T03:50:33Z","git_url":"git://github.com/oppia/oppia.git","ssh_url":"git@github.com:oppia/oppia.git","clone_url":"https://github.com/oppia/oppia.git","svn_url":"https://github.com/oppia/oppia","homepage":"https://www.oppia.org","size":73497,"stargazers_count":81,"watchers_count":81,"language":"Python","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":121,"mirror_url":null,"open_issues_count":276,"forks":121,"open_issues":276,"watchers":81,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/oppia/oppia/pulls/1520"},"html":{"href":"https://github.com/oppia/oppia/pull/1520"},"issue":{"href":"https://api.github.com/repos/oppia/oppia/issues/1520"},"comments":{"href":"https://api.github.com/repos/oppia/oppia/issues/1520/comments"},"review_comments":{"href":"https://api.github.com/repos/oppia/oppia/pulls/1520/comments"},"review_comment":{"href":"https://api.github.com/repos/oppia/oppia/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/oppia/oppia/pulls/1520/commits"},"statuses":{"href":"https://api.github.com/repos/oppia/oppia/statuses/b0fdc462404dc4e48d349a0e508fe21e99cac762"}}}}