Guest User

Untitled

a guest
Jul 17th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. import subprocess
  3.  
  4.  
  5. def main():
  6. shortlog = subprocess.check_output([
  7. 'git',
  8. 'shortlog',
  9. '--summary',
  10. ]).decode()
  11. authors = []
  12. for log_line in shortlog.splitlines():
  13. authors.append(log_line.split(None, 1)[1])
  14. first_commits_by_author = []
  15. for author in authors:
  16. commits = subprocess.check_output([
  17. 'git',
  18. 'log',
  19. f'--author={author}',
  20. '--reverse',
  21. "--pretty=format:%at,%ad,%an",
  22. '--date=short',
  23. ]).decode()
  24. first_commits_by_author.append(commits.splitlines()[0].split(','))
  25. header = 'timestamp,date,author,contributor_number'
  26. data = []
  27. sorted_committers = sorted(first_commits_by_author, key=lambda x: x[0])
  28. for contributer_count_zero_indexed, x in enumerate(sorted_committers):
  29. contributer_count = contributer_count_zero_indexed + 1
  30. x.append(str(contributer_count))
  31. data.append(','.join(x))
  32. print(header)
  33. for datum in data:
  34. print(datum)
  35.  
  36.  
  37. if __name__ == '__main__':
  38. main()
Add Comment
Please, Sign In to add comment