From a4e85b2bcd668a4f789436740f2d9d882d3ee09c Mon Sep 17 00:00:00 2001 From: Bruce Zu Date: Mon, 1 Sep 2014 13:52:00 +0800 Subject: [PATCH] Restrict the input of plugin_archetype_deploy.sh Input mispelled option of plugin_archetype_deploy.sh it starts to run. Restrict the input to avoid this error. Add confirm before run. Change-Id: I6fdc8b592679c45891210261a47285171b50e35f --- tools/plugin_archetype_deploy.sh | 56 +++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/tools/plugin_archetype_deploy.sh b/tools/plugin_archetype_deploy.sh index 929e1fd59d..b5d1a6658a 100755 --- a/tools/plugin_archetype_deploy.sh +++ b/tools/plugin_archetype_deploy.sh @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -help() +function help { cat <<'eof' Usage: plugin_archetype_deploy [option] @@ -21,8 +21,9 @@ Usage: plugin_archetype_deploy [option] Deploys Gerrit plugin Maven archetypes to Maven Central Valid options: - --help show this message - --dry-run don't execute commands, just print them + --help show this message. + --dry-run don't execute commands, just print them. + eof exit } @@ -62,22 +63,39 @@ function build_and_deploy -Dfile=target/$module-$ver.jar } -while [ $# -gt 0 ]; do - test "$1" == --dry-run && dryRun=true - test "$1" == --help && help - shift -done +function confirm +{ + read -n1 -p "Are you sure you want to deploy? [N/y]: " ready + if [[ ! $ready == [Yy] ]]; then + if [[ $ready == [Nn] || -z $ready ]]; then + echo; exit + else + echo; confirm + fi + fi +} -root=$(instroot) -cd "$root" -ver=$(getver GERRIT_VERSION) -[[ $ver == *-SNAPSHOT ]] \ - && url="https://oss.sonatype.org/content/repositories/snapshots" \ - || url="https://oss.sonatype.org/service/local/staging/deploy/maven2" +function run +{ + test ${dryRun:-'false'} == 'false' && confirm + root=$(instroot) + cd "$root" + ver=$(getver GERRIT_VERSION) + [[ $ver == *-SNAPSHOT ]] \ + && url="https://oss.sonatype.org/content/repositories/snapshots" \ + || url="https://oss.sonatype.org/service/local/staging/deploy/maven2" -for d in gerrit-plugin-archetype \ - gerrit-plugin-js-archetype \ - gerrit-plugin-gwt-archetype ; do - (cd "$d"; build_and_deploy) -done + for d in gerrit-plugin-archetype \ + gerrit-plugin-js-archetype \ + gerrit-plugin-gwt-archetype ; do + (cd "$d"; build_and_deploy) + done +} +if [ "$1" == "--dry-run" ]; then + dryRun=true && run +elif [ -z "$1" ]; then + run +else + help +fi