def lint(files): """ lint(files: [str]) -> boolean Runs the configured linter for each file in files, and returns True if no linter issues are found, False otherwise. """ config = get_config() try: lint_engine = config['linter'] except KeyError: print_colored('No linter configured for this project.', color='yellow') return True print_colored('Running Linter...', color='none') err_codes = 0 for filename in files: for lint_rule in lint_engine: regex = lint_rule['pattern'] if re.match(regex, filename): linter = lint_rule['command'] cmd = '%s %s' % (linter, filename) err_codes += call_command(cmd) break return err_codes == 0
def callback(args): """ push_callback() -> bool runs custom push hooks, returns True if everythink ok, False if should abort. """ try: remote_name = args[2] branch_name = args[3].split(':')[1] except IndexError: print_colored('Raptor doesnt support pushing without '+\ 'arguments (yet). Sadface.', color='red') return False # fetch the remote so we have the most up-to-date information call_command('git fetch %s' % (remote_name, )) output = run_command('git diff HEAD %s/%s --name-status' %\ (remote_name, branch_name)) stdout = output['stdout'].strip() stderr = output['stderr'].strip() if stderr.startswith('fatal'): print 'remote has no branch "%s"' % (branch_name,), \ '- falling back to master' output = run_command('git diff HEAD %s/master --name-status' %\ (remote_name, )) stdout = output['stdout'].strip() stderr = output['stderr'].strip() if stderr.startswith('fatal'): print "couldn't push to master. bailing." return False git_files = get_diffed_files(stdout) return prompt_lint(git_files)