From c6f74ff8539330dd912de35c4e384f4cecab8a1b Mon Sep 17 00:00:00 2001 From: Dani Donisa Date: Mon, 28 Oct 2024 16:43:50 +0100 Subject: [PATCH] Make xargs to ignore commands if stdin is empty When we added a new gem, REMOVED_GEMS was empty, and the `basename` command crashed. Not anymore. When there is nothing coming from ADDED_GEMS (because we remove the gem) or REMOVED_GEMS (because we add a new gem) `xargs` will not crash anymore. --- .github/workflows/create_diffend_io_links.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/create_diffend_io_links.yml b/.github/workflows/create_diffend_io_links.yml index 975d4533999..9fcb2833229 100644 --- a/.github/workflows/create_diffend_io_links.yml +++ b/.github/workflows/create_diffend_io_links.yml @@ -18,8 +18,8 @@ jobs: run: | # Receive added and removed file names from the git diff, filter out everything besides the gem files and receive # the basename without the gem file extension - ADDED_GEMS=( $(git diff --name-only --diff-filter=A origin/${GITHUB_BASE_REF} $GITHUB_SHA | grep .gem$ | xargs basename -s .gem) ) - REMOVED_GEMS=( $(git diff --name-only --diff-filter=D origin/${GITHUB_BASE_REF} $GITHUB_SHA | grep .gem$ | xargs basename -s .gem) ) + ADDED_GEMS=( $(git diff --name-only --diff-filter=A origin/${GITHUB_BASE_REF} $GITHUB_SHA | grep .gem$ | xargs -r basename -s .gem) ) + REMOVED_GEMS=( $(git diff --name-only --diff-filter=D origin/${GITHUB_BASE_REF} $GITHUB_SHA | grep .gem$ | xargs -r basename -s .gem) ) COMMENT_TEXT="Please see the links listed bellow to review the changes applied to the gems:"$'\n'