From c9f90c03467eff410cb5e275da38f0e1e48589ae Mon Sep 17 00:00:00 2001 From: arzzen Date: Sun, 15 Jan 2017 18:31:22 +0100 Subject: [PATCH] init --- CONTRIBUTING.md | 25 ++++++++++++ Makefile | 16 ++++++++ README.md | 64 ++++++++++++++++++++++++++++- git-fast-stats.sh | 100 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 203 insertions(+), 2 deletions(-) create mode 100644 CONTRIBUTING.md create mode 100644 Makefile create mode 100644 git-fast-stats.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..9f43868 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,25 @@ +Contributing +============ + +Want to contribute? Great! First, read this page. + +# Code reviews +All submissions, including submissions by project members, require review. We +use Github pull requests for this purpose. + +# Some tips for good pull requests: +* Use our code + When in doubt, try to stay true to the existing code of the project. +* Write a descriptive commit message. What problem are you solving and what + are the consequences? Where and what did you test? Some good tips: + [here](http://robots.thoughtbot.com/5-useful-tips-for-a-better-commit-message) + and [here](https://www.kernel.org/doc/Documentation/SubmittingPatches). +* If your PR consists of multiple commits which are successive improvements / + fixes to your first commit, consider squashing them into a single commit + (`git rebase -i`) such that your PR is a single commit on top of the current + HEAD. This make reviewing the code so much easier, and our history more + readable. + +# Formatting + +This documentation is written using standard [markdown syntax](https://help.github.com/articles/markdown-basics/). Please submit your changes using the same syntax. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6ada369 --- /dev/null +++ b/Makefile @@ -0,0 +1,16 @@ +prefix=/usr/local + +# files that need mode 755 +EXEC_FILES=git-quick-stats + +all: + @echo "usage: make install" + @echo " make uninstall" + +install: + install -m 0755 $(EXEC_FILES) $(prefix)/bin + +uninstall: + test -d $(prefix)/bin && \ + cd $(prefix)/bin && \ +rm -f $(EXEC_FILES) \ No newline at end of file diff --git a/README.md b/README.md index 1a4a2b0..e6cf160 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,62 @@ -# git-quick-stats -Git statistics all in one + +## GIT quick statistics + +> Git-quick-stats is a simple and efficient way to access various statistics in git repository. +> (dependence `apt install dialog`) +Want to contribute? Great! First, [read this page][]. + +## Usage + +``` +git-quick-stats +``` + +## Example + +![screenshot_example](https://cloud.githubusercontent.com/assets/6382002/21964569/946c0042-db4e-11e6-8a2a-aa20f0b71b04.png) + + +## Installation + +``` +$ git clone https://github.com/arzzen/git-quick-stats.git && cd git-quick-stats +$ sudo make install +``` + +For uninstalling, open up the cloned directory and run + +``` +sudo make uninstall +``` + +## Contribution + +Want to contribute? Great! First, read this page. + +#### Code reviews +All submissions, including submissions by project members, require review. +We use Github pull requests for this purpose. + +#### Some tips for good pull requests: +* Use our code + When in doubt, try to stay true to the existing code of the project. +* Write a descriptive commit message. What problem are you solving and what + are the consequences? Where and what did you test? Some good tips: + [here](http://robots.thoughtbot.com/5-useful-tips-for-a-better-commit-message) + and [here](https://www.kernel.org/doc/Documentation/SubmittingPatches). +* If your PR consists of multiple commits which are successive improvements / + fixes to your first commit, consider squashing them into a single commit + (`git rebase -i`) such that your PR is a single commit on top of the current + HEAD. This make reviewing the code so much easier, and our history more + readable. + +#### Formatting + +This documentation is written using standard [markdown syntax](https://help.github.com/articles/markdown-basics/). Please submit your changes using the same syntax. + +## Licensing +MIT see [LICENSE][] for the full license text. + + [read this page]: http://github.com/arzzen/git-quick-stats/blob/master/CONTRIBUTING.md + [landing page]: http://arzzen.github.io/git-quick-stats + [LICENSE]: https://github.com/arzzen/git-quick-stats/blob/master/LICENSE.txt \ No newline at end of file diff --git a/git-fast-stats.sh b/git-fast-stats.sh new file mode 100644 index 0000000..999bcb0 --- /dev/null +++ b/git-fast-stats.sh @@ -0,0 +1,100 @@ +#!/bin/bash + +HEIGHT=15 +WIDTH=50 +CHOICE_HEIGHT=10 +BACKTITLE="Various statistics in git repository - all in one place" +TITLE="GIT's various statistics" +MENU="Choose one of the following options:" + +OPTIONS=( + 1 "Suggest code reviewers" + 2 "Detailed stats per author" + 3 "Commits per day" + 4 "Commits per author" + 5 "Get own stats for the day" + 6 "List all contributors" + 7 "List of all the branches by date" + 8 "Get text changelogs" +) + +CHOICE=$(dialog --clear \ + --backtitle "$BACKTITLE" \ + --title "$TITLE" \ + --menu "$MENU" \ + $HEIGHT $WIDTH $CHOICE_HEIGHT \ + "${OPTIONS[@]}" \ + 2>&1 >/dev/tty) + +function detailedGitStats() +{ + git log --numstat | awk ' + function printStats(author) { + printf "%s:\n", author + printf " insertions: %d (%.0f%%)\n", more[author], (more[author] / more["total"] * 100) + printf " deletions: %d (%.0f%%)\n", less[author], (less[author] / less["total"] * 100) + printf " files: %d (%.0f%%)\n", file[author], (file[author] / file["total"] * 100) + printf " commits: %d (%.0f%%)\n", commits[author], (commits[author] / commits["total"] * 100) + } + + /^Author:/ { + author = $2 " " $3 + commits[author] += 1 + commits["total"] += 1 + } + + /^[0-9]/ { + more[author] += $1 + less[author] += $2 + file[author] += 1 + + more["total"] += $1 + less["total"] += $2 + file["total"] += 1 + } + + END { + for (author in commits) { + if (author != "total") { + printStats(author) + } + } + printStats("total") + }' +} + +clear +case $CHOICE in + 1) + echo "Suggest code reviewers based on git history." + git log --pretty=%an $* | head -n 100 | sort | uniq -c | sort -nr + ;; + 2) + echo "Detailed stats per author, including contribution to the total change" + detailedGitStats + ;; + 3) + echo "Git commits per day:" + git log --date=short --format='%ad' | sort | uniq -c + ;; + 4) + echo "Git commits per author:" + git shortlog -s -n + ;; + 5) + echo "Get own stats for the day:" + git diff --shortstat "@{0 day ago}" + ;; + 6) + echo "List repository contributors by author name (sorted by name):" + git log --format='%aN' | sort -u + ;; + 7) + echo "List of all the branches, ordered by most recent commits:" + git for-each-ref --sort=committerdate refs/heads/ --format='[%(authordate:relative)] %(color:blue) %(authorname) %(color:yellow)%(refname:short)%(color:reset)' + ;; + 8) + echo "Generate git changelogs:" + git log --pretty=format:"- %s%n%b" --since="$(git show -s --format=%ad `git rev-list --tags --max-count=1`)" + ;; +esac