01261d4795f16b3dc9a75660ed66969b04161cf1
- Author
- Robby Russell <robby@planetargon.com>
- Committer
- Robby Russell <robby@planetargon.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/plugins/git-prompt/gitstatus.py b/plugins/git-prompt/gitstatus.py
2index ee6fab9bd64a2201d47a66767fb4a40988f4aa87..ef894bff248e37b9175ee4002dc244dafc2cea68 100644
3--- a/plugins/git-prompt/gitstatus.py
4+++ b/plugins/git-prompt/gitstatus.py
5@@ -1,20 +1,30 @@
6 #!/usr/bin/env python
7 # -*- coding: UTF-8 -*-
8+from subprocess import Popen, PIPE
9+import re
10
11 # change those symbols to whatever you prefer
12-symbols = {'ahead of': '↑', 'behind': '↓', 'staged':'♦', 'changed':'‣', 'untracked':'…', 'clean':'⚡', 'unmerged':'≠', 'sha1':':'}
13-
14-from subprocess import Popen, PIPE
15+symbols = {
16+ 'ahead of': '↑',
17+ 'behind': '↓',
18+ 'staged': '♦',
19+ 'changed': '‣',
20+ 'untracked': '…',
21+ 'clean': '⚡',
22+ 'unmerged': '≠',
23+ 'sha1': ':'
24+}
25
26-output,error = Popen(['git','status'], stdout=PIPE, stderr=PIPE).communicate()
27+output, error = Popen(
28+ ['git', 'status'], stdout=PIPE, stderr=PIPE).communicate()
29
30 if error:
31- import sys
32- sys.exit(0)
33+ import sys
34+ sys.exit(0)
35 lines = output.splitlines()
36
37-import re
38-behead_re = re.compile(r"^# Your branch is (ahead of|behind) '(.*)' by (\d+) commit")
39+behead_re = re.compile(
40+ r"^# Your branch is (ahead of|behind) '(.*)' by (\d+) commit")
41 diverge_re = re.compile(r"^# and have (\d+) and (\d+) different")
42
43 status = ''
44@@ -23,46 +33,50 @@ changed = re.compile(r'^# Changed but not updated:$', re.MULTILINE)
45 untracked = re.compile(r'^# Untracked files:$', re.MULTILINE)
46 unmerged = re.compile(r'^# Unmerged paths:$', re.MULTILINE)
47
48+
49 def execute(*command):
50- out, err = Popen(stdout=PIPE, stderr=PIPE, *command).communicate()
51- if not err:
52- nb = len(out.splitlines())
53- else:
54- nb = '?'
55- return nb
56+ out, err = Popen(stdout=PIPE, stderr=PIPE, *command).communicate()
57+ if not err:
58+ nb = len(out.splitlines())
59+ else:
60+ nb = '?'
61+ return nb
62
63 if staged.search(output):
64- nb = execute(['git','diff','--staged','--name-only','--diff-filter=ACDMRT'])
65- status += '%s%s' % (symbols['staged'], nb)
66+ nb = execute(
67+ ['git', 'diff', '--staged', '--name-only', '--diff-filter=ACDMRT'])
68+ status += '%s%s' % (symbols['staged'], nb)
69 if unmerged.search(output):
70- nb = execute(['git','diff', '--staged','--name-only', '--diff-filter=U'])
71- status += '%s%s' % (symbols['unmerged'], nb)
72+ nb = execute(['git', 'diff', '--staged', '--name-only', '--diff-filter=U'])
73+ status += '%s%s' % (symbols['unmerged'], nb)
74 if changed.search(output):
75- nb = execute(['git','diff','--name-only', '--diff-filter=ACDMRT'])
76- status += '%s%s' % (symbols['changed'], nb)
77+ nb = execute(['git', 'diff', '--name-only', '--diff-filter=ACDMRT'])
78+ status += '%s%s' % (symbols['changed'], nb)
79 if untracked.search(output):
80-## nb = len(Popen(['git','ls-files','--others','--exclude-standard'],stdout=PIPE).communicate()[0].splitlines())
81-## status += "%s" % (symbols['untracked']*(nb//3 + 1), )
82- status += symbols['untracked']
83+ status += symbols['untracked']
84 if status == '':
85- status = symbols['clean']
86+ status = symbols['clean']
87
88 remote = ''
89
90 bline = lines[0]
91 if bline.find('Not currently on any branch') != -1:
92- branch = symbols['sha1']+ Popen(['git','rev-parse','--short','HEAD'], stdout=PIPE).communicate()[0][:-1]
93+ branch = symbols['sha1'] + Popen([
94+ 'git',
95+ 'rev-parse',
96+ '--short',
97+ 'HEAD'], stdout=PIPE).communicate()[0][:-1]
98 else:
99- branch = bline.split(' ')[3]
100- bstatusline = lines[1]
101- match = behead_re.match(bstatusline)
102- if match:
103- remote = symbols[match.groups()[0]]
104- remote += match.groups()[2]