{"action":"created","comment":{"url":"https://api.github.com/repos/oppia/oppia/pulls/comments/41960500","id":41960500,"diff_hunk":"@@ -0,0 +1,182 @@\n+# coding: utf-8\n+#\n+# Copyright 2014 The Oppia Authors. All Rights Reserved.\n+#\n+# Licensed under the Apache License, Version 2.0 (the \"License\");\n+# you may not use this file except in compliance with the License.\n+# You may obtain a copy of the License at\n+#\n+#      http://www.apache.org/licenses/LICENSE-2.0\n+#\n+# Unless required by applicable law or agreed to in writing, software\n+# distributed under the License is distributed on an \"AS-IS\" BASIS,\n+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+# See the License for the specific language governing permissions and\n+# limitations under the License.\n+\n+\"\"\" Pre-commit script for oppia\n+This script checks Javascript coding style using jscs node module\n+It returns and fix errors\n+\n+IMPORTANT NOTES:\n+\n+1.  Before running this script, you must install third-party dependencies by\n+    running\n+\n+        bash scripts/start.sh\n+\n+    at least once.\n+\n+2.  This script should be run from the oppia root folder:\n+\n+        python scripts/pre_commit_linter.py\n+ Note that the root folder MUST be named 'oppia'.\n+ \"\"\"\n+\n+__author__ = \"Barnabas Makonda(barnabasmakonda@gmail.com)\"\n+\n+import os\n+import sys\n+import subprocess\n+\n+\n+def _current_changed():\n+    \"\"\"This function looks for all files changed but not\n+    yet staged.\n+    Returns:\n+        list of files changed but not staged files\n+    \"\"\"\n+    changed_files = os.popen(\"git diff --name-only\")","path":"scripts/pre_commit_linter.py","position":49,"original_position":49,"commit_id":"bc0494bd1f77cdb28bb41b9534d4daeb16717a1a","original_commit_id":"bc0494bd1f77cdb28bb41b9534d4daeb16717a1a","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":"Use the subprocess module instead -- see e.g. deploy.py for examples. According to [the docs](https://docs.python.org/2/library/subprocess.html) it's meant to replace the older os.popen stuff.","created_at":"2015-10-14T06:59:12Z","updated_at":"2015-10-14T06:59:12Z","html_url":"https://github.com/oppia/oppia/pull/1029#discussion_r41960500","pull_request_url":"https://api.github.com/repos/oppia/oppia/pulls/1029","_links":{"self":{"href":"https://api.github.com/repos/oppia/oppia/pulls/comments/41960500"},"html":{"href":"https://github.com/oppia/oppia/pull/1029#discussion_r41960500"},"pull_request":{"href":"https://api.github.com/repos/oppia/oppia/pulls/1029"}}},"pull_request":{"url":"https://api.github.com/repos/oppia/oppia/pulls/1029","id":47378444,"html_url":"https://github.com/oppia/oppia/pull/1029","diff_url":"https://github.com/oppia/oppia/pull/1029.diff","patch_url":"https://github.com/oppia/oppia/pull/1029.patch","issue_url":"https://api.github.com/repos/oppia/oppia/issues/1029","number":1029,"state":"open","locked":false,"title":"[WORK-IN-PROGRESS]Pre commit JS-Linter scripts","user":{"login":"MAKOSCAFEE","id":6409210,"avatar_url":"https://avatars.githubusercontent.com/u/6409210?v=3","gravatar_id":"","url":"https://api.github.com/users/MAKOSCAFEE","html_url":"https://github.com/MAKOSCAFEE","followers_url":"https://api.github.com/users/MAKOSCAFEE/followers","following_url":"https://api.github.com/users/MAKOSCAFEE/following{/other_user}","gists_url":"https://api.github.com/users/MAKOSCAFEE/gists{/gist_id}","starred_url":"https://api.github.com/users/MAKOSCAFEE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MAKOSCAFEE/subscriptions","organizations_url":"https://api.github.com/users/MAKOSCAFEE/orgs","repos_url":"https://api.github.com/users/MAKOSCAFEE/repos","events_url":"https://api.github.com/users/MAKOSCAFEE/events{/privacy}","received_events_url":"https://api.github.com/users/MAKOSCAFEE/received_events","type":"User","site_admin":false},"body":"This contains initial work for  checking JavaScript coding-style before committing any change to oppia codebase.\r\nIt uses [node-jscs](https://github.com/jscs-dev/node-jscs) library and Google style-guide. With few customization as seen in ```.jsrcsrc``` file.  Decided to use ```node-jscs``` because if preset it follows google style-guide, can easly be customized or add new rule and it can auto-fix errors. But if there is preference to Library this can be changed. \r\n\r\nSo far what it does:\r\n*  find all changed files(Staged and non-staged) and select only JavaScript files.\r\n* And lint all JS displaying error in the console.\r\n* It can also automatically fix errors like space after comma, space after fn(), capitalize first letter, adding semicolon where forgotten, indentation,convert tabs into space and likes(is disabled for now until full customization)\r\n\r\nWhat to more to be done:\r\n* Continuing customizing rules based on GOOGLE STYLE GUIDE and project requirement.\r\n* Also when fully customized can be used to clean all javascript files\r\n\r\nThanks","created_at":"2015-10-11T23:45:16Z","updated_at":"2015-10-14T06:59:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9ad370d6e1139a7938b32dc7f069d83a3c4dee7e","assignee":{"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},"milestone":null,"commits_url":"https://api.github.com/repos/oppia/oppia/pulls/1029/commits","review_comments_url":"https://api.github.com/repos/oppia/oppia/pulls/1029/comments","review_comment_url":"https://api.github.com/repos/oppia/oppia/pulls/comments{/number}","comments_url":"https://api.github.com/repos/oppia/oppia/issues/1029/comments","statuses_url":"https://api.github.com/repos/oppia/oppia/statuses/bc0494bd1f77cdb28bb41b9534d4daeb16717a1a","head":{"label":"MAKOSCAFEE:pre-commit-linter-scripts","ref":"pre-commit-linter-scripts","sha":"bc0494bd1f77cdb28bb41b9534d4daeb16717a1a","user":{"login":"MAKOSCAFEE","id":6409210,"avatar_url":"https://avatars.githubusercontent.com/u/6409210?v=3","gravatar_id":"","url":"https://api.github.com/users/MAKOSCAFEE","html_url":"https://github.com/MAKOSCAFEE","followers_url":"https://api.github.com/users/MAKOSCAFEE/followers","following_url":"https://api.github.com/users/MAKOSCAFEE/following{/other_user}","gists_url":"https://api.github.com/users/MAKOSCAFEE/gists{/gist_id}","starred_url":"https://api.github.com/users/MAKOSCAFEE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MAKOSCAFEE/subscriptions","organizations_url":"https://api.github.com/users/MAKOSCAFEE/orgs","repos_url":"https://api.github.com/users/MAKOSCAFEE/repos","events_url":"https://api.github.com/users/MAKOSCAFEE/events{/privacy}","received_events_url":"https://api.github.com/users/MAKOSCAFEE/received_events","type":"User","site_admin":false},"repo":{"id":40843161,"name":"oppia","full_name":"MAKOSCAFEE/oppia","owner":{"login":"MAKOSCAFEE","id":6409210,"avatar_url":"https://avatars.githubusercontent.com/u/6409210?v=3","gravatar_id":"","url":"https://api.github.com/users/MAKOSCAFEE","html_url":"https://github.com/MAKOSCAFEE","followers_url":"https://api.github.com/users/MAKOSCAFEE/followers","following_url":"https://api.github.com/users/MAKOSCAFEE/following{/other_user}","gists_url":"https://api.github.com/users/MAKOSCAFEE/gists{/gist_id}","starred_url":"https://api.github.com/users/MAKOSCAFEE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MAKOSCAFEE/subscriptions","organizations_url":"https://api.github.com/users/MAKOSCAFEE/orgs","repos_url":"https://api.github.com/users/MAKOSCAFEE/repos","events_url":"https://api.github.com/users/MAKOSCAFEE/events{/privacy}","received_events_url":"https://api.github.com/users/MAKOSCAFEE/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/MAKOSCAFEE/oppia","description":"Tool for creating interactive tutors.","fork":true,"url":"https://api.github.com/repos/MAKOSCAFEE/oppia","forks_url":"https://api.github.com/repos/MAKOSCAFEE/oppia/forks","keys_url":"https://api.github.com/repos/MAKOSCAFEE/oppia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MAKOSCAFEE/oppia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MAKOSCAFEE/oppia/teams","hooks_url":"https://api.github.com/repos/MAKOSCAFEE/oppia/hooks","issue_events_url":"https://api.github.com/repos/MAKOSCAFEE/oppia/issues/events{/number}","events_url":"https://api.github.com/repos/MAKOSCAFEE/oppia/events","assignees_url":"https://api.github.com/repos/MAKOSCAFEE/oppia/assignees{/user}","branches_url":"https://api.github.com/repos/MAKOSCAFEE/oppia/branches{/branch}","tags_url":"https://api.github.com/repos/MAKOSCAFEE/oppia/tags","blobs_url":"https://api.github.com/repos/MAKOSCAFEE/oppia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MAKOSCAFEE/oppia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MAKOSCAFEE/oppia/git/refs{/sha}","trees_url":"https://api.github.com/repos/MAKOSCAFEE/oppia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MAKOSCAFEE/oppia/statuses/{sha}","languages_url":"https://api.github.com/repos/MAKOSCAFEE/oppia/languages","stargazers_url":"https://api.github.com/repos/MAKOSCAFEE/oppia/stargazers","contributors_url":"https://api.github.com/repos/MAKOSCAFEE/oppia/contributors","subscribers_url":"https://api.github.com/repos/MAKOSCAFEE/oppia/subscribers","subscription_url":"https://api.github.com/repos/MAKOSCAFEE/oppia/subscription","commits_url":"https://api.github.com/repos/MAKOSCAFEE/oppia/commits{/sha}","git_commits_url":"https://api.github.com/repos/MAKOSCAFEE/oppia/git/commits{/sha}","comments_url":"https://api.github.com/repos/MAKOSCAFEE/oppia/comments{/number}","issue_comment_url":"https://api.github.com/repos/MAKOSCAFEE/oppia/issues/comments{/number}","contents_url":"https://api.github.com/repos/MAKOSCAFEE/oppia/contents/{+path}","compare_url":"https://api.github.com/repos/MAKOSCAFEE/oppia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MAKOSCAFEE/oppia/merges","archive_url":"https://api.github.com/repos/MAKOSCAFEE/oppia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MAKOSCAFEE/oppia/downloads","issues_url":"https://api.github.com/repos/MAKOSCAFEE/oppia/issues{/number}","pulls_url":"https://api.github.com/repos/MAKOSCAFEE/oppia/pulls{/number}","milestones_url":"https://api.github.com/repos/MAKOSCAFEE/oppia/milestones{/number}","notifications_url":"https://api.github.com/repos/MAKOSCAFEE/oppia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MAKOSCAFEE/oppia/labels{/name}","releases_url":"https://api.github.com/repos/MAKOSCAFEE/oppia/releases{/id}","created_at":"2015-08-16T21:49:10Z","updated_at":"2015-08-16T21:49:11Z","pushed_at":"2015-10-13T08:46:27Z","git_url":"git://github.com/MAKOSCAFEE/oppia.git","ssh_url":"git@github.com:MAKOSCAFEE/oppia.git","clone_url":"https://github.com/MAKOSCAFEE/oppia.git","svn_url":"https://github.com/MAKOSCAFEE/oppia","homepage":"https://www.oppia.org","size":42402,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":false,"has_wiki":false,"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":"db5c2d17336dfdbad58ddc6e8c9503a5fad51826","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 interactive 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}","created_at":"2015-08-14T00:16:14Z","updated_at":"2015-10-06T09:18:56Z","pushed_at":"2015-10-14T03:04:53Z","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":43888,"stargazers_count":44,"watchers_count":44,"language":"Python","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":60,"mirror_url":null,"open_issues_count":178,"forks":60,"open_issues":178,"watchers":44,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/oppia/oppia/pulls/1029"},"html":{"href":"https://github.com/oppia/oppia/pull/1029"},"issue":{"href":"https://api.github.com/repos/oppia/oppia/issues/1029"},"comments":{"href":"https://api.github.com/repos/oppia/oppia/issues/1029/comments"},"review_comments":{"href":"https://api.github.com/repos/oppia/oppia/pulls/1029/comments"},"review_comment":{"href":"https://api.github.com/repos/oppia/oppia/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/oppia/oppia/pulls/1029/commits"},"statuses":{"href":"https://api.github.com/repos/oppia/oppia/statuses/bc0494bd1f77cdb28bb41b9534d4daeb16717a1a"}}}}