{"action":"created","comment":{"url":"https://api.github.com/repos/scopatz/xonsh/pulls/comments/30294083","id":30294083,"diff_hunk":"@@ -70,8 +79,28 @@ def current_branch(cwd=None, pad=True):\n     return branch or ''\n \n \n+@ensure_git\n+def git_dirty(cwd=None):\n+    \"\"\"Returns a boolean as to whether there are uncommitted files on the\n+    current branch of a git repository (if there is one)\"\"\"\n+    try:\n+        cmd = ['git', 'status', '--porcelain']\n+        s = subprocess.check_output(cmd,\n+                                    stderr=subprocess.PIPE,\n+                                    cwd=cwd,\n+                                    universal_newlines=True)\n+        return bool(s)\n+    except subprocess.CalledProcessError:\n+        return False\n+\n+\n+def git_dirty_color():","path":"xonsh/environ.py","position":78,"original_position":78,"commit_id":"aefd19aacabb62b411f4d29bb93408dd68144a4a","original_commit_id":"aefd19aacabb62b411f4d29bb93408dd68144a4a","user":{"login":"scopatz","id":320553,"avatar_url":"https://avatars.githubusercontent.com/u/320553?v=3","gravatar_id":"","url":"https://api.github.com/users/scopatz","html_url":"https://github.com/scopatz","followers_url":"https://api.github.com/users/scopatz/followers","following_url":"https://api.github.com/users/scopatz/following{/other_user}","gists_url":"https://api.github.com/users/scopatz/gists{/gist_id}","starred_url":"https://api.github.com/users/scopatz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scopatz/subscriptions","organizations_url":"https://api.github.com/users/scopatz/orgs","repos_url":"https://api.github.com/users/scopatz/repos","events_url":"https://api.github.com/users/scopatz/events{/privacy}","received_events_url":"https://api.github.com/users/scopatz/received_events","type":"User","site_admin":false},"body":"This needs a docstring, since it is public.  Also, maybe this could just be called `git_color()` since it returns a color either way?","created_at":"2015-05-14T02:40:59Z","updated_at":"2015-05-14T02:40:59Z","html_url":"https://github.com/scopatz/xonsh/pull/228#discussion_r30294083","pull_request_url":"https://api.github.com/repos/scopatz/xonsh/pulls/228","_links":{"self":{"href":"https://api.github.com/repos/scopatz/xonsh/pulls/comments/30294083"},"html":{"href":"https://github.com/scopatz/xonsh/pull/228#discussion_r30294083"},"pull_request":{"href":"https://api.github.com/repos/scopatz/xonsh/pulls/228"}}},"pull_request":{"url":"https://api.github.com/repos/scopatz/xonsh/pulls/228","id":35389279,"html_url":"https://github.com/scopatz/xonsh/pull/228","diff_url":"https://github.com/scopatz/xonsh/pull/228.diff","patch_url":"https://github.com/scopatz/xonsh/pull/228.patch","issue_url":"https://api.github.com/repos/scopatz/xonsh/issues/228","number":228,"state":"open","locked":false,"title":"Update prompt to display different color branch name if git is dirty","user":{"login":"gthole","id":1581949,"avatar_url":"https://avatars.githubusercontent.com/u/1581949?v=3","gravatar_id":"","url":"https://api.github.com/users/gthole","html_url":"https://github.com/gthole","followers_url":"https://api.github.com/users/gthole/followers","following_url":"https://api.github.com/users/gthole/following{/other_user}","gists_url":"https://api.github.com/users/gthole/gists{/gist_id}","starred_url":"https://api.github.com/users/gthole/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gthole/subscriptions","organizations_url":"https://api.github.com/users/gthole/orgs","repos_url":"https://api.github.com/users/gthole/repos","events_url":"https://api.github.com/users/gthole/events{/privacy}","received_events_url":"https://api.github.com/users/gthole/received_events","type":"User","site_admin":false},"body":"Maybe it's a little presumptuous for my first PR to the project to modify something as fundamental as the default prompt, but I find it incredibly informative to know from the prompt whether the current git repository is clean or dirty.\r\n\r\nThis PR sets changes the color of the `curr_branch` to be green if git is clean, or red if there are uncommitted files, and updates the documentation with the added `$FORMATTER_DICT` setting.\r\n\r\n![git is clean](http://www.american-buddha.com/ghostbust.127d.gif)","created_at":"2015-05-14T02:33:30Z","updated_at":"2015-05-14T02:41:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"804aed725af35844d0a64c0d9e688abf08b783b2","assignee":null,"milestone":{"url":"https://api.github.com/repos/scopatz/xonsh/milestones/1","html_url":"https://github.com/scopatz/xonsh/milestones/v0.2","labels_url":"https://api.github.com/repos/scopatz/xonsh/milestones/1/labels","id":1013181,"number":1,"title":"v0.2","description":"","creator":{"login":"scopatz","id":320553,"avatar_url":"https://avatars.githubusercontent.com/u/320553?v=3","gravatar_id":"","url":"https://api.github.com/users/scopatz","html_url":"https://github.com/scopatz","followers_url":"https://api.github.com/users/scopatz/followers","following_url":"https://api.github.com/users/scopatz/following{/other_user}","gists_url":"https://api.github.com/users/scopatz/gists{/gist_id}","starred_url":"https://api.github.com/users/scopatz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scopatz/subscriptions","organizations_url":"https://api.github.com/users/scopatz/orgs","repos_url":"https://api.github.com/users/scopatz/repos","events_url":"https://api.github.com/users/scopatz/events{/privacy}","received_events_url":"https://api.github.com/users/scopatz/received_events","type":"User","site_admin":false},"open_issues":31,"closed_issues":185,"state":"open","created_at":"2015-03-09T18:29:10Z","updated_at":"2015-05-14T02:36:50Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/scopatz/xonsh/pulls/228/commits","review_comments_url":"https://api.github.com/repos/scopatz/xonsh/pulls/228/comments","review_comment_url":"https://api.github.com/repos/scopatz/xonsh/pulls/comments{/number}","comments_url":"https://api.github.com/repos/scopatz/xonsh/issues/228/comments","statuses_url":"https://api.github.com/repos/scopatz/xonsh/statuses/aefd19aacabb62b411f4d29bb93408dd68144a4a","head":{"label":"gthole:git-dirty","ref":"git-dirty","sha":"aefd19aacabb62b411f4d29bb93408dd68144a4a","user":{"login":"gthole","id":1581949,"avatar_url":"https://avatars.githubusercontent.com/u/1581949?v=3","gravatar_id":"","url":"https://api.github.com/users/gthole","html_url":"https://github.com/gthole","followers_url":"https://api.github.com/users/gthole/followers","following_url":"https://api.github.com/users/gthole/following{/other_user}","gists_url":"https://api.github.com/users/gthole/gists{/gist_id}","starred_url":"https://api.github.com/users/gthole/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gthole/subscriptions","organizations_url":"https://api.github.com/users/gthole/orgs","repos_url":"https://api.github.com/users/gthole/repos","events_url":"https://api.github.com/users/gthole/events{/privacy}","received_events_url":"https://api.github.com/users/gthole/received_events","type":"User","site_admin":false},"repo":{"id":35551673,"name":"xonsh","full_name":"gthole/xonsh","owner":{"login":"gthole","id":1581949,"avatar_url":"https://avatars.githubusercontent.com/u/1581949?v=3","gravatar_id":"","url":"https://api.github.com/users/gthole","html_url":"https://github.com/gthole","followers_url":"https://api.github.com/users/gthole/followers","following_url":"https://api.github.com/users/gthole/following{/other_user}","gists_url":"https://api.github.com/users/gthole/gists{/gist_id}","starred_url":"https://api.github.com/users/gthole/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gthole/subscriptions","organizations_url":"https://api.github.com/users/gthole/orgs","repos_url":"https://api.github.com/users/gthole/repos","events_url":"https://api.github.com/users/gthole/events{/privacy}","received_events_url":"https://api.github.com/users/gthole/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gthole/xonsh","description":"xonsh is a Python-ish, BASHwards-compatible shell.","fork":true,"url":"https://api.github.com/repos/gthole/xonsh","forks_url":"https://api.github.com/repos/gthole/xonsh/forks","keys_url":"https://api.github.com/repos/gthole/xonsh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gthole/xonsh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gthole/xonsh/teams","hooks_url":"https://api.github.com/repos/gthole/xonsh/hooks","issue_events_url":"https://api.github.com/repos/gthole/xonsh/issues/events{/number}","events_url":"https://api.github.com/repos/gthole/xonsh/events","assignees_url":"https://api.github.com/repos/gthole/xonsh/assignees{/user}","branches_url":"https://api.github.com/repos/gthole/xonsh/branches{/branch}","tags_url":"https://api.github.com/repos/gthole/xonsh/tags","blobs_url":"https://api.github.com/repos/gthole/xonsh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gthole/xonsh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gthole/xonsh/git/refs{/sha}","trees_url":"https://api.github.com/repos/gthole/xonsh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gthole/xonsh/statuses/{sha}","languages_url":"https://api.github.com/repos/gthole/xonsh/languages","stargazers_url":"https://api.github.com/repos/gthole/xonsh/stargazers","contributors_url":"https://api.github.com/repos/gthole/xonsh/contributors","subscribers_url":"https://api.github.com/repos/gthole/xonsh/subscribers","subscription_url":"https://api.github.com/repos/gthole/xonsh/subscription","commits_url":"https://api.github.com/repos/gthole/xonsh/commits{/sha}","git_commits_url":"https://api.github.com/repos/gthole/xonsh/git/commits{/sha}","comments_url":"https://api.github.com/repos/gthole/xonsh/comments{/number}","issue_comment_url":"https://api.github.com/repos/gthole/xonsh/issues/comments{/number}","contents_url":"https://api.github.com/repos/gthole/xonsh/contents/{+path}","compare_url":"https://api.github.com/repos/gthole/xonsh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gthole/xonsh/merges","archive_url":"https://api.github.com/repos/gthole/xonsh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gthole/xonsh/downloads","issues_url":"https://api.github.com/repos/gthole/xonsh/issues{/number}","pulls_url":"https://api.github.com/repos/gthole/xonsh/pulls{/number}","milestones_url":"https://api.github.com/repos/gthole/xonsh/milestones{/number}","notifications_url":"https://api.github.com/repos/gthole/xonsh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gthole/xonsh/labels{/name}","releases_url":"https://api.github.com/repos/gthole/xonsh/releases{/id}","created_at":"2015-05-13T13:48:44Z","updated_at":"2015-05-13T13:48:45Z","pushed_at":"2015-05-14T02:21:07Z","git_url":"git://github.com/gthole/xonsh.git","ssh_url":"git@github.com:gthole/xonsh.git","clone_url":"https://github.com/gthole/xonsh.git","svn_url":"https://github.com/gthole/xonsh","homepage":"http://xonsh.org","size":4967,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"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":"master"}},"base":{"label":"scopatz:master","ref":"master","sha":"ba3f1ede16b3a10636ee1d814ef2e588ca4615d6","user":{"login":"scopatz","id":320553,"avatar_url":"https://avatars.githubusercontent.com/u/320553?v=3","gravatar_id":"","url":"https://api.github.com/users/scopatz","html_url":"https://github.com/scopatz","followers_url":"https://api.github.com/users/scopatz/followers","following_url":"https://api.github.com/users/scopatz/following{/other_user}","gists_url":"https://api.github.com/users/scopatz/gists{/gist_id}","starred_url":"https://api.github.com/users/scopatz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scopatz/subscriptions","organizations_url":"https://api.github.com/users/scopatz/orgs","repos_url":"https://api.github.com/users/scopatz/repos","events_url":"https://api.github.com/users/scopatz/events{/privacy}","received_events_url":"https://api.github.com/users/scopatz/received_events","type":"User","site_admin":false},"repo":{"id":29620400,"name":"xonsh","full_name":"scopatz/xonsh","owner":{"login":"scopatz","id":320553,"avatar_url":"https://avatars.githubusercontent.com/u/320553?v=3","gravatar_id":"","url":"https://api.github.com/users/scopatz","html_url":"https://github.com/scopatz","followers_url":"https://api.github.com/users/scopatz/followers","following_url":"https://api.github.com/users/scopatz/following{/other_user}","gists_url":"https://api.github.com/users/scopatz/gists{/gist_id}","starred_url":"https://api.github.com/users/scopatz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scopatz/subscriptions","organizations_url":"https://api.github.com/users/scopatz/orgs","repos_url":"https://api.github.com/users/scopatz/repos","events_url":"https://api.github.com/users/scopatz/events{/privacy}","received_events_url":"https://api.github.com/users/scopatz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/scopatz/xonsh","description":"xonsh is a Python-ish, BASHwards-compatible shell.","fork":false,"url":"https://api.github.com/repos/scopatz/xonsh","forks_url":"https://api.github.com/repos/scopatz/xonsh/forks","keys_url":"https://api.github.com/repos/scopatz/xonsh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scopatz/xonsh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scopatz/xonsh/teams","hooks_url":"https://api.github.com/repos/scopatz/xonsh/hooks","issue_events_url":"https://api.github.com/repos/scopatz/xonsh/issues/events{/number}","events_url":"https://api.github.com/repos/scopatz/xonsh/events","assignees_url":"https://api.github.com/repos/scopatz/xonsh/assignees{/user}","branches_url":"https://api.github.com/repos/scopatz/xonsh/branches{/branch}","tags_url":"https://api.github.com/repos/scopatz/xonsh/tags","blobs_url":"https://api.github.com/repos/scopatz/xonsh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scopatz/xonsh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scopatz/xonsh/git/refs{/sha}","trees_url":"https://api.github.com/repos/scopatz/xonsh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scopatz/xonsh/statuses/{sha}","languages_url":"https://api.github.com/repos/scopatz/xonsh/languages","stargazers_url":"https://api.github.com/repos/scopatz/xonsh/stargazers","contributors_url":"https://api.github.com/repos/scopatz/xonsh/contributors","subscribers_url":"https://api.github.com/repos/scopatz/xonsh/subscribers","subscription_url":"https://api.github.com/repos/scopatz/xonsh/subscription","commits_url":"https://api.github.com/repos/scopatz/xonsh/commits{/sha}","git_commits_url":"https://api.github.com/repos/scopatz/xonsh/git/commits{/sha}","comments_url":"https://api.github.com/repos/scopatz/xonsh/comments{/number}","issue_comment_url":"https://api.github.com/repos/scopatz/xonsh/issues/comments{/number}","contents_url":"https://api.github.com/repos/scopatz/xonsh/contents/{+path}","compare_url":"https://api.github.com/repos/scopatz/xonsh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scopatz/xonsh/merges","archive_url":"https://api.github.com/repos/scopatz/xonsh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scopatz/xonsh/downloads","issues_url":"https://api.github.com/repos/scopatz/xonsh/issues{/number}","pulls_url":"https://api.github.com/repos/scopatz/xonsh/pulls{/number}","milestones_url":"https://api.github.com/repos/scopatz/xonsh/milestones{/number}","notifications_url":"https://api.github.com/repos/scopatz/xonsh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scopatz/xonsh/labels{/name}","releases_url":"https://api.github.com/repos/scopatz/xonsh/releases{/id}","created_at":"2015-01-21T22:05:27Z","updated_at":"2015-05-12T17:20:27Z","pushed_at":"2015-05-14T02:33:30Z","git_url":"git://github.com/scopatz/xonsh.git","ssh_url":"git@github.com:scopatz/xonsh.git","clone_url":"https://github.com/scopatz/xonsh.git","svn_url":"https://github.com/scopatz/xonsh","homepage":"http://xonsh.org","size":4967,"stargazers_count":371,"watchers_count":371,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":35,"mirror_url":null,"open_issues_count":34,"forks":35,"open_issues":34,"watchers":371,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scopatz/xonsh/pulls/228"},"html":{"href":"https://github.com/scopatz/xonsh/pull/228"},"issue":{"href":"https://api.github.com/repos/scopatz/xonsh/issues/228"},"comments":{"href":"https://api.github.com/repos/scopatz/xonsh/issues/228/comments"},"review_comments":{"href":"https://api.github.com/repos/scopatz/xonsh/pulls/228/comments"},"review_comment":{"href":"https://api.github.com/repos/scopatz/xonsh/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/scopatz/xonsh/pulls/228/commits"},"statuses":{"href":"https://api.github.com/repos/scopatz/xonsh/statuses/aefd19aacabb62b411f4d29bb93408dd68144a4a"}}}}