Skip to content

Instantly share code, notes, and snippets.

@williamespindola
Last active June 19, 2018 10:40
Show Gist options
  • Save williamespindola/b38d67dd08247a32812787db31ad8e34 to your computer and use it in GitHub Desktop.
Save williamespindola/b38d67dd08247a32812787db31ad8e34 to your computer and use it in GitHub Desktop.
Example: list-authors name/of/file
#!/usr/bin/env bash
declare -r FILENAME=${1}
declare -r TEMPORATY=$(mktemp)
exec 3<> ${TEMPORATY}
{
echo "/**"
git blame --line-porcelain "${FILENAME}" |
egrep '^author' |
tr '\n' ' ' |
sed 's,author ,\n,g' |
sed -E 's,^(.+) author-mail (<[^>]+>).+$,\1 \2,g' |
egrep -v '^$' |
sed -E "s,Not Committed Yet <not.committed.yet>,$(git config user.name) <$(git config user.email)>,g" |
sed 's,^, * @author ,' |
sort -u
echo " */"
} 1>&3
declare CLASS_DOCBLOCK=$(tr '\n' '#' < ${TEMPORATY} | sed 's,#,\\n,g')
sed -Ei "s%^(final )?class%${CLASS_DOCBLOCK}final class%g" ${FILENAME}
@williamespindola
Copy link
Author

Se você esta no windows ou mac sem gnu coreutils você pode usar este script abaixo e terá que copiar na mão

#!/usr/bin/env bash

git blame --line-porcelain ${1} |
    egrep '^author |^author-mail' |
    sed 's,author-mail ,,g' |
    tr '\n' ' ' |
    tr '/>' '\n' |
    sort |
    egrep -v '^$' |
    uniq |
    sort -rn |
    sed -E 's, *author, * @author,g'
    sort 

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