Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 154 lines (143 sloc) 4.825 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
#!/bin/bash
#
# Run through some simple usage cases. This both tests that important
# features work, and gives an example of suggested usage to get people
# started.
#
# usage: test_usage.sh VCS
# where VCS is one of:
# bzr, git, hg, arch, none
#
# Note that this script uses the *installed* version of be, not the
# one in your working tree.

set -e # exit immediately on failed command
set -o pipefail # pipes fail if any stage fails
set -v # verbose, echo commands to stdout

exec 6>&2 # save stderr to file descriptor 6
exec 2>&1 # fd 2 now writes to stdout

if [ $# -gt 1 ]
then
    echo "usage: test_usage.sh [VCS]"
    echo ""
    echo "where VCS is one of"
    for VCS in arch bzr darcs git hg none
    do
echo " $VCS"
    done
    exit 1
elif [ $# -eq 0 ]
then
    for VCS in arch bzr darcs git hg none
    do
echo -e "\n\nTesting $VCS\n\n"
$0 "$VCS" || exit 1
    done
    exit 0
fi

VCS="$1"

TESTDIR=`mktemp -d /tmp/BEtest.XXXXXXXXXX`
cd $TESTDIR

# Initialize the VCS repository
if [ "$VCS" == "arch" ]
then
    ID=`tla my-id`
    ARCH_PARAM_DIR="$HOME/.arch-params"
    ARCH_ARCHIVE_ROOT=`mktemp -d /tmp/BEtest.XXXXXXXXXX`
    UNIQUE=`echo "$ARCH_ARCHIVE_ROOT" | sed 's/\/tmp\/BEtest.//;s/[0-9]//g'`
    ARCH_ARCHIVE="j@x.com--BE-test-usage-$UNIQUE"
    ARCH_PROJECT="BE-test-usage--twig--99.5"
    ARCH_ARCHIVE_DIR="$ARCH_ARCHIVE_ROOT/$ARCH_PROJECT"
    echo "tla make-archive $ARCH_ARCHIVE $ARCH_ARCHIVE_DIR"
    tla make-archive $ARCH_ARCHIVE $ARCH_ARCHIVE_DIR
    echo "tla archive-setup -A $ARCH_ARCHIVE $ARCH_PROJECT"
    tla archive-setup -A $ARCH_ARCHIVE $ARCH_PROJECT
    echo "tla init-tree -A $ARCH_ARCHIVE $ARCH_PROJECT"
    tla init-tree -A $ARCH_ARCHIVE $ARCH_PROJECT
    echo "Adjusing the naming conventions to allow .files"
    sed -i 's/^source .*/source ^[._=a-zA-X0-9].*$/' '{arch}/=tagging-method'
    echo "tla import -A $ARCH_ARCHIVE --summary 'Began versioning'"
    tla import -A $ARCH_ARCHIVE --summary 'Began versioning'
elif [ "$VCS" == "bzr" ]
then
    ID=`bzr whoami`
    bzr init
elif [ "$VCS" == "darcs" ]
then
    if [ -z "$DARCS_EMAIL" ]; then
export DARCS_EMAIL="J. Doe <jdoe@example.com>"
    fi
    ID="$DARCS_EMAIL"
    darcs init
elif [ "$VCS" == "git" ]
then
    NAME=`git config user.name`
    EMAIL=`git config user.email`
    ID="$NAME <$EMAIL>"
    git init
elif [ "$VCS" == "hg" ]
then
    ID=`hg showconfig ui.username`
    hg init
elif [ "$VCS" == "none" ]
then
    ID=`id -nu`
else
    echo "Unrecognized VCS '$VCS'"
    exit 1
fi

if [ -z "$ID" ]
then # set a default ID for VCSs that aren't tracking one yet.
    ID="John Doe <jdoe@example.com>"
fi
echo "I am '$ID'"

be init # initialize the Bugs Everywhere repository
OUT=`be new 'having too much fun'` # create a new bug
echo "$OUT"
BUG=`echo "$OUT" | sed -n 's/Created bug with ID //p'`
echo "Working with bug: $BUG"
be comment $BUG "This is an argument"
#be set user_id "$ID" # get tired of guessing user id for none VCS
be set # show settings
be comment $BUG/ "No it isn't" # comment on the first comment
be show $BUG # show details on a given bug
be status closed $BUG # set bug status to 'closed'
be comment $BUG "It's closed, but I can still comment."
if [ "$VCS" != 'none' ]; then
    be commit 'Initial commit'
fi
be status open $BUG # set bug status to 'open'
be comment $BUG "Reopend, comment again"
be status fixed $BUG # set bug status to 'fixed'
be list # list all open bugs
be list --status fixed # list all fixed bugs
be assign - $BUG # assign the bug to yourself
be list -m --status fixed # see fixed bugs assigned to you
be assign 'Joe' $BUG # assign the bug to Joe
be list -a Joe --status fixed # list the fixed bugs assigned to Joe
be assign none $BUG # un-assign the bug
if [ "$VCS" != 'none' ]; then
  be diff # see what has changed
fi
OUT=`be new 'also having too much fun'`
BUGB=`echo "$OUT" | sed -n 's/Created bug with ID //p'`
be comment $BUGB "Blissfully unaware of a similar bug"
be merge $BUG $BUGB # join BUGB to BUG
be --no-pager show $BUG # show bug details & comments
# you can also export/import XML bugs/comments
OUT=`be new 'yet more fun'`
BUGC=`echo "$OUT" | sed -n 's/Created bug with ID //p'`
be comment $BUGC "The ants go marching..."
be show --xml $BUGC/ | be import-xml --add-only --comment-root $BUG -
be remove $BUG # decide that you don't like that bug after all
be commit "You can even commit using BE"
be commit --allow-empty "And you can add empty commits if you like"
be commit "But this will fail" || echo "Failed"

cd /
rm -rf $TESTDIR

if [ "$VCS" == "arch" ]
then
    # Cleanup everything outside of TESTDIR
    rm -rf "$ARCH_ARCHIVE_ROOT"
    rm -rf "$ARCH_PARAM_DIR/=locations/$ARCH_ARCHIVE"
fi

exec 2>&6 6>&- # restore stderr and close fd 6
Something went wrong with that request. Please try again.