فهرست منبع

walle 2.0 alpha - 增加info.commit

walle 6 سال پیش
والد
کامیت
b8ff2f7f5d
1فایلهای تغییر یافته به همراه5 افزوده شده و 1 حذف شده
  1. 5 1
      walle/api/general.py

+ 5 - 1
walle/api/general.py

@@ -8,6 +8,7 @@
     :author: wushuiyong@walle-web.io
 """
 
+import os
 import platform
 
 from flask import abort
@@ -92,7 +93,10 @@ class GeneralAPI(SecurityResource):
         try:
             repo = Repo(current_app.config.get('PROJECT_ROOT'))
             branch = str(repo.active_branch)
-            commit = 'ba4ca13d'
+            heads = os.path.join(current_app.config.get('PROJECT_ROOT'), '.git/refs/heads/', branch)
+            commit = ''
+            with open(heads) as f:
+                commit = f.read().strip()[0:8]
         except Exception as e:
             branch, commit = ''