From bfbd649d5de27c1434bc8bb7df9d33847fb3c088 Mon Sep 17 00:00:00 2001 From: Jack-Benny Persson Date: Thu, 12 Dec 2013 14:14:02 +0100 Subject: [PATCH] Nytt push.sh script --- Labb4/laborationsrapport.md | 1 + push.sh | 74 +++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100755 push.sh diff --git a/Labb4/laborationsrapport.md b/Labb4/laborationsrapport.md index e185d5f..c0f4006 100644 --- a/Labb4/laborationsrapport.md +++ b/Labb4/laborationsrapport.md @@ -42,3 +42,4 @@ echo $Var # "Hej alla sura" skrivs ut ``` Att kunna söka efter variabler är också trevligt, typ `echo ${!U}` som kommer att matcha t.ex. UID och USER. + diff --git a/push.sh b/push.sh new file mode 100755 index 0000000..aa4807f --- /dev/null +++ b/push.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +################################################################################ +# # +# Copyright (C) 2011 Jack-Benny Persson # +# # +# This program is free software; you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation; either version 2 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program; if not, write to the Free Software # +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# # +################################################################################ + +## Interactive git add/commit/push for beginners ## + +# Declare some variables +Git=/usr/bin/git +Repo=$HOME/testgit +Msg="$1" + +# Sanity checks +if [ $1 -ne 1 ]; then + echo 'Usage: $0 "commit message"' + exit 2 +fi + +if [ ! -x $Git ]; then + echo "Can't execut $Git" + exit 2 +fi + +if [ ! -d $Repo ]; then + echo "$Repo does not exist" + exit 2 +fi + +if [ -d $Repo ]; then + if [ ! -d $Repo/.git ]; then + echo "$Git is not a git repository" + exit 2 + fi +fi + +# Enter our repo, list changes and ask to commit them +cd $Repo + +git status + +printf "\nAre you sure you want to commit and push these changes? (y/n)" +read ShallWe + +if [ "$ShallWe" = "y" ]; then + echo "Adding, commiting & pushing" + git add -A + git commit -m "$Msg" + echo "Fake push" +elif [ "$ShallWe" = "n" ]; then + echo "Aborting" + exit 1 +else + echo "Please choose y(es) or n(o)" + exit 2 +fi + +exit 0