From bc83b354b5e07a2b58461df8148cc8ad580eafb3 Mon Sep 17 00:00:00 2001
From: Sam Gleske <sag47@drexel.edu>
Date: Fri, 13 Sep 2013 12:53:28 -0400
Subject: [PATCH] Added environ variable checking

Updated README for Features
Added better description comment to config.sh.SAMPLE
---
 CHANGELOG        |  7 ++++++
 README.md        |  9 ++++++++
 add_mirror.sh    | 59 ++++++++++++++++++++++++++++++++++++++++++++++++
 config.sh.SAMPLE |  1 +
 4 files changed, 76 insertions(+)

diff --git a/CHANGELOG b/CHANGELOG
index 2befb9c..9f5f683 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,10 @@
+gitlab-mirrors v0.2.2
+* Safer environment variable option checking for config.sh in add_mirror.sh command.
+* Added Features do README
+
+gitlab-mirrors v0.2.1
+* CHANGELOG update
+
 gitlab-mirrors v0.2
 * Renamed project from git-mirrors to gitlab-mirrors.
 * Colorized output enabled for all commands!
diff --git a/README.md b/README.md
index 7fc5542..7c1f03b 100644
--- a/README.md
+++ b/README.md
@@ -3,6 +3,15 @@
 The [gitlab-mirrors](https://github.com/sag47/gitlab-mirrors) project is designed to fill in a feature which is currently missing from GitLab: the ability to mirror remote repositories.  gitlab-mirrors creates read only copies of remote repositories in gitlab.  It provides a CLI management interface for managing the mirrored repositories (e.g. add, delete, update) so that an admin may regularly update all mirrors using `crontab`.  It operates by interacting with the [GitLab API][1] using [python-gitlab][2].
 
 
+## Features
+
+* Mirror git and SVN repositories.
+* When adding a mirror if the project doesn't exist in GitLab then `add_mirrror.sh` will automatically create it.
+  * Specify initial project defaults when a project is created (e.g. issues enabled, wiki enabled, etc.)
+* Update a single mirror with the `update_mirror.sh` command.
+* Update all known mirrors with the `git-mirrors.sh` command.  Useful for adding to a `cron` job for updating all repositories on a regular schedule.
+
+
 ---
 # Three easy steps
 
diff --git a/add_mirror.sh b/add_mirror.sh
index 09b02f3..99abc29 100755
--- a/add_mirror.sh
+++ b/add_mirror.sh
@@ -122,6 +122,7 @@ done
 
 function preflight() {
   STATUS=0
+  #test required git or svn option
   if ${git} && ${svn};then
     red_echo -n "Must not set " 1>&2
     yellow_echo -n "--svn" 1>&2
@@ -138,24 +139,82 @@ function preflight() {
     red_echo " options." 1>&2
     STATUS=1
   fi
+  #test required project_name option
   if [ -z "${project_name}" ];then
     red_echo -n "Missing " 1>&2
     yellow_echo -n "--project-name" 1>&2
     red_echo " option." 1>&2
     STATUS=1
   fi
+  #test required mirror option
   if [ -z "${mirror}" ];then
     red_echo -n "Missing " 1>&2
     yellow_echo -n "--mirror" 1>&2
     red_echo " option." 1>&2
     STATUS=1
   fi
+  #test authors_file path for existence
   if [ ! -z "${authors_file}" -a ! -f "${authors_file}" ];then
     red_echo -n "Specified "
     yellow_echo -n "--authors-file"
     red_echo " does not exist!"
     STATUS=1
   fi
+  #test issues_enabled environment variable (must be bool)
+  if [ ! "${issues_enabled}" = "true" ] && [ ! "${issues_enabled}" = "false" ];then
+    red_echo -n "issues_enabled="
+    yellow_echo -n "${issues_enabled}"
+    red_echo -n "is not a valid option for issues_enabled!  Must be "
+    yellow_echo -n "true"
+    red_echo -n "or "
+    yellow_echo -n "false"
+    red_echo "." 1>&2
+    STATUS=1
+  fi
+  #test wall_enabled environment variable (must be bool)
+  if [ ! "${wall_enabled}" = "true" ] && [ ! "${wall_enabled}" = "false" ];then
+    red_echo -n "wall_enabled="
+    yellow_echo -n "${wall_enabled}"
+    red_echo -n "is not a valid option for wall_enabled!  Must be "
+    yellow_echo -n "true"
+    red_echo -n "or "
+    yellow_echo -n "false"
+    red_echo "." 1>&2
+    STATUS=1
+  fi
+  #test wiki_enabled environment variable (must be bool)
+  if [ ! "${wiki_enabled}" = "true" ] && [ ! "${wiki_enabled}" = "false" ];then
+    red_echo -n "wiki_enabled="
+    yellow_echo -n "${wiki_enabled}"
+    red_echo -n "is not a valid option for wiki_enabled!  Must be "
+    yellow_echo -n "true"
+    red_echo -n "or "
+    yellow_echo -n "false"
+    red_echo "." 1>&2
+    STATUS=1
+  fi
+  #test snippets_enabled environment variable (must be bool)
+  if [ ! "${snippets_enabled}" = "true" ] && [ ! "${snippets_enabled}" = "false" ];then
+    red_echo -n "snippets_enabled="
+    yellow_echo -n "${snippets_enabled}"
+    red_echo -n "is not a valid option for snippets_enabled!  Must be "
+    yellow_echo -n "true"
+    red_echo -n "or "
+    yellow_echo -n "false"
+    red_echo "." 1>&2
+    STATUS=1
+  fi
+  #test public environment variable (must be bool)
+  if [ ! "${public}" = "true" ] && [ ! "${public}" = "false" ];then
+    red_echo -n "public="
+    yellow_echo -n "${public}"
+    red_echo -n "is not a valid option for public!  Must be "
+    yellow_echo -n "true"
+    red_echo -n "or "
+    yellow_echo -n "false"
+    red_echo "." 1>&2
+    STATUS=1
+  fi
   return ${STATUS}
 }
 
diff --git a/config.sh.SAMPLE b/config.sh.SAMPLE
index 4c77d6d..01225da 100644
--- a/config.sh.SAMPLE
+++ b/config.sh.SAMPLE
@@ -33,6 +33,7 @@ gitlab_user_token_secret="$(head -n1 "${user_home}/private_token")"
 # then it will assign the following values as defaults.
 #
 
+#values must be true or false
 issues_enabled=false
 wall_enabled=false
 wiki_enabled=false
-- 
GitLab