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
This commit is contained in:
Bruce Zu
2014-09-01 13:52:00 +08:00
parent 546d22f0e0
commit a4e85b2bcd

View File

@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
help() function help
{ {
cat <<'eof' cat <<'eof'
Usage: plugin_archetype_deploy [option] Usage: plugin_archetype_deploy [option]
@@ -21,8 +21,9 @@ Usage: plugin_archetype_deploy [option]
Deploys Gerrit plugin Maven archetypes to Maven Central Deploys Gerrit plugin Maven archetypes to Maven Central
Valid options: Valid options:
--help show this message --help show this message.
--dry-run don't execute commands, just print them --dry-run don't execute commands, just print them.
eof eof
exit exit
} }
@@ -62,22 +63,39 @@ function build_and_deploy
-Dfile=target/$module-$ver.jar -Dfile=target/$module-$ver.jar
} }
while [ $# -gt 0 ]; do function confirm
test "$1" == --dry-run && dryRun=true {
test "$1" == --help && help read -n1 -p "Are you sure you want to deploy? [N/y]: " ready
shift if [[ ! $ready == [Yy] ]]; then
done if [[ $ready == [Nn] || -z $ready ]]; then
echo; exit
else
echo; confirm
fi
fi
}
root=$(instroot) function run
cd "$root" {
ver=$(getver GERRIT_VERSION) test ${dryRun:-'false'} == 'false' && confirm
[[ $ver == *-SNAPSHOT ]] \ root=$(instroot)
&& url="https://oss.sonatype.org/content/repositories/snapshots" \ cd "$root"
|| url="https://oss.sonatype.org/service/local/staging/deploy/maven2" 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 \ for d in gerrit-plugin-archetype \
gerrit-plugin-js-archetype \ gerrit-plugin-js-archetype \
gerrit-plugin-gwt-archetype ; do gerrit-plugin-gwt-archetype ; do
(cd "$d"; build_and_deploy) (cd "$d"; build_and_deploy)
done done
}
if [ "$1" == "--dry-run" ]; then
dryRun=true && run
elif [ -z "$1" ]; then
run
else
help
fi