예제 #1
0
def parseInfo(clStr):
    matched = re.search(
        'Change (\d+) by ([\w.-]+)@[-:.\w\d]+ on (\d{4}/\d{2}/\d{2}) (\d{2}:\d{2}:\d{2})',
        clStr)
    if (not matched):
        sys.stderr.write("change not found for {0}\n".format(clStr))
        return {}
    change = matched.group(1)
    committer = matched.group(2)
    date = matched.group(3)
    time = matched.group(4)

    # wcheung is the person who performs code line cutover. Skip all of those cls
    if "release" in committer or "wcheung" in committer:
        return {}

    rev = re.search('@rev ([\w.]+)@', clStr, re.IGNORECASE)
    if rev:
        reviewer = rev.group(1).lower()
    else:
        reviewer = 'none'
    gusId = ''
    gus = re.search('https://gus.my.salesforce.com/.*(a07[\w\d]+)', clStr)
    if not gus:
        gus = re.search('https://gus.lightning.force.com/.*(a07[\w\d]+)',
                        clStr)
    taskId = ''
    if not gus:
        task = re.search('https://gus.my.salesforce.com/.*(a0m[\w\d]+)', clStr)
        if not task:
            task = re.search('https://gus.lightning.force.com/.*(a0m[\w\d]+)',
                             clStr)
        if task:
            taskId = sfdcid.to15(task.group(1))
    if gus:
        gusId = sfdcid.to15(gus.group(1))
    javaFiles = re.findall('... (//.+java#[0-9]+)', clStr)
    return {
        "p4.change": change,
        "p4.committer": committer,
        "p4.reviewer": reviewer,
        "p4.date": date,
        "p4.time": time,
        "p4.gusid": gusId,
        "p4.gustaskid": taskId,
        "p4.filecount": len(javaFiles)
    }
예제 #2
0
파일: gus.py 프로젝트: fmedio-sfdc/code-eye
def assignRecordTypes(fileinfos, idsToRecordTypes):
    for fileinfo in fileinfos:
        if ('p4.gusid' in fileinfo):
            gusid = sfdcid.to15(fileinfo['p4.gusid'])
            if (gusid in idsToRecordTypes):
                if (idsToRecordTypes[gusid] != 'Integrate'):
                    fileinfo['gus.worktype'] = idsToRecordTypes[gusid]
                else:
                    sys.stderr.write("integration: skipping: {0}\n".format(
                        fileinfo['filename']))
            else:
                sys.stderr.write(
                    "no gus record type: skipping: {0}\n".format(gusid))
        elif ('filename' in fileinfo):
            sys.stderr.write("no gusid: skipping: {0}\n".format(
                fileinfo['filename']))
예제 #3
0
        print(json.dumps(info, separators=(',', ':')))


sessionId = os.environ.get('GUS_SESSION_ID')
if (not sessionId):
    sys.stderr.write("Error: Expected environment variable: GUS_SESSION_ID\n")
    exit()
#sys.stderr.write("SessionId: {0}".format(sessionId))

maxQueryCount = 200
count = 0
gusIdCache = set()
fileinfos = []
for line in fileinput.input():
    onefile = json.loads(line)
    gusId = sfdcid.to15(onefile['p4.gusid'])
    if (not gusId):
        # there's no work id, check for a task id
        taskId = sfdcid.to15(onefile['p4.gustaskid'])
        if (not taskId):
            sys.stderr.write(
                "no well formed gus work item or task found: {0}, workid='{1}', taskid='{2}'\n"
                .format(onefile['filename'], onefile['p4.gusid'],
                        onefile['p4.gustaskid']))
        else:
            sys.stderr.write("TODO: retrieve gus work item from gus task id")
    else:
        if (not gusId in gusIdCache):
            if count >= maxQueryCount:
                queryAndAssign(fileinfos, gusIdCache, sessionId)
예제 #4
0
파일: gus.py 프로젝트: fmedio-sfdc/code-eye
def queryToIds(gusJson):
    idsToRecordTypes = {}
    for gusRecord in gusJson['records']:
        idsToRecordTypes[sfdcid.to15(gusRecord['Id'])] = gusRecord['Type__c']

    return idsToRecordTypes
예제 #5
0
 def test_15_digit_gusId(self):
     self.assertEqual(sfdcid.to15('123456789012345'), '123456789012345')