Skip to content

Commit

Permalink
support aliases (expand them after count), add an achievement for the…
Browse files Browse the repository at this point in the history
…m, added a test
  • Loading branch information
riffraff authored and icefox committed Mar 20, 2010
1 parent 3282230 commit d0ead89
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
19 changes: 18 additions & 1 deletion git-achievements
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ function count_unlock_achievement
fi
}

function unalias_command ()
{
#XXX maybe this should be recursive?
local cmdline=$(git config --get "alias.$1")
echo $cmdline
return
}

function check_for_achievements
{
# Anyone know of a cleaner way of checking for hooks?
Expand All @@ -148,7 +156,16 @@ function check_for_achievements
;;
esac

case $1 in
local command=$1

local expansion=$(unalias_command "$command")
if [[ $expansion ]] ; then
# not a real inventor
unlock_achievement "Garage Inventor" "Used a custom alias for a Git command"
command="$expansion"
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"
case $2 in
Expand Down
4 changes: 4 additions & 0 deletions test/testscript
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ function runtest() {
git format-patch HEAD^
git reset --hard HEAD^
git am -k3 0001*
git config alias.xxx ls-files
git xxx
git config --unset alias.xxx

}

export PATH=$PATH:$PWD/../
Expand Down

0 comments on commit d0ead89

Please sign in to comment.