/ test_usage.sh
test_usage.sh
1 #!/bin/bash 2 # 3 # Run through some simple usage cases. This both tests that important 4 # features work, and gives an example of suggested usage to get people 5 # started. 6 # 7 # usage: test_usage.sh VCS 8 # where VCS is one of: 9 # bzr, git, hg, none 10 # 11 # Note that this script uses the *installed* version of be, not the 12 # one in your working tree. 13 14 set -e # exit immediately on failed command 15 set -o pipefail # pipes fail if any stage fails 16 set -v # verbose, echo commands to stdout 17 18 exec 6>&2 # save stderr to file descriptor 6 19 exec 2>&1 # fd 2 now writes to stdout 20 21 if [ $# -gt 1 ] 22 then 23 echo "usage: test_usage.sh [VCS]" 24 echo "" 25 echo "where VCS is one of" 26 for VCS in bzr darcs git hg none 27 do 28 echo " $VCS" 29 done 30 exit 1 31 elif [ $# -eq 0 ] 32 then 33 for VCS in bzr darcs git hg none 34 do 35 echo -e "\n\nTesting $VCS\n\n" 36 $0 "$VCS" || exit 1 37 done 38 exit 0 39 fi 40 41 VCS="$1" 42 43 TESTDIR=`mktemp -d /tmp/BEtest.XXXXXXXXXX` 44 cd $TESTDIR 45 46 # Initialize the VCS repository 47 if [ "$VCS" == "bzr" ] 48 then 49 ID=`bzr whoami` 50 bzr init 51 elif [ "$VCS" == "darcs" ] 52 then 53 if [ -z "$DARCS_EMAIL" ]; then 54 export DARCS_EMAIL="J. Doe <jdoe@example.com>" 55 fi 56 ID="$DARCS_EMAIL" 57 darcs init 58 elif [ "$VCS" == "git" ] 59 then 60 NAME=`git config user.name` 61 EMAIL=`git config user.email` 62 ID="$NAME <$EMAIL>" 63 git init 64 elif [ "$VCS" == "hg" ] 65 then 66 ID=`hg showconfig ui.username` 67 hg init 68 elif [ "$VCS" == "none" ] 69 then 70 ID=`id -nu` 71 else 72 echo "Unrecognized VCS '$VCS'" 73 exit 1 74 fi 75 76 if [ -z "$ID" ] 77 then # set a default ID for VCSs that aren't tracking one yet. 78 ID="John Doe <jdoe@example.com>" 79 fi 80 echo "I am '$ID'" 81 82 be init # initialize the Bugs Everywhere repository 83 OUT=`be new 'having too much fun'` # create a new bug 84 echo "$OUT" 85 BUG=`echo "$OUT" | sed -n 's/Created bug with ID //p'` 86 echo "Working with bug: $BUG" 87 be comment $BUG "This is an argument" 88 #be set user_id "$ID" # get tired of guessing user id for none VCS 89 be set # show settings 90 be comment $BUG/ "No it isn't" # comment on the first comment 91 be show $BUG # show details on a given bug 92 be status closed $BUG # set bug status to 'closed' 93 be comment $BUG "It's closed, but I can still comment." 94 if [ "$VCS" != 'none' ]; then 95 be commit 'Initial commit' 96 fi 97 be status open $BUG # set bug status to 'open' 98 be comment $BUG "Reopend, comment again" 99 be status fixed $BUG # set bug status to 'fixed' 100 be list # list all open bugs 101 be list --status fixed # list all fixed bugs 102 be assign - $BUG # assign the bug to yourself 103 be list -m --status fixed # see fixed bugs assigned to you 104 be assign 'Joe' $BUG # assign the bug to Joe 105 be list -a Joe --status fixed # list the fixed bugs assigned to Joe 106 be assign none $BUG # un-assign the bug 107 if [ "$VCS" != 'none' ]; then 108 be diff # see what has changed 109 fi 110 OUT=`be new 'also having too much fun'` 111 BUGB=`echo "$OUT" | sed -n 's/Created bug with ID //p'` 112 be comment $BUGB "Blissfully unaware of a similar bug" 113 be merge $BUG $BUGB # join BUGB to BUG 114 be --no-pager show $BUG # show bug details & comments 115 # you can also export/import XML bugs/comments 116 OUT=`be new 'yet more fun'` 117 BUGC=`echo "$OUT" | sed -n 's/Created bug with ID //p'` 118 be comment $BUGC "The ants go marching..." 119 be show --xml $BUGC/ | be import-xml --add-only --root $BUG - 120 be remove $BUG # decide that you don't like that bug after all 121 be commit "You can even commit using BE" 122 be commit --allow-empty "And you can add empty commits if you like" 123 be commit "But this will fail" || echo "Failed" 124 125 cd / 126 rm -rf $TESTDIR 127 128 exec 2>&6 6>&- # restore stderr and close fd 6