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
* Colorized output enabled for all commands!
* Better argument handling on all commands!
* 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!
* Knit and grit changes
* add_mirror.sh has more robust error checking.
......
......@@ -20,6 +20,7 @@ svn=false
git=false
project_name=""
mirror=""
force=false
#
# ARGUMENT HANDLING
......@@ -48,6 +49,8 @@ DESCRIPTION:
An authors file to pass to git-svn for mapping
SVN users to git users.
-f,--force Force add project even if it already exists.
--git Mirror a git repository (must be explicitly set)
-m,--mirror URL Repository URL to be mirrored.
......@@ -61,8 +64,8 @@ DESCRIPTION:
EOF
}
#Short options are one letter. If an argument follows a short opt then put a colon (:) after it
SHORTOPTS="hvm:p:"
LONGOPTS="help,version,git,svn,mirror:,project-name:,authors-file:"
SHORTOPTS="hvfm:p:"
LONGOPTS="help,version,force,git,svn,mirror:,project-name:,authors-file:"
ARGS=$(getopt -s bash --options "${SHORTOPTS}" --longoptions "${LONGOPTS}" --name "${PROGNAME}" -- "$@")
eval set -- "$ARGS"
while true; do
......@@ -83,6 +86,10 @@ while true; do
svn=true
shift
;;
-f|--force)
force=true
shift
;;
-p|--project-name)
project_name="${2}"
shift 2
......@@ -163,8 +170,8 @@ if [ ! -e "${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
exit 1
elif [ -d "${repo_dir}/${gitlab_namespace}/${project_name}" ];then
red_echo "Error: \"${repo_dir}/${gitlab_namespace}\" exists already. Aborting command." 1>&2
elif [ -d "${repo_dir}/${gitlab_namespace}/${project_name}" ] && ! ${force};then
red_echo "Error: \"${repo_dir}/${gitlab_namespace}/${project_name}\" exists already. Aborting command." 1>&2
exit 1
fi
#Resolve the $authors_file path because of changing working directories
......@@ -237,9 +244,6 @@ elif ${svn};then
echo "Creating mirror from ${mirror}"
cd "${repo_dir}/${gitlab_namespace}"
if [ ! -z "${authors_file}" ];then
echo "${authors_file}"
#git svn clone ${git_svn_additional_options} --authors-file="${authors_file}" "${mirror}" "${project_name}"
git svn clone "${mirror}" "${project_name}" ${git_svn_additional_options} --authors-file="${authors_file}"
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