def get_branch(dir_address, params=''): (status, output) = commands.getstatusoutput('cd ' + dir_address + ';git branch ' + params) if status == 0: return function.business_return('获取分支成功', 0, function.get_branch_list(output)) else: return function.business_return('获取分支失败', -701, [], output)
def log(dir_address, number=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 ' + dir_address + ';git log --pretty=format:"%h{|}%s{|}[%cd]{|}<%an>" ' + date_format + ' -' + str(number)) if status == 0: return function.business_return('获取版本成功', 0, function.get_version_list(output)) else: return function.business_return('获取版本失败', -706, [], output)
def fetch(dir_address, branch_name=''): (status, output) = commands.getstatusoutput('cd ' + dir_address + ';git fetch origin ' + branch_name) if status != 0: return function.business_return('同步远程分支失败', -703, [], output) return True
def clean(dir_address): (status, output) = commands.getstatusoutput('cd ' + dir_address + ';git checkout .;git clean -fd') if status != 0: return function.business_return('清除本地改动项失败', -702, [], output) return True
def reset(dir_address, version_name): (status, output) = commands.getstatusoutput('cd ' + dir_address + ';git reset --hard ' + version_name) if status != 0: return function.business_return('版本重置失败', -709, [], output) return True
def push(dir_address, branch_name): (status, output) = commands.getstatusoutput('cd ' + dir_address + ';git push origin ' + branch_name) if status != 0: return function.business_return('推送分支失败', -708, [], output) return True
def checkout(dir_address, branch_name): (status, output) = commands.getstatusoutput('cd ' + dir_address + ';git checkout ' + branch_name) if status != 0: return function.business_return('分支切换失败', -704, [], output) return True
def clone(dir_address, git_address): (status, output) = commands.getstatusoutput('cd ' + dir_address + ';git clone ' + git_address) if status != 0: return function.business_return('克隆失败', -700, [], output) return True
def branch(dir_address, branch_name): (status, output) = commands.getstatusoutput('cd ' + dir_address + ';git branch ' + branch_name) if status != 0: return function.business_return('创建分支失败', -707, [], output) return True