Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_head_commit(self):
- with change_directory(self.get_config_dir() or os.getcwd()):
- stdout, stderr = run_shell_command('git log -1 --pretty=%B')
- stdout = stdout.rstrip('\n')
- pos = stdout.find('\n')
- shortlog = stdout[:pos] if pos != -1 else stdout
- magic_github_merge_commit_regex = re.compile(
- r'^Merge [0-9a-f]+ into [0-9a-f]+$|....')
- match = re.fullmatch(magic_github_merge_commit_regex, shortlog)
- if match and len(shortlog) == 92:
- command = 'git log --pretty=%P -n 1 ' + head_commit
- parent_commits = run_shell_command(command)
- sha_regex = re.compile(r'([0-9a-f]{40})')
- unmerged_commit_sha = re.findall(sha_regex, parent_commits)[1]
- command = ('git log -n 1 ' +
- str(unmerged_commit_sha) + ' --pretty=%B')
- return run_shell_command(command)
- else:
- return run_shell_command('git log -1 --pretty=%B')
Add Comment
Please, Sign In to add comment