-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGitUtils.py
30 lines (26 loc) · 990 Bytes
/
GitUtils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
'''
# Author: [email protected]
# Source: https://github.com/scarrillo/GitUtils-Sublime
# Version 1.0
# Date: 2012.10.25
'''
import sublime, sublime_plugin, os
class GitUtils(sublime_plugin.EventListener):
def on_query_context(self, view, key, operator, operand, match_all):
if key == "git_status":
self.doGit(view)
return True
return None
def doGit(self, view):
projFolders = view.window().folders()
for folder in projFolders:
#view.window().run_command('exec', {"cmd": ["git", "--git-dir="+str(folder)+"/.git", "--work-tree="+str(folder), "status"]} )
folderName = folder[folder.rfind('/')+1:]
print "Git Status: "+folderName
# Print git status
log = os.popen("git --git-dir="+ folder +"/.git --work-tree="+ folder + " status").readlines()
# Print current branch
#log = os.popen("git --git-dir="+str(folder)+"/.git --work-tree="+str(folder)+ " branch|grep \\*").readlines()
if len(log) != 0:
for line in log:
print line