Created
October 24, 2013 09:02
-
-
Save mironal/7133709 to your computer and use it in GitHub Desktop.
出っ出ーーwwwww 全然コーディングしてない人を晒し上げ奴wwwwwwwwwwwwwwwww
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
#!/bin/bash | |
# | |
# The MIT License (MIT) | |
# Copyright (c) 2013 mironal | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining | |
# a copy of this software and associated documentation files (the | |
# "Software"), to deal in the Software without restriction, including | |
# without limitation the rights to use, copy, modify, merge, publish, | |
# distribute, sublicense, and/or sell copies of the Software, and to | |
# permit persons to whom the Software is furnished to do so, subject to | |
# the following conditions: | |
# | |
# The above copyright notice and this permission notice shall be | |
# included in all copies or substantial portions of the Software. | |
# | |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | |
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | |
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | |
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
# | |
# .hと.mに限って誰が何行書いたかを計測するアレヽ(•̀ω•́ )ゝ✧ | |
TMP_GIT_BLAME_FILE=/tmp/code-lines.tmpfile | |
TMP_USERLIST_FILE=/tmp/code-lines-userlist.tmpfile | |
trap 'rm -f "$TMP_GIT_BLAME_FILE" && rm -f "$TMP_USERLIST_FILE" && exit 1' 1 2 3 15 | |
# ユーザ一覧 | |
git log --pretty=format:"%an" | sort | uniq > "$TMP_USERLIST_FILE" | |
# 最も長いユーザ名の長さ + 1を作る | |
NAME_SPACE_LENGTH=`awk '{ if (length($0) > max) max = length($0) } | |
END { print (max + 1) }' "$TMP_USERLIST_FILE"` | |
# 計測対象のファイル数を表示 | |
echo "`git ls-files "$1" | wc -l | sed -e 's/[^0-9]//g'` files found." | |
echo | |
# blame (^^ゞ | |
# egrep のところで拡張子を指定しているので注意!! | |
git ls-files "$1" | egrep "\.[hm]$" | xargs -n1 git --no-pager blame --line-porcelain -f -w | grep "^author " > "$TMP_GIT_BLAME_FILE" | |
# ユーザ毎に表示 | |
while read USER_NAME; do | |
NUM_OF_LINES=`cat "$TMP_GIT_BLAME_FILE" | grep "${USER_NAME}" | wc -l | sed -e 's/[^0-9]//g'` | |
printf "%-${NAME_SPACE_LENGTH}s\t%-10s\n" "$USER_NAME" "$NUM_OF_LINES" | |
done < $TMP_USERLIST_FILE | |
rm -f $TMP_GIT_BLAME_FILE | |
rm -f $TMP_USERLIST_FILE | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment