diff options
author | Sayamindu Dasgupta <sayamindu@gmail.com> | 2010-01-08 22:45:33 (GMT) |
---|---|---|
committer | Sayamindu Dasgupta <sayamindu@gmail.com> | 2010-01-08 22:45:33 (GMT) |
commit | b7dbad4e48e8c6779e05a56cae5a83b3c3bfec40 (patch) | |
tree | d01cad2a5add30a52cc8fd581adb0dc7e0260286 /Pootle-2.0.0/local_apps/pootle_app/views/language/item_dict.py | |
parent | 1790e434a8a1e32132443ad5868598cb3a619c4e (diff) |
Show a commit status column for PO files
Diffstat (limited to 'Pootle-2.0.0/local_apps/pootle_app/views/language/item_dict.py')
-rw-r--r-- | Pootle-2.0.0/local_apps/pootle_app/views/language/item_dict.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Pootle-2.0.0/local_apps/pootle_app/views/language/item_dict.py b/Pootle-2.0.0/local_apps/pootle_app/views/language/item_dict.py index bb46167..5f72841 100644 --- a/Pootle-2.0.0/local_apps/pootle_app/views/language/item_dict.py +++ b/Pootle-2.0.0/local_apps/pootle_app/views/language/item_dict.py @@ -29,6 +29,9 @@ from pootle_app.models.permissions import check_permission from pootle_store.models import Store from pootle_app.views.language import dispatch +from pootle_store.util import absolute_real_path + +import os, subprocess ################################################################################ def get_item_summary(request, quick_stats, path_obj): @@ -298,4 +301,30 @@ def make_store_item(request, store, links_required=None): item.update({ 'icon': 'file', 'isfile': True }) + item.update({ + 'needscommit' : get_commit_status(absolute_real_path(store.real_path)) }) return item + +def get_commit_status(path): + ''' Returns True if a commit needs to be made ''' + #FIXME: This should be made a part of the translate-toolkit + directory = os.path.realpath(path) + gitdir = None + while directory != '/': + directory = os.path.dirname(directory) + gitdir = os.path.join(directory, '.git') + if os.path.exists(gitdir): + cmd = ['git', 'diff', '--shortstat', path] + proc = subprocess.Popen(args = cmd, + stdout = subprocess.PIPE, + stderr = subprocess.PIPE, + stdin = subprocess.PIPE, + cwd = directory) + (gitoutput, giterror) = proc.communicate() + if len(gitoutput) > 0: + return True + else: + return False + + return False # Doesn't seem to be a git repo, so return False + |