Skip to content

Commit

Permalink
Fixed aliased calls. fixes #3
Browse files Browse the repository at this point in the history
  • Loading branch information
MitMaro committed Apr 11, 2011
1 parent 6d97a78 commit 7d6c654
Showing 1 changed file with 39 additions and 30 deletions.
69 changes: 39 additions & 30 deletions git-achievements
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,14 @@ function git_achievements_command

function log_action
{
echo "$@" >> "${ACTIONLOGFILE}"
local expansion=$(unalias_command "$1")

if [[ $expansion ]] ; then
shift
echo "$expansion $@" >> "${ACTIONLOGFILE}"
else
echo "$@" >> "${ACTIONLOGFILE}"
fi
echo -n "Date: " >> "${ACTIONLOGFILE}"
date >> "${ACTIONLOGFILE}"
}
Expand Down Expand Up @@ -159,12 +166,14 @@ function check_for_achievements
if [[ $expansion ]] ; then
# not a real inventor
unlock_achievement "Garage Inventor" "Used a custom alias for a Git command"
command="$expansion"

# get actual command, removing any additional parameters from the command
command=$(echo "$expansion" | awk '{ print $1; }')
fi

case $command in
add )
count_unlock_achievement "Stone Mason" "Added files to the index area for inclusion in the next commit with git add" "$1"
count_unlock_achievement "Stone Mason" "Added files to the index area for inclusion in the next commit with git add" "$command"
case $2 in
*.gitignore )
unlock_achievement "Caretaker" "Added a .gitignore file to a repository."
Expand All @@ -175,19 +184,19 @@ function check_for_achievements
esac
;;
am )
count_unlock_achievement "Messenger" "Applied a patch using git am." "$1"
count_unlock_achievement "Messenger" "Applied a patch using git am." "$command"
;;
bisect )
count_unlock_achievement "Hunter" "Used git bisect to perform a binary search to find which change introduced a bug." "$1"
count_unlock_achievement "Hunter" "Used git bisect to perform a binary search to find which change introduced a bug." "$command"
;;
blame )
count_unlock_achievement "Investigator" "Used git blame to annotate a file with information about how each line changed." "$1"
count_unlock_achievement "Investigator" "Used git blame to annotate a file with information about how each line changed." "$command"
;;
bundle )
count_unlock_achievement "Delivery Boy" "Move objects and refs by archive with git bundle." "$1"
count_unlock_achievement "Delivery Boy" "Move objects and refs by archive with git bundle." "$command"
;;
cherry-pick )
unlock_achievement "Cherry Picker" "Used git cherry-pick to add a sha from another branch into the current branch." "$1"
unlock_achievement "Cherry Picker" "Used git cherry-pick to add a sha from another branch into the current branch." "$command"
;;
checkout )
case $2 in
Expand All @@ -197,12 +206,12 @@ function check_for_achievements
esac
;;
clean )
count_unlock_achievement "Cleaning lady" "Remove untracked files from the working tree with git clean" "$1"
count_unlock_achievement "Cleaning lady" "Remove untracked files from the working tree with git clean" "$command"
;;
commit )
count_unlock_achievement "Author" "Made 2^Level commits using git commit." "$1"
count_unlock_achievement "Author" "Made 2^Level commits using git commit." "$command"
if [ "`git log --pretty=oneline | wc -l`" -eq "1" ] ; then
unlock_achievement "Let there be light" "Commit without a parent." "$1"
unlock_achievement "Let there be light" "Commit without a parent." "$command"
fi
case $2 in
--amend )
Expand Down Expand Up @@ -230,31 +239,31 @@ function check_for_achievements

;;
fetch )
count_unlock_achievement "Collector" "Fetches named heads or tags from another repository with git fetch" "$1"
count_unlock_achievement "Collector" "Fetches named heads or tags from another repository with git fetch" "$command"
;;
filter-branch )
count_unlock_achievement "Tree Trimmer" "Rewrite branches with git filter-branch" "$1"
count_unlock_achievement "Tree Trimmer" "Rewrite branches with git filter-branch" "$command"
;;
format-patch )
count_unlock_achievement "Archivist" "Prepare each commit with its patch in one file per commit with git format-patch" "$1"
count_unlock_achievement "Archivist" "Prepare each commit with its patch in one file per commit with git format-patch" "$command"
;;
gc )
count_unlock_achievement "Chimney Sweeper" "Used git gc to run a number of housekeeping tasks on the current repository." "$1"
count_unlock_achievement "Chimney Sweeper" "Used git gc to run a number of housekeeping tasks on the current repository." "$command"
;;
grep )
count_unlock_achievement "Fisherman" "Look for specified patterns in the current repository with git grep." "$1"
count_unlock_achievement "Fisherman" "Look for specified patterns in the current repository with git grep." "$command"
;;
imap-send )
count_unlock_achievement "Postman" "Send a collection of patches from stdin to an IMAP folder with git imap-send" "$1"
count_unlock_achievement "Postman" "Send a collection of patches from stdin to an IMAP folder with git imap-send" "$command"
;;
init )
count_unlock_achievement "Architect" "Created a new repository with git init." "$1"
count_unlock_achievement "Architect" "Created a new repository with git init." "$command"
;;
instaweb )
count_unlock_achievement "Web Designer" "Instantly browse your working repository in gitweb with git instaweb" "$1"
count_unlock_achievement "Web Designer" "Instantly browse your working repository in gitweb with git instaweb" "$command"
;;
log )
count_unlock_achievement "Historian" "Investigate the commit log using git log." "$1"
count_unlock_achievement "Historian" "Investigate the commit log using git log." "$command"
case $2 in
-p* )
unlock_achievement "Dentist" "Extracted patches using git log -p."
Expand All @@ -265,15 +274,15 @@ function check_for_achievements
esac
;;
merge )
count_unlock_achievement "Banker" "Join two or more development histories together with git merge." "$1"
count_unlock_achievement "Banker" "Join two or more development histories together with git merge." "$command"
;;
push )
case $2 in
-n|--dry-run )
;;
* )
# not a dry run
count_unlock_achievement "Socialite" "pushed a branch to a remote repository using git push" "$1"
count_unlock_achievement "Socialite" "pushed a branch to a remote repository using git push" "$command"
case $2 in
-f )
count_unlock_achievement "Thug" "Forced pushed a branch with git push -f" "push -f"
Expand Down Expand Up @@ -311,13 +320,13 @@ function check_for_achievements
unlock_achievement "Beach Lion" "Restricted login shell for GIT-only SSH access with git shell"
;;
show )
count_unlock_achievement "Presenter" "Shows one or more objects (blobs, trees, tags and commits) with git show" "$1"
count_unlock_achievement "Presenter" "Shows one or more objects (blobs, trees, tags and commits) with git show" "$command"
;;
show-branch )
count_unlock_achievement "Gardner" "Shows the commit ancestry graph with git show-branch" "$1"
count_unlock_achievement "Gardner" "Shows the commit ancestry graph with git show-branch" "$command"
;;
stash )
count_unlock_achievement "Product Manager" "Stash the changes in a dirty working directory away with git stash." "$1"
count_unlock_achievement "Product Manager" "Stash the changes in a dirty working directory away with git stash." "$command"
;;
submodule )
case $2 in
Expand All @@ -330,19 +339,19 @@ function check_for_achievements
esac
;;
svn|p4 )
count_unlock_achievement "Traveler" "Streamed changes between another rcs with git svn or git p4." "$1"
count_unlock_achievement "Traveler" "Streamed changes between another rcs with git svn or git p4." "$command"
;;
tag )
count_unlock_achievement "Gipsy" "Create, list, delete a tag signed with GPG using git tag" "$1"
count_unlock_achievement "Gipsy" "Create, list, delete a tag signed with GPG using git tag" "$command"
;;
whatchanged )
count_unlock_achievement "News Reader" "Show logs with difference each commit introduces with git whatchanged" "$1"
count_unlock_achievement "News Reader" "Show logs with difference each commit introduces with git whatchanged" "$command"
;;
flow )
count_unlock_achievement "Pedantic" "Use the flow extension to encourage an orderly and standardized branching model" "$1"
count_unlock_achievement "Pedantic" "Use the flow extension to encourage an orderly and standardized branching model" "$command"
;;
hash-object|update-index|commit-tree|update-ref )
count_unlock_achievement "Plumber" "Use the internal plumbing commands of git." "$1"
count_unlock_achievement "Plumber" "Use the internal plumbing commands of git." "$command"
;;
esac
}
Expand Down

0 comments on commit 7d6c654

Please sign in to comment.