From d070a09cbc6348a8e0daea4733ac12d7d2c1e54a Mon Sep 17 00:00:00 2001 From: vsoch Date: Wed, 8 Apr 2020 11:46:20 -0600 Subject: [PATCH] replacing all echos with printf To be consistent, echo statements should be replaced with printf with a newline. Conversation with wchagrin mentioned that using printf is better practice than echo and I want to be consistent. Signed-off-by: vsoch --- scripts/entrypoint.sh | 10 +++++----- scripts/pull_request.sh | 16 ++++++++-------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh index d4b2adc..cc0f47b 100755 --- a/scripts/entrypoint.sh +++ b/scripts/entrypoint.sh @@ -7,18 +7,18 @@ set -o pipefail # We derive variables from the environment instead of command line # Tell the user files found immediately -echo "Found files in workspace:" +printf "Found files in workspace:\n" ls # Project file and if are both required for generation! # The action requires, but we have the double check here for a fallback if [ -z "${INPUT_PROJECT_FILE}" ]; then - echo "Project file (project-file) is required" + printf "Project file (project-file) is required\n" exit 1 fi # Show the user where we are -echo "Present working directory is:" +printf "Present working directory is:\n" pwd ls @@ -51,7 +51,7 @@ node /code/bin/sourcecred.js scores "${INPUT_PROJECT}" | python3 -m json.tool > # Automated means that we push to a branch, otherwise we open a pull request if [ "${INPUT_AUTOMATED}" == "true" ]; then - echo "Automated PR requested" + printf "Automated PR requested\n" UPDATE_BRANCH="${INPUT_BRANCH_AGAINST}" else UPDATE_BRANCH="update/sourcecred-cred-$(date '+%Y-%m-%d')" @@ -74,7 +74,7 @@ git checkout -b "${UPDATE_BRANCH}" git branch if [ "${INPUT_AUTOMATED}" == "true" ]; then - git pull origin "${UPDATE_BRANCH}" || echo "Branch not yet on remote" + git pull origin "${UPDATE_BRANCH}" || printf "Branch not yet on remote\n" git add "${INPUT_TARGET}/*" git add "${INPUT_SCORES_JSON}" git commit -m "Automated deployment to update cred in ${INPUT_TARGET} $(date '+%Y-%m-%d')" diff --git a/scripts/pull_request.sh b/scripts/pull_request.sh index 06d147c..c19c3b5 100755 --- a/scripts/pull_request.sh +++ b/scripts/pull_request.sh @@ -26,7 +26,7 @@ PULLS_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls" check_credentials() { if [[ -z "${GITHUB_TOKEN}" ]]; then - echo "You must include the GITHUB_TOKEN as an environment variable." + printf "You must include the GITHUB_TOKEN as an environment variable.\n" exit 1 fi @@ -60,7 +60,7 @@ print(data[0]["head"]["ref"])') # Option 1: The pull request is already open if [[ "${PR}" == "${SOURCE}" ]]; then - printf '%s\n' "Pull request from ${SOURCE} to ${TARGET} is already open!" + printf '%s\n' "Pull request from ${SOURCE} to ${TARGET} is already open\n" # Option 2: Open a new pull request else @@ -70,7 +70,7 @@ print(data[0]["head"]["ref"])') set -x; curl -fsSL -K "${curl_config}" -X POST --data "${DATA}" "${PULLS_URL}" ) - echo $? + printf "$?\n" fi } @@ -85,7 +85,7 @@ main() { # User specified branch for PR if [ -z "${UPDATE_BRANCH}" ]; then - echo "You must specify a branch to PR from." + printf "You must specify a branch to PR from.\n" exit 1 fi printf '%s\n' "Branch for pull request is ${UPDATE_BRANCH}" @@ -101,8 +101,8 @@ main() { } -echo "========================================================================== -START: Creating SourceCred Cred Update Pull Request!"; +printf "========================================================================== +START: Creating SourceCred Cred Update Pull Request\n"; main "$@" -echo "========================================================================== -END: Finished"; +printf "========================================================================== +END: Finished\n";