From 6daab8357362c5c1f8cd68c7f29876af8db62e70 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 4 Jun 2014 18:12:23 +0530 Subject: [PATCH] Added functionality for git_init and git_commit --- src/lib/ee_lib_git_commit.sh | 15 +++++++++++++++ src/lib/ee_lib_git_init.sh | 21 +++++++++++++++++++++ src/lib/ee_lib_service.sh | 2 +- 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/lib/ee_lib_git_commit.sh create mode 100644 src/lib/ee_lib_git_init.sh diff --git a/src/lib/ee_lib_git_commit.sh b/src/lib/ee_lib_git_commit.sh new file mode 100644 index 00000000..8d8ff7a2 --- /dev/null +++ b/src/lib/ee_lib_git_commit.sh @@ -0,0 +1,15 @@ +# Record changes to the repository + +function ee_lib_git_commit() +{ + cd $EE_GIT_DIR \ + || ee_lib_error "Unable to change directory $EE_GIT_DIR, exit status = " $? + + if [ $(git status -s | wc -l) -ne 0 ]; then + ee_lib_echo "Commiting changes inside $EE_GIT_DIR, please wait..." + + # Add newly created files && commit it + git add --all && git commit -am "$EE_GIT_MESSAGE" &>> $EE_COMMAND_LOG \ + || ee_lib_error "Unable to Git commit on $EE_GIT_DIR, exit status = " $? + fi +} diff --git a/src/lib/ee_lib_git_init.sh b/src/lib/ee_lib_git_init.sh new file mode 100644 index 00000000..d0feef6c --- /dev/null +++ b/src/lib/ee_lib_git_init.sh @@ -0,0 +1,21 @@ +# Initialise Git + +function ee_lib_git_init() +{ + # Change directory + cd $EE_GIT_DIR || ee_lib_error "Unable to change directory $EE_GIT_DIR, exit status = " $? + + # Check .git + if [ ! -d .git ]; then + ee_lib_echo "Initialise Git On $EE_GIT_DIR..." + git init &>> $EE_COMMAND_LOG \ + || ee_lib_error "Unable to initialize Git on $EE_GIT_DIR, exit status = " $? + fi + + # Check for untracked files + if [ $(git status -s | wc -l) -ne 0 ]; then + # Add files in Git version control + git add --all && git commit -am "Initialize Git On $EE_GIT_DIR" &>> $EE_COMMAND_LOG \ + || ee_lib_error "Unable to Git commit on $EE_GIT_DIR, exit status = " $? + fi +} diff --git a/src/lib/ee_lib_service.sh b/src/lib/ee_lib_service.sh index e0a34792..6167b3b1 100644 --- a/src/lib/ee_lib_service.sh +++ b/src/lib/ee_lib_service.sh @@ -21,4 +21,4 @@ function ee_lib_service() fi done -} \ No newline at end of file +}