From ccedafb019f7287010f89742d42ac46afe1fdb52 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Wed, 18 Apr 2018 22:15:05 +0200 Subject: Get rid of the `$NEW_PRS` variable Looking over the code again it dawned on me that this variable is unnecessary and overcomplicates the code. Just pass in the result from before as an argument to the function. --- redprine | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/redprine b/redprine index 2b93085..fd21649 100755 --- a/redprine +++ b/redprine @@ -13,8 +13,6 @@ REDMINE_TOKEN='' CACHE_FILE="$HOME/redprine.json" -NEW_PRS='' - function github_owner_repo () { local git_remote=$(git remote get-url origin) local owner_repo=$(echo "$git_remote" | @@ -193,7 +191,9 @@ function update_redmine_status () { } function update_cache_with_new_pulls () { - jq "${NEW_PRS} + ." "$CACHE_FILE" > "${CACHE_FILE}.new" + local new_pull_requests="$1" + + jq "$new_pull_requests" "$CACHE_FILE" > "${CACHE_FILE}.new" mv "${CACHE_FILE}.new" "$CACHE_FILE" } @@ -202,8 +202,7 @@ function update_cache_with_new_pulls () { # pull_requests=$(fetch_pull_requests) # cache_my_pull_requests "$pull_requests" pr_json=$(new_pull_requests) -NEW_PRS="$pr_json" issue_prs=$(issue_numbers_and_pull_request_urls "$pr_json") update_redmine_statuses "$issue_prs" -update_cache_with_new_pulls +update_cache_with_new_pulls "$pr_json" -- cgit v1.2.3