提交 ebaeb7b4 编写于 作者: G gongfuxiang

git版本处理

上级 f9462a73
......@@ -10,6 +10,7 @@
from django.http import HttpResponse
from django.conf import settings
import commands,re
try :
import json # python >= 2.6
except ImportError:
......@@ -21,6 +22,31 @@ reload(sys)
sys.setdefaultencoding('utf8')
# git版本号大小判断
# @author Devil
# @version 0.0.1
# @blog http://gong.gg/
# @date 2017-08-21
# @param [list] [版本号(如: [1,3,6])]
# @return [boolean] [系统版本大于参数版本True, 则False]
def git_version_determine_size(ver_list) :
if len(ver_list) <= 0 :
return False
(status, output) = commands.getstatusoutput('git --version')
if status == 0 :
re_list = re.compile(r'[1-9]\d*').findall(output)
re_count = len(re_list)
print re_list
if re_count > 0 :
for index in range(len(ver_list)) :
if index < re_count :
if int(re_list[index]) < int(ver_list[index]) :
return False
else :
return False
return True
# 获取项目临时操作地址
# @author Devil
# @version 0.0.1
......
......@@ -172,7 +172,11 @@ def get_version_list(request) :
return function.ajax_return_exit('git拉取分支代码失败', -13, [], output)
# 获取版本列表
(status, output) = commands.getstatusoutput('cd '+git_dir_address+';git log --pretty=format:"%h{|}%s{|}[%cd]{|}<%an>" --date=format:"%Y-%m-%d %H:%M:%S" -30')
if function.git_version_determine_size([2,4]) == True :
date_format = '--date=format:"%Y-%m-%d %H:%M:%S"'
else :
date_format = ''
(status, output) = commands.getstatusoutput('cd '+git_dir_address+';git log --pretty=format:"%h{|}%s{|}[%cd]{|}<%an>" '+date_format+' -30')
if status == 0 :
version_list = function.get_version_list(output)
if len(version_list) == 0 :
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册