diff --git a/CHANGELOG b/CHANGELOG index 09fa7366d96f7e9f372bd82f10046345cfd6e415..2befb9cadd94eb46cbe6a6b97e1e36d5da778d62 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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. diff --git a/add_mirror.sh b/add_mirror.sh index bab32d8c05df1433915e4165892bf5e9a046c67a..54894fa402a854d3004448a5d98084583a91d1ce 100755 --- a/add_mirror.sh +++ b/add_mirror.sh @@ -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