Skip to content

Commit f0f274f

Browse files
refactor: shell conditionals to use double brackets (#46)
1 parent 6e40d38 commit f0f274f

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

copr-ci.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ git clone "https://github.com/${COPR_OWNER}/${COPR_PACKAGE}.git" --depth 1
77
cd "${COPR_PACKAGE}"
88

99
# get info from the webhook payload
10-
if test -z "$REVISION"; then
10+
if [[ -z "$REVISION" ]]; then
1111
# the hook_payload file contains webhook JSON payload (copr creates it for us);
1212
# it is created only if the build is triggered by Custom webhook.
13-
if test -f "$resultdir"/hook_payload; then
13+
if [[ -f "$resultdir"/hook_payload ]]; then
1414
git clone https://github.com/praiskup/copr-ci-tooling \
1515
"$resultdir/cct" --depth 1
1616
export PATH="$resultdir/cct:$PATH"
@@ -21,7 +21,7 @@ if test -z "$REVISION"; then
2121

2222
# use jq to get the pr_id from the hook_payload
2323
PR=$(jq -r '.pr_id // empty' "$resultdir"/hook_payload)
24-
if [ -z "$PR" ]; then
24+
if [[ -z "$PR" ]]; then
2525
BRANCH="master"
2626
else
2727
BRANCH="pr/${PR}"
@@ -38,7 +38,7 @@ git submodule update --init --recursive
3838

3939
# get the tag of this commit IF it has one
4040
TAG=$(git tag --points-at HEAD | head -n1)
41-
if [ -z "$TAG" ]; then
41+
if [[ -z "$TAG" ]]; then
4242
TAG="0.0.$PR"
4343
fi
4444
TAG="${TAG#v}" # remove v prefix from the tag
@@ -54,7 +54,7 @@ directories=(
5454
"./packaging/linux/fedora"
5555
)
5656
for dir in "${directories[@]}"; do
57-
if [ -f "${dir}/${COPR_PACKAGE}.spec" ]; then
57+
if [[ -f "${dir}/${COPR_PACKAGE}.spec" ]]; then
5858
echo "Found spec file in ${dir}"
5959
rpmlint "${dir}/${COPR_PACKAGE}.spec"
6060

@@ -64,8 +64,8 @@ for dir in "${directories[@]}"; do
6464
done
6565

6666
# fail if the spec file is not in the resultdir
67-
if [ ! -f "${resultdir}/${COPR_PACKAGE}.spec" ]; then
68-
echo "ERROR: ${COPR_PACKAGE}.spec not found"
67+
if [[ ! -f "${resultdir}/${COPR_PACKAGE}.spec" ]]; then
68+
echo "ERROR: ${COPR_PACKAGE}.spec not found" >&2
6969
exit 1
7070
fi
7171

0 commit comments

Comments
 (0)