Skip to content

Instantly share code, notes, and snippets.

@avalanchy
Last active August 29, 2015 14:01
Show Gist options
  • Save avalanchy/0b815be8e5bfe8ecb149 to your computer and use it in GitHub Desktop.
Save avalanchy/0b815be8e5bfe8ecb149 to your computer and use it in GitHub Desktop.
GIT: Display branch url and check for PDB when pushing into remote repository. #python #git #git-hook
#!/usr/bin/python
import subprocess
import sys
def branch_url():
remote = sys.argv[2]
command = 'git branch --contains'
branch_name = subprocess.check_output(command, shell=True).strip(' *\n')
tree_url = remote.replace(':', '/') \
.replace('git@', 'https://') \
.replace('.git', '/tree/')
branch_url = tree_url + branch_name
print 'Branch URL:\n * ' + branch_url
def pdb_in_code():
command = 'grep -nIr --include=\\*.py pdb'
try:
output = subprocess.check_output(command, shell=True)
except subprocess.CalledProcessError:
pass
else:
print '!!! Pdb left in code'
print output.strip()
if __name__ == '__main__':
branch_url()
pdb_in_code()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment