Example #1
0
def update_remote(requestInfo):
    id = requestInfo['projectId']
    remote = requestInfo['remote']+","
    branch = requestInfo['branch']
    p = Project.objects.get(id=id)
    p.remote = remote
    p.save()
    Git.createBranch(branch,'master',0,remote)
    InsertInfo.insert(branch,remote,id,p.status)
Example #2
0
def createNewBranch(requestInfo,user):
    '''
    创建新分支
    '''
    projectId = int(requestInfo['projectId'] or 0) if 'projectId' in requestInfo else 0
    branch = requestInfo['branch_name'] if 'branch_name' in requestInfo else ''
    branch_type = requestInfo['branch_type'] if 'branch_type' in requestInfo else ''
    nowNum=branch[-1]
    try:
        num=int(nowNum)
        num = num + 1
        index=branch.find('-',8)
        branch_start=branch[0:index]
        branch_end=branch[index:40]
        branch_end = branch_end.replace(str(nowNum), str(num))
        branch_name =branch_start+branch_end
    except:
        num=1
        branch_name = branch+str(num)
    pb = Branch.objects.get(project=projectId)
    pb.name = branch_name
    pb.save()
    pl = Project.objects.get(id=projectId)
    pl.status = 3

    pl.save();
    remote = ""
    app_info = ""
    arr_branch_old = []
    arr_branch = []
    arr_remote = []
    for app in branch_type.split(','):

        if app == "member":
            app = "anjuke"
        if "_usersite" in app and "api_usersite" != app:
            app = "anjuke_usersite"
        if app+"," not in remote:
            remote=remote+app+","
            branch_name1=branch+"-"+app
            branch_remote = BranchInfo.objects.filter(branch_name = branch_name1)[0]
            arr_branch.append(branch_name+"-"+app)
            arr_branch_old.append(branch_name1)
            arr_remote.append(branch_remote.create_version)
#    branch_remote = BranchInfo.objects.filter(plist_id = projectId)
#    for b in branch_remote:
#        b.gc = 0

#        b.create_version = ''
#        b.save()
    InsertInfo.insert(branch_name,remote,projectId,pl.status)
    for i in range(len(arr_branch)):
        print (arr_branch[i])
        print (arr_remote[i])
        print (arr_branch_old[i])
        branch_remote = BranchInfo.objects.filter(branch_name = arr_branch[i])[0]
        branch_remote.create_version = arr_remote[i]
        branch_remote.gc = 1
        branch_remote.save()
        branch_remote = BranchInfo.objects.filter(branch_name = arr_branch_old[i])[0]
        branch_remote.create_version = ''
        branch_remote.gc = 0
        branch_remote.save()
    
    Git.createNewBranch(branch_name,remote,projectId,user)
    return 'OK'