Skip to content

Instantly share code, notes, and snippets.

@sangheestyle
Last active August 29, 2015 14:01
Show Gist options
  • Save sangheestyle/3ff8803a088340e3bc1f to your computer and use it in GitHub Desktop.
Save sangheestyle/3ff8803a088340e3bc1f to your computer and use it in GitHub Desktop.
Analyzing developers' commit relationship

This scratch is for analyzing developers' relationship by analyzing commits such as same chunk modification.

@sangheestyle
Copy link
Author

@sangheestyle
Copy link
Author

@sangheestyle
Copy link
Author

This code can do logging commits with variable options and placeholders. Especially, each commit in commites includes information such as commit ID(%h), author email(%ae), changeset(--numstat)

log_output = check_output(["git", "log", "--pretty=format:%h\t%ae", "--numstat", "--no-merges", "--since='1 years ago'"])
commits = [x.strip() for x in log_output.split('\n\n')]
print len(commits)

For example, the last commit in commits was written by [email protected] and includes 1 add and 1 delete line which mostly means that 1 line is modified. Also the modified file is services/java/com/android/server/MountService.java

In [37]: commits[-1]
Out[37]: 'f503c8f\[email protected]\n1\t1\tservices/java/com/android/server/MountService.java'

Reference: https://www.kernel.org/pub/software/scm/git/docs/git-log.html

@sangheestyle
Copy link
Author

Some exceptions

In [44]: print commits[-7]
9994769 [email protected]
38  35  docs/html/develop/index.jd
-   -   docs/html/images/home/io-gdl-2013.png
7   6   docs/html/index.jd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment