def getRevisionDifference(repository, prevRevision, revision): # Init git wrap gitWrap = GitWrap(repository, config.REPOSITORIES) gitWrap.init() # Get commit changes patch = gitWrap.get_commit_diff(prevRevision, revision) # Parse patch return ValidationResult(Parser.run(patch).getVars())
def predictForPatchFile(project_id, patchFile): # Init validation validation = ValidationResult([]); # Decode patch file patchFileContent = patchFile.read() result = chardet.detect(patchFileContent) # Get changes of patch file changes = Parser.run(patchFileContent.decode(encoding=result['encoding'])).getVars() # Make prediction return ModelService.predict(project_id, changes)