Last active
October 24, 2020 00:20
-
-
Save jhonatanmsc/d9102eeefcca02a4f46d82a3ddf0ea5b to your computer and use it in GitHub Desktop.
detalha os commits do dia (**so funciona se seus commits seguirem o padrão "tag: commit")
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import subprocess | |
| from datetime import date | |
| def main(): | |
| help = "detalha os commits do dia" | |
| print("### %s ###" % help) | |
| author = input('Git username: ') | |
| cwd = input('Project source: ') | |
| command = f'cd {cwd} && git log --pretty=format:"%s" --author="{author}" --since="6am"' | |
| raw_last_commits = subprocess.check_output(command, shell=True).decode('utf-8').strip() | |
| commits = raw_last_commits.split('\n') | |
| tags = {commit.split(': ')[0]: [] for commit in commits if 'Merge branch' not in commit} | |
| for commit in commits: | |
| if 'Merge branch' not in commit: | |
| tags[commit.split(': ')[0]].append(commit.split(': ')[1]) | |
| descr = "Resumo do dia:\n" | |
| for tag in tags: | |
| descr += " %s:\n" % tag | |
| for commit in tags[tag]: | |
| descr += " - %s\n" % commit | |
| descr += "\n" | |
| print("--- commits %s ---\n" % str(date.today())) | |
| print(descr) | |
| if __name__ == '__main__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment