def callback(args): """ commit_callback() -> bool runs custom commit hooks, returns True if everything ok, False if should abort. """ command = '' if '-a' in args or '--all' in args: command = 'git diff HEAD --name-status' else: command = 'git diff --cached --name-status' output = run_command(command) git_files = get_diffed_files(output['stdout']) return prompt_lint(git_files)
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)