def passthrough(options): """ git_passthrough() -> None runs git with options passed to raptor. """ cmd = 'git %s' % (' '.join(options)) run_command(cmd, ignore_output=True)
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)
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 get_aliases(): """ get_aliases() -> dict returns a dictionary containing git command aliases, where the keys are the aliases and the values are the corresponding actual command names """ output = run_command('git config --get-regexp alias*') aliases = output['stdout'].split('\n') result = {} for alias in aliases: if len(alias) == 0: continue alias_name = alias.split()[0][6:] alias_value = alias.split(' ', 1)[1] result[alias_name] = alias_value return result