[sysadmin-bin: 113/168] git.py: Add get_project_description()



commit 8f54f3ea2e119c7c219608cc95931a6f9756dfb9
Author: Todd Zullinger <tmz pobox com>
Date:   Wed Jul 22 13:22:12 2009 -0400

    git.py: Add get_project_description()

 git.py |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/git.py b/git.py
index 2117f82..72adff1 100644
--- a/git.py
+++ b/git.py
@@ -191,4 +191,21 @@ def get_module_name():
 
     return projectshort
 
+# Return the project description or '' if it is 'Unnamed repository;'
+def get_project_description():
+    try:
+        git_dir = git.rev_parse(git_dir=True, _quiet=True)
+    except CalledProcessError:
+        die("GIT_DIR not set")
 
+    projectdesc = ''
+    description = os.path.join(git_dir, 'description')
+    if os.path.exists(description):
+        try:
+            projectdesc = open(description).read().strip()
+        except:
+            pass
+    if projectdesc.startswith('Unnamed repository;'):
+        projectdesc = ''
+
+    return projectdesc



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]