brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [01/16] brooklyn-dist git commit: make-release-artifacts.sh: refactor reusable code
Date Thu, 17 Mar 2016 12:54:59 GMT
Repository: brooklyn-dist
Updated Branches:
  refs/heads/master 01ac8ad8d -> 5ee9370cc


make-release-artifacts.sh: refactor reusable code

fail(), confirm() and detect_version() are refactored into a separate
script, along with new function assert_in_project_root(), which is
sourced in.

Project: http://git-wip-us.apache.org/repos/asf/brooklyn-dist/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-dist/commit/9e4100d8
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-dist/tree/9e4100d8
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-dist/diff/9e4100d8

Branch: refs/heads/master
Commit: 9e4100d8866042aa3ac26d681d5c54ef90a4f887
Parents: 01ac8ad
Author: Richard Downer <richard@apache.org>
Authored: Tue Mar 15 13:50:09 2016 +0000
Committer: Richard Downer <richard@apache.org>
Committed: Wed Mar 16 15:39:17 2016 +0000

----------------------------------------------------------------------
 release/common.sh                 | 64 ++++++++++++++++++++++++++++++++++
 release/make-release-artifacts.sh | 43 +++--------------------
 2 files changed, 69 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/9e4100d8/release/common.sh
----------------------------------------------------------------------
diff --git a/release/common.sh b/release/common.sh
new file mode 100755
index 0000000..51ed3d4
--- /dev/null
+++ b/release/common.sh
@@ -0,0 +1,64 @@
+#!/bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+###############################################################################
+fail() {
+    echo >&2 "$@"
+    exit 1
+}
+
+###############################################################################
+confirm() {
+    # call with a prompt string or use a default
+    if [ "${batch_confirm_y}" == "true" ] ; then
+        true
+    else
+      read -r -p "${1:-Are you sure? [y/N]} " response
+      case $response in
+        [yY][eE][sS]|[yY]) 
+            true
+            ;;
+        *)
+            false
+            ;;
+      esac
+    fi
+}
+
+###############################################################################
+detect_version() {
+    if [ \! -z "${current_version}" ]; then
+        return
+    fi
+
+    set +e
+    current_version=$( xmlstarlet select -t -v '/_:project/_:version/text()' pom.xml 2>/dev/null
)
+    success=$?
+    set -e
+    if [ "${success}" -ne 0 -o -z "${current_version}" ]; then
+        fail Could not detect version number
+    fi
+}
+
+###############################################################################
+assert_in_project_root() {
+    [ -d .git ] || fail Must run in brooklyn project root directory
+}
+

http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/9e4100d8/release/make-release-artifacts.sh
----------------------------------------------------------------------
diff --git a/release/make-release-artifacts.sh b/release/make-release-artifacts.sh
index 90f138e..7bd2f18 100755
--- a/release/make-release-artifacts.sh
+++ b/release/make-release-artifacts.sh
@@ -25,11 +25,12 @@
 
 set -e
 
-###############################################################################
-fail() {
-    echo >&2 "$@"
+release_script_dir=$( cd $( dirname $0 ) && pwd )
+[ -f "${release_script_dir}/common.sh" ] || {
+    echo >&2 "Could not find common.sh in the same directory as this script"
     exit 1
 }
+. "${release_script_dir}/common.sh"
 
 ###############################################################################
 show_help() {
@@ -59,39 +60,6 @@ END
 }
 
 ###############################################################################
-confirm() {
-    # call with a prompt string or use a default
-    if [ "${batch_confirm_y}" == "true" ] ; then
-        true
-    else
-      read -r -p "${1:-Are you sure? [y/N]} " response
-      case $response in
-        [yY][eE][sS]|[yY]) 
-            true
-            ;;
-        *)
-            false
-            ;;
-      esac
-    fi
-}
-
-###############################################################################
-detect_version() {
-    if [ \! -z "${current_version}" ]; then
-        return
-    fi
-
-    set +e
-    current_version=$( xmlstarlet select -t -v '/_:project/_:version/text()' pom.xml 2>/dev/null
)
-    success=$?
-    set -e
-    if [ "${success}" -ne 0 -o -z "${current_version}" ]; then
-        fail Could not detect version number
-    fi
-}
-
-###############################################################################
 # Argument parsing
 rc_suffix=
 OPTIND=1
@@ -121,7 +89,7 @@ shift $((OPTIND-1))
 
 ###############################################################################
 # Prerequisite checks
-[ -d .git ] || fail Must run in brooklyn project root directory
+assert_in_project_root
 
 detect_version
 
@@ -135,7 +103,6 @@ else
     artifact_name=${release_name}-rc${rc_suffix}
 fi
 
-release_script_dir=$( cd $( dirname $0 ) && pwd )
 brooklyn_dir=$( pwd )
 rm -rf ${release_script_dir}/tmp
 staging_dir="${release_script_dir}/tmp/source/"


Mime
View raw message