Update release scripts for branches
[policy/parent.git] / integration / src / release_scripts / generateCommit.sh
index 3277592..29e600a 100755 (executable)
@@ -4,7 +4,7 @@
 # ============LICENSE_START================================================
 # ONAP
 # =========================================================================
-# Copyright (C) 2021 Nordix Foundation.
+# Copyright (C) 2021-2022 Nordix Foundation.
 # =========================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -20,7 +20,9 @@
 # ============LICENSE_END==================================================
 #
 
-SCRIPT_NAME=`basename $0`
+set -e
+
+SCRIPT_NAME=$(basename "$0")
 repo_location="./"
 
 usage()
@@ -45,13 +47,6 @@ usage()
     exit 255;
 }
 
-update_parent=false
-update_common=false
-update_models=false
-update_drools_pdp=false
-update_snapshot=false
-update_docker=false
-
 while getopts "hl:r:i:e:m:" opt
 do
     case $opt in
@@ -127,7 +122,7 @@ then
     exit 1
 fi
 
-git -C $repo_location/$specified_repo status | grep '^Your branch is up to date' > /dev/null 2>&1
+git -C "$repo_location/$specified_repo" status | grep '^Your branch is up to date' > /dev/null 2>&1
 return_code=$?
 
 if [ $return_code -eq 0 ]
@@ -135,30 +130,32 @@ then
     echo "generating commit '$commit_header' . . ."
 
     commit_msg_temp_file=$(mktemp)
-    echo "$commit_header"                                           > $commit_msg_temp_file
-    echo ""                                                        >> $commit_msg_temp_file
-    echo "*** This commit is generated by a PF release script ***" >> $commit_msg_temp_file
-    echo ""                                                        >> $commit_msg_temp_file
-    echo "$commit_message"                                         >> $commit_msg_temp_file
-    echo ""                                                        >> $commit_msg_temp_file
-    echo "Issue-ID: $issue_id"                                     >> $commit_msg_temp_file
-
-    git -C $repo_location/$specified_repo add .
-    git -C $repo_location/$specified_repo commit -s -F "$commit_msg_temp_file"
-    rm $commit_msg_temp_file
+    {
+        echo "$commit_header"
+        echo ""
+        echo "$commit_message"
+        echo ""
+        echo "*** This commit is generated by a PF release script ***"
+        echo ""
+        echo "Issue-ID: $issue_id"
+    } > "$commit_msg_temp_file"
+
+    git -C "$repo_location/$specified_repo" add .
+    git -C "$repo_location/$specified_repo" commit -s -F "$commit_msg_temp_file"
+    rm "$commit_msg_temp_file"
 
     echo "commit '$commit_header' generated"
 else
     echo "updating commit '$commit_header' . . ."
 
-    git -C $repo_location/$specified_repo add .
-    git -C $repo_location/$specified_repo commit -as --amend --no-edit
+    git -C "$repo_location/$specified_repo" add .
+    git -C "$repo_location/$specified_repo" commit -as --amend --no-edit
 
     echo "commit '$commit_header' updated"
 fi
 
 echo "sending commit '$commit_header' to gerrit . . ."
-git -C $repo_location/$specified_repo review
+git -C "$repo_location/$specified_repo" review
 echo "commit '$commit_header' sent to gerrit . . ."