-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow pinning of repo and branch for testing (#100)
* Allow pinning of repo and branch * Fix missing delete pin
- Loading branch information
Showing
3 changed files
with
137 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
core-arbiter https://github.com/me-box/core-arbiter.git master | ||
core-export-service https://github.com/me-box/core-export-service.git master | ||
store-json https://github.com/me-box/store-json.git master | ||
store-timeseries https://github.com/me-box/store-timeseries.git master | ||
platform-app-server https://github.com/me-box/platform-app-server.git master | ||
driver-os-monitor https://github.com/me-box/driver-os-monitor.git master | ||
app-os-monitor https://github.com/me-box/app-os-monitor.git master | ||
driver-twitter https://github.com/me-box/driver-twitter.git master | ||
driver-sensingkit https://github.com/me-box/driver-sensingkit.git master | ||
driver-google-takeout https://github.com/me-box/driver-google-takeout.git master | ||
driver-phillips-hue https://github.com/me-box/driver-phillips-hue.git master | ||
driver-tplink-smart-plug https://github.com/me-box/driver-tplink-smart-plug.git master | ||
app-light-graph https://github.com/me-box/app-light-graph.git master | ||
app-twitter-sentiment https://github.com/me-box/app-twitter-sentiment.git master | ||
core-container-manager https://github.com/me-box/core-container-manager master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,32 @@ | ||
#!/usr/bin/env bash | ||
|
||
#set this to ssh if you want to clone over ssh rather then https | ||
UPDATE_TYPE="" | ||
|
||
update_repo() | ||
{ | ||
|
||
if [ "$UPDATE_TYPE" = "ssh" ] | ||
then | ||
update_repo_ssh $1 | ||
else | ||
update_repo_https $1 | ||
fi | ||
} | ||
|
||
update_repo_https() | ||
{ | ||
NAME=$1 | ||
REPO="https://github.com/me-box/${NAME}.git" | ||
|
||
REPO=$2 | ||
BRANCH=$3 | ||
|
||
if [ ! -d ${NAME} ]; then | ||
echo "Pulling ${NAME} FROM ${REPO} on branch ${BRANCH}" | ||
git clone ${REPO} ${NAME} | ||
else | ||
cd ${NAME} | ||
echo ${NAME} `git pull` | ||
git checkout $BRANCH | ||
cd .. | ||
fi | ||
} | ||
|
||
update_repo_ssh() | ||
{ | ||
NAME=$1 | ||
REPO="git@github.com:me-box/${NAME}.git" | ||
|
||
if [ ! -d ${NAME} ]; then | ||
git clone ${REPO} ${NAME} | ||
else | ||
echo "Updating ${NAME} FROM ${REPO} on branch ${BRANCH}" | ||
cd ${NAME} | ||
git remote set-url origin $REPO | ||
git checkout $BRANCH | ||
echo ${NAME} `git pull` | ||
cd .. | ||
fi | ||
} | ||
|
||
update_repo "core-container-manager" & | ||
update_repo "core-arbiter" & | ||
update_repo "core-export-service" & | ||
update_repo "platform-app-server" & | ||
update_repo "store-json" & | ||
update_repo "store-timeseries" & | ||
|
||
update_repo "driver-os-monitor" & | ||
update_repo "driver-twitter" & | ||
update_repo "driver-sensingkit" & | ||
update_repo "driver-google-takeout" & | ||
update_repo "driver-phillips-hue" & | ||
update_repo "driver-tplink-smart-plug" & | ||
while read comp; do | ||
if [ "$comp" != "" ] | ||
then | ||
update_repo $comp & | ||
fi | ||
done <databox-components | ||
|
||
update_repo "app-twitter-sentiment" & | ||
update_repo "app-light-graph" & | ||
update_repo "app-os-monitor" & | ||
wait |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
#!/bin/bash | ||
|
||
fail() { | ||
echo -e "[ERROR] ${1}" | ||
exit 1 | ||
} | ||
|
||
assert() { | ||
if [ "$1" != "$2" ] | ||
then | ||
fail "$3" "$1" | ||
fi | ||
} | ||
|
||
usage() { | ||
echo $# | ||
echo "Please invoke this script with the relative path to the databox component you would like to pin." | ||
echo "Usage: databox-pin [OPTION...] [COMPONENT DIR]" | ||
echo "Flags:" | ||
echo "-d Delete the pin" | ||
echo "-h This help message" | ||
exit 1 | ||
} | ||
|
||
if [[ $# < 1 ]] || [[ "$1" == "-h" ]] # Must have more than 1 args. | ||
then | ||
usage | ||
fi | ||
|
||
update_file() { | ||
FILE=$1 | ||
COMP=$2 | ||
LINE=$3 | ||
LEFT=$(grep -v "^${COMP}" $FILE) | ||
echo "$LEFT" > $FILE | ||
echo -e $LINE >> $FILE | ||
} | ||
|
||
check_y() { | ||
if [ $1 != "y" ] | ||
then | ||
echo "OK - no changes made" | ||
exit 0 | ||
fi | ||
} | ||
|
||
add_entry() { | ||
echo "Are you sure you want to pin ${COMPONENT_NAME} to ${ORIGIN} ${BRANCH}? [y/n]" | ||
read -n1 ANS | ||
check_y $ANS | ||
|
||
cd $COMPONENT_DIR >/dev/null 2>&1 | ||
assert $? 0 "directory (${COMPONENT_DIR}) not found" | ||
|
||
git status >/dev/null 2>&1 | ||
assert $? 0 "directory (${COMPONENT_DIR}) is not a git repo." | ||
|
||
ORIGIN=$(git remote get-url --push origin) | ||
#convert ssh to https pins | ||
ORIGIN=${ORIGIN//git@/https:\/\/} | ||
ORIGIN=${ORIGIN//com:/com\/} | ||
|
||
BRANCH=$(git rev-parse --abbrev-ref HEAD) | ||
|
||
cd .. | ||
|
||
update_file $DATABOX_CONFIG_FILE $COMPONENT_NAME "$COMPONENT_NAME $ORIGIN $BRANCH" | ||
|
||
echo "Done pined ${COMPONENT_NAME} to ${ORIGIN} ${BRANCH}" | ||
} | ||
|
||
del_entry() { | ||
echo "Are you sure you want to unpin ${COMPONENT_NAME}? [y/n]" | ||
read -n1 ANS | ||
check_y $ANS | ||
|
||
ORIGIN="https://github.com/me-box/${COMPONENT_NAME}" | ||
BRANCH="master" | ||
update_file $DATABOX_CONFIG_FILE $COMPONENT_NAME "$COMPONENT_NAME $ORIGIN $BRANCH" | ||
|
||
echo "Done unpined ${COMPONENT_NAME}" | ||
} | ||
|
||
DATABOX_CONFIG_FILE=databox-components | ||
|
||
|
||
|
||
|
||
if [[ "$1" == "-d" ]] | ||
then | ||
shift | ||
DATABOX_DIR=${pwd} | ||
COMPONENT_DIR=${1} | ||
COMPONENT_NAME=${1//.\//} | ||
COMPONENT_NAME=${COMPONENT_NAME%/} | ||
del_entry | ||
else | ||
DATABOX_DIR=${pwd} | ||
COMPONENT_DIR=${1} | ||
COMPONENT_NAME=${1//.\//} | ||
COMPONENT_NAME=${COMPONENT_NAME%/} | ||
add_entry | ||
fi | ||
|
||
|
||
|
||
|
||
|