~veebers/juju-ci-tools/migration-add-migrate-back-to-original

928.3.2 by Curtis Hovey
Update eco repos separately from testing. We will only test if something was updated.
1
#!/bin/bash
928.3.4 by Curtis Hovey
Update the eco project deps after pulling a new revision.
2
set -eu
928.3.2 by Curtis Hovey
Update eco repos separately from testing. We will only test if something was updated.
3
928.3.3 by Curtis Hovey
Explicity pull master.
4
LOCAL_REPO=$(readlink -f $1)  # Path to the local repo: gogo/src/github.com/foo
5
REMOTE_REPO=$(echo "$LOCAL_REPO" | sed -e 's,.*/src/,,')
928.3.2 by Curtis Hovey
Update eco repos separately from testing. We will only test if something was updated.
6
7
: ${CI_TOOLS=$(readlink -f $(dirname $0))}
8
CLOUD_CITY=$(readlink -f $CI_TOOLS/../cloud-city)
9
10
while [[ "${1-}" != "" ]]; do
11
    case $1 in
12
        --cloud-city)
13
            shift
928.3.3 by Curtis Hovey
Explicity pull master.
14
            CLOUD_CITY=$(readlink -f $1)
928.3.2 by Curtis Hovey
Update eco repos separately from testing. We will only test if something was updated.
15
            ;;
16
    esac
17
    shift
18
done
19
928.3.3 by Curtis Hovey
Explicity pull master.
20
cd $LOCAL_REPO
935 by Curtis Hovey
Use the command name, not an aliases (fixes broken job).
21
git checkout master
928.3.2 by Curtis Hovey
Update eco repos separately from testing. We will only test if something was updated.
22
OLD_HASH=$(git log --first-parent -1 --pretty=format:%h)
23
source $CLOUD_CITY/juju-bot.txt
928.3.3 by Curtis Hovey
Explicity pull master.
24
git pull https://$github_user:$github_password@$REMOTE_REPO.git master
928.3.2 by Curtis Hovey
Update eco repos separately from testing. We will only test if something was updated.
25
NEW_HASH=$(git log --first-parent -1 --pretty=format:%h)
26
if [[ $OLD_HASH == $NEW_HASH ]]; then
27
    echo "Nothing to test."
28
    exit 1
29
else
30
    echo "A new revision can be tested."
928.3.4 by Curtis Hovey
Update the eco project deps after pulling a new revision.
31
    set +e
32
    echo "Updating all go deps."
33
    go get ./...
928.3.2 by Curtis Hovey
Update eco repos separately from testing. We will only test if something was updated.
34
    exit 0
35
fi