|
| 1 | +#!/bin/bash |
| 2 | +# |
| 3 | +# Copyright 2014 Range Networks, Inc. |
| 4 | +# |
| 5 | +# This program is free software: you can redistribute it and/or modify |
| 6 | +# it under the terms of the GNU Affero General Public License as published by |
| 7 | +# the Free Software Foundation, either version 3 of the License, or |
| 8 | +# (at your option) any later version. |
| 9 | +# |
| 10 | +# This program is distributed in the hope that it will be useful, |
| 11 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | +# GNU Affero General Public License for more details. |
| 14 | +# |
| 15 | +# You should have received a copy of the GNU Affero General Public License |
| 16 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | +# See the COPYING file in the main directory for details. |
| 18 | +# |
| 19 | + |
| 20 | +source $(dirname $0)/common.source |
| 21 | + |
| 22 | +usage () { |
| 23 | + echo "# usage: ./create.sh component-directory (tag/branch name)" |
| 24 | + exit 1 |
| 25 | +} |
| 26 | + |
| 27 | +# What component do we want to manipulate? |
| 28 | +if [ -z "$1" ]; then |
| 29 | + usage |
| 30 | +elif [ ! -d $1 ]; then |
| 31 | + usage |
| 32 | +else |
| 33 | + COMPONENT=$1 |
| 34 | +fi |
| 35 | + |
| 36 | +# Are we adding a creating or branch? |
| 37 | +if [ -z "$2" ]; then |
| 38 | + read -r -p "# Do you want to create a tag or branch? " TYPE |
| 39 | +elif [ $2 == "tag" ]; then |
| 40 | + TYPE="tag" |
| 41 | +elif [ $2 == "branch" ]; then |
| 42 | + TYPE="branch" |
| 43 | +else |
| 44 | + usage |
| 45 | +fi |
| 46 | + |
| 47 | +# Which one should be created? |
| 48 | +if [ -z "$3" ]; then |
| 49 | + read -r -p "# What new $TYPE would you like to create? " NAME |
| 50 | +else |
| 51 | + NAME=$3 |
| 52 | +fi |
| 53 | + |
| 54 | +# Really, truly? Alrighty, execute. |
| 55 | +read -r -p "# To create a new $TYPE named $NAME, answer \"yes\" " ANSWER |
| 56 | +if [ $ANSWER == "yes" ]; then |
| 57 | + cd $COMPONENT |
| 58 | + if [ $TYPE == "tag" ]; then |
| 59 | + echo "# Sorry, tag creations haven't been implemented. Bailing." |
| 60 | + exit 1 |
| 61 | + elif [ $TYPE == "branch" ]; then |
| 62 | + echo "# - creating..." |
| 63 | + sayAndDo git checkout -b $NAME |
| 64 | + echo "# - pushing to origin..." |
| 65 | + sayAndDo git push -u origin $NAME |
| 66 | + fi |
| 67 | +else |
| 68 | + echo "# - better safe than sorry, cancelling..." |
| 69 | +fi |
0 commit comments