aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/bash/function/branch.sh
diff options
context:
space:
mode:
authorVratko Polak <vrpolak@cisco.com>2019-07-10 13:59:50 +0200
committerPeter Mikus <pmikus@cisco.com>2019-07-10 14:23:48 +0000
commit36d56bdb7f9f394047e2df3f29bf47db877b649c (patch)
treede01e08334759f2f41b30dabcbd179b94015b0e0 /resources/libraries/bash/function/branch.sh
parente45404bf7b8cbdb10adf85815c2e005134e463ad (diff)
Bash functions style cleanup
+ Update rst documentation for bash style + Command substitution: + Clarify when to use backticks. + Recommend avoiding nested command substitution. + Do not recommend putting command substitution results into quotes. + Function definition content: + Move "set -exuo pipefail" after comment only blocks. + Other set flags allowed for functions with good reasons. + Apply the new recommendations. - Blank lines unified in code but no written recommendation in rst. + Add missing references to functions called, variables read or set. + Add TODOs to where lists would be long. + Minor improvements to function descriptions. + Make "if" expressions more python-like. + Add missing "|| die" (or "|| true") where spotted. + Downgrade DEFAULT_NIC to a local variable. + Add TODO to list reasons for blacklisted tags. Change-Id: I05dce030a8c2cb1b3a242d8b977e8fe150d8ee20 Signed-off-by: Vratko Polak <vrpolak@cisco.com>
Diffstat (limited to 'resources/libraries/bash/function/branch.sh')
-rw-r--r--resources/libraries/bash/function/branch.sh12
1 files changed, 6 insertions, 6 deletions
diff --git a/resources/libraries/bash/function/branch.sh b/resources/libraries/bash/function/branch.sh
index e340a0c658..558a2b617e 100644
--- a/resources/libraries/bash/function/branch.sh
+++ b/resources/libraries/bash/function/branch.sh
@@ -21,8 +21,6 @@ set -exuo pipefail
function checkout_csit_for_vpp () {
- set -exuo pipefail
-
# This should be useful mainly for vpp-csit jobs (and timed csit-vpp jobs),
# which want to use csit oper branches (especially for vpp stable branches).
# This allows the Jenkins job to checkout CSIT master branch,
@@ -51,6 +49,8 @@ function checkout_csit_for_vpp () {
# Functions called:
# - die - Print to stderr and exit, defined in "common" library.
+ set -exuo pipefail
+
case "${1}" in
"stable/"*)
branch_id="origin/${1/stable\//oper-rls}"
@@ -74,10 +74,10 @@ function checkout_csit_for_vpp () {
csit_branch="${csit_branch#origin/}" || die
override_ref="${CSIT_REF-}"
if [[ -n "${override_ref}" ]]; then
- git fetch --depth=1 https://gerrit.fd.io/r/csit "${override_ref}"
- git checkout FETCH_HEAD
+ git fetch --depth=1 https://gerrit.fd.io/r/csit "${override_ref}" || die
+ git checkout FETCH_HEAD || die
else
- git checkout "${csit_branch}"
+ git checkout "${csit_branch}" || die
fi
- popd
+ popd || die
}