Skip to content
Snippets Groups Projects
Commit bd717573 authored by Sam Gleske's avatar Sam Gleske
Browse files

Adding force option to add_mirror.sh

parent c8e5665c
No related branches found
No related tags found
No related merge requests found
...@@ -3,6 +3,7 @@ gitlab-mirrors v0.2 ...@@ -3,6 +3,7 @@ gitlab-mirrors v0.2
* Colorized output enabled for all commands! * Colorized output enabled for all commands!
* Better argument handling on all commands! * Better argument handling on all commands!
* Project creation defaults can now be set in config.sh! * Project creation defaults can now be set in config.sh!
* New options for add_mirror.sh, see ./add_mirror.sh -h
* New delete_mirror.sh command! * New delete_mirror.sh command!
* Knit and grit changes * Knit and grit changes
* add_mirror.sh has more robust error checking. * add_mirror.sh has more robust error checking.
......
...@@ -20,6 +20,7 @@ svn=false ...@@ -20,6 +20,7 @@ svn=false
git=false git=false
project_name="" project_name=""
mirror="" mirror=""
force=false
# #
# ARGUMENT HANDLING # ARGUMENT HANDLING
...@@ -48,6 +49,8 @@ DESCRIPTION: ...@@ -48,6 +49,8 @@ DESCRIPTION:
An authors file to pass to git-svn for mapping An authors file to pass to git-svn for mapping
SVN users to git users. SVN users to git users.
-f,--force Force add project even if it already exists.
--git Mirror a git repository (must be explicitly set) --git Mirror a git repository (must be explicitly set)
-m,--mirror URL Repository URL to be mirrored. -m,--mirror URL Repository URL to be mirrored.
...@@ -61,8 +64,8 @@ DESCRIPTION: ...@@ -61,8 +64,8 @@ DESCRIPTION:
EOF EOF
} }
#Short options are one letter. If an argument follows a short opt then put a colon (:) after it #Short options are one letter. If an argument follows a short opt then put a colon (:) after it
SHORTOPTS="hvm:p:" SHORTOPTS="hvfm:p:"
LONGOPTS="help,version,git,svn,mirror:,project-name:,authors-file:" LONGOPTS="help,version,force,git,svn,mirror:,project-name:,authors-file:"
ARGS=$(getopt -s bash --options "${SHORTOPTS}" --longoptions "${LONGOPTS}" --name "${PROGNAME}" -- "$@") ARGS=$(getopt -s bash --options "${SHORTOPTS}" --longoptions "${LONGOPTS}" --name "${PROGNAME}" -- "$@")
eval set -- "$ARGS" eval set -- "$ARGS"
while true; do while true; do
...@@ -83,6 +86,10 @@ while true; do ...@@ -83,6 +86,10 @@ while true; do
svn=true svn=true
shift shift
;; ;;
-f|--force)
force=true
shift
;;
-p|--project-name) -p|--project-name)
project_name="${2}" project_name="${2}"
shift 2 shift 2
...@@ -163,8 +170,8 @@ if [ ! -e "${repo_dir}/${gitlab_namespace}" ];then ...@@ -163,8 +170,8 @@ if [ ! -e "${repo_dir}/${gitlab_namespace}" ];then
elif [ ! -d "${repo_dir}/${gitlab_namespace}" ];then elif [ ! -d "${repo_dir}/${gitlab_namespace}" ];then
red_echo "Error: \"${repo_dir}/${gitlab_namespace}\" exists but is not a directory." 1>&2 red_echo "Error: \"${repo_dir}/${gitlab_namespace}\" exists but is not a directory." 1>&2
exit 1 exit 1
elif [ -d "${repo_dir}/${gitlab_namespace}/${project_name}" ];then elif [ -d "${repo_dir}/${gitlab_namespace}/${project_name}" ] && ! ${force};then
red_echo "Error: \"${repo_dir}/${gitlab_namespace}\" exists already. Aborting command." 1>&2 red_echo "Error: \"${repo_dir}/${gitlab_namespace}/${project_name}\" exists already. Aborting command." 1>&2
exit 1 exit 1
fi fi
#Resolve the $authors_file path because of changing working directories #Resolve the $authors_file path because of changing working directories
...@@ -237,9 +244,6 @@ elif ${svn};then ...@@ -237,9 +244,6 @@ elif ${svn};then
echo "Creating mirror from ${mirror}" echo "Creating mirror from ${mirror}"
cd "${repo_dir}/${gitlab_namespace}" cd "${repo_dir}/${gitlab_namespace}"
if [ ! -z "${authors_file}" ];then if [ ! -z "${authors_file}" ];then
echo "${authors_file}" git svn clone "${mirror}" "${project_name}" ${git_svn_additional_options} --authors-file="${authors_file}"
#git svn clone ${git_svn_additional_options} --authors-file="${authors_file}" "${mirror}" "${project_name}"
fi fi
fi fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment