def git_project_url(path): # remote urls look like: [email protected]:mrj0/easy-cheese.git # or possibly: https://github.com/mrj0/easy-cheese.git # or https://github.com/mrj0/easy-cheese result = shell('git remote -v show') for line in result.stdout.split('\n'): name, remote, _ = re.split(r'\s', line.strip()) print('remote', remote) if remote.startswith('git@github'): _host, path = remote.split(':') path = path.replace('.git', '') organization, project = os.path.split(path) return 'https://github.com/{}/{}'.format(organization, project) if remote.startswith('https://github'): path = urlsplit(remote).path path = path.replace('.git', '') organization, project = os.path.split(path) return 'https://github.com/{}/{}'.format(organization.lstrip('/'), project)
def git_author_email(path): return shell('git log -1 --pretty=format:%ae').stdout.strip()
def git_author_name(path): return shell('git log -1 --pretty=format:%an').stdout.strip()