def insertDeltas(commit, objectName, type, items, delta_type, el_type, el_subtype = None): for item in items: deployable = getDeployable(commit.branch, objectName, type, el_type, item, el_subtype) delta = Delta() delta.user_change = getLastChange(objectName, el_type, item) delta.object = deployable delta.commit = commit delta.delta_type = delta_type delta.save()
def insertDeltas(commit, objectName, type, items, delta_type, el_type, el_subtype=None): for item in items: deployable = getDeployable(commit.branch, objectName, type, el_type, item, el_subtype) delta = Delta() delta.user_change = getLastChange(objectName, el_type, item) delta.object = deployable delta.commit = commit delta.delta_type = delta_type delta.save()
def analyzeCommit(branch, commit): global documentCache global mapCache global working_branch global change_batch working_branch = branch logger.info("Analyzing commit %s" % commit.hash) documentCache = { } # do not want to accumulate this stuff over multiple iterations mapCache = {} change_batch = None # clean up deltas in case we are rerunning Delta.objects.filter(commit=commit).delete() TranslationDelta.objects.filter(commit=commit).delete() lhash = commit.prev_hash rhash = commit.hash ## # call "git diff" to get a list of changed files ## omap = getDiffNames(lhash, rhash) ## # load all changed files from each hash into a map for performance ## lFileCache = createFileCache(lhash, omap, branch.name) rFileCache = createFileCache(rhash, omap, branch.name) for otype, olist in omap.items(): logger.debug("Type: %s" % otype) if otype == 'objects': analyzeObjectChanges(olist, lFileCache, rFileCache, 'fields', commit) analyzeObjectChanges(olist, lFileCache, rFileCache, 'validationRules', commit) analyzeObjectChanges(olist, lFileCache, rFileCache, 'webLinks', commit) analyzeObjectChanges(olist, lFileCache, rFileCache, 'recordTypes', commit) analyzeRecordTypePicklistChanges(olist, lFileCache, rFileCache, commit) analyzeObjectChanges(olist, lFileCache, rFileCache, 'namedFilters', commit) analyzeObjectChanges(olist, lFileCache, rFileCache, 'listViews', commit) # misc single-node elements # analyzeObjectChanges(list, lFileCache, rFileCache, 'label', commit) # analyzeObjectChanges(list, lFileCache, rFileCache, 'nameField', commit, nameKey='label') # analyzeObjectChanges(list, lFileCache, rFileCache, 'pluralLabel', commit) # analyzeObjectChanges(list, lFileCache, rFileCache, 'searchLayouts', commit) # analyzeObjectChanges(list, lFileCache, rFileCache, 'sharingModel', commit) elif otype == 'translations': analyzeTranslationChanges(olist, lFileCache, rFileCache, commit) elif otype == 'workflows': analyzeWorkflowChanges(olist, lFileCache, rFileCache, 'alerts', commit) analyzeWorkflowChanges(olist, lFileCache, rFileCache, 'fieldUpdates', commit) analyzeWorkflowChanges(olist, lFileCache, rFileCache, 'rules', commit) analyzeWorkflowChanges(olist, lFileCache, rFileCache, 'tasks', commit) elif otype == 'objectTranslations': analyzeObjectTranslationChanges(olist, lFileCache, rFileCache, 'fields', commit) analyzeObjectTranslationChanges(olist, lFileCache, rFileCache, 'validationRules', commit) analyzeObjectTranslationChanges(olist, lFileCache, rFileCache, 'webLinks', commit) elif otype == 'labels': analyzeLabelChanges(olist, lFileCache, rFileCache, 'labels', commit) else: for listitem in olist: delta_type = None if lFileCache.has_key(listitem) and rFileCache.has_key( listitem) == False: delta_type = 'd' elif lFileCache.has_key(listitem) == False: delta_type = 'a' else: delta_type = 'u' delta = Delta() delta.object = getDeployable(branch, listitem, otype, None, None, None) delta.commit = commit delta.user_change = getLastChange(listitem, None, None) if delta.user_change is None: print '** Audit record not found for %s' % listitem else: #print 'audit record found!' pass delta.delta_type = delta_type delta.save() commit.status = 'c' commit.save()
def analyzeCommit(branch, commit): global documentCache global mapCache global working_branch global change_batch working_branch = branch logger.info("Analyzing commit %s" % commit.hash) documentCache = {} # do not want to accumulate this stuff over multiple iterations mapCache = {} change_batch = None # clean up deltas in case we are rerunning Delta.objects.filter(commit=commit).delete() TranslationDelta.objects.filter(commit=commit).delete() lhash = commit.prev_hash rhash = commit.hash ## # call "git diff" to get a list of changed files ## omap = getDiffNames(lhash, rhash) ## # load all changed files from each hash into a map for performance ## lFileCache = createFileCache(lhash, omap, branch.name) rFileCache = createFileCache(rhash, omap, branch.name) for otype,olist in omap.items(): logger.debug("Type: %s" % otype) if otype == 'objects': analyzeObjectChanges(olist, lFileCache, rFileCache, 'fields', commit) analyzeObjectChanges(olist, lFileCache, rFileCache, 'validationRules', commit) analyzeObjectChanges(olist, lFileCache, rFileCache, 'webLinks', commit) analyzeObjectChanges(olist, lFileCache, rFileCache, 'recordTypes', commit) analyzeRecordTypePicklistChanges(olist, lFileCache, rFileCache, commit) analyzeObjectChanges(olist, lFileCache, rFileCache, 'namedFilters', commit) analyzeObjectChanges(olist, lFileCache, rFileCache, 'listViews', commit) # misc single-node elements # analyzeObjectChanges(list, lFileCache, rFileCache, 'label', commit) # analyzeObjectChanges(list, lFileCache, rFileCache, 'nameField', commit, nameKey='label') # analyzeObjectChanges(list, lFileCache, rFileCache, 'pluralLabel', commit) # analyzeObjectChanges(list, lFileCache, rFileCache, 'searchLayouts', commit) # analyzeObjectChanges(list, lFileCache, rFileCache, 'sharingModel', commit) elif otype == 'translations': analyzeTranslationChanges(olist, lFileCache, rFileCache, commit) elif otype == 'workflows': analyzeWorkflowChanges(olist, lFileCache, rFileCache, 'alerts', commit) analyzeWorkflowChanges(olist, lFileCache, rFileCache, 'fieldUpdates', commit) analyzeWorkflowChanges(olist, lFileCache, rFileCache, 'rules', commit) analyzeWorkflowChanges(olist, lFileCache, rFileCache, 'tasks', commit) elif otype == 'objectTranslations': analyzeObjectTranslationChanges(olist, lFileCache, rFileCache, 'fields', commit) analyzeObjectTranslationChanges(olist, lFileCache, rFileCache, 'validationRules', commit) analyzeObjectTranslationChanges(olist, lFileCache, rFileCache, 'webLinks', commit) elif otype == 'labels': analyzeLabelChanges(olist, lFileCache, rFileCache, 'labels', commit) else: for listitem in olist: delta_type = None if lFileCache.has_key(listitem) and rFileCache.has_key(listitem) == False: delta_type = 'd' elif lFileCache.has_key(listitem) == False: delta_type = 'a' else: delta_type = 'u' delta = Delta() delta.object = getDeployable(branch, listitem, otype, None, None, None) delta.commit = commit delta.user_change = getLastChange(listitem, None, None) if delta.user_change is None: print '** Audit record not found for %s' % listitem else: #print 'audit record found!' pass delta.delta_type = delta_type delta.save() commit.status = 'c' commit.save()