aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2018-04-18 22:08:14 +0200
committerTeddy Wing2018-04-18 22:08:14 +0200
commite0ea6a97407746dc43aca20d6f5608873c162821 (patch)
tree5433889ec12ed95217ad2550f1cbdd5cc4fe6d2b
parenta7b31fd5482ba822f2a3fd95fe35069cdf427bec (diff)
downloadredprine-e0ea6a97407746dc43aca20d6f5608873c162821.tar.bz2
Cache updated pull requests after updating Redmine
Save the pull requests that we treated and updated Redmine issues for to our cache file to ensure we don't make duplicate Redmine update requests for those PRs the next time the script is run.
-rwxr-xr-xredprine9
1 files changed, 9 insertions, 0 deletions
diff --git a/redprine b/redprine
index eadec8a..aff2316 100755
--- a/redprine
+++ b/redprine
@@ -12,6 +12,8 @@ REDMINE_BASE_URL=''
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" |
@@ -183,11 +185,18 @@ function update_redmine_status () {
--location "${REDMINE_BASE_URL}/issues/${issue_id}.json"
}
+function update_cache_with_new_pulls () {
+ jq "${NEW_PRS} + ." "$CACHE_FILE" > "${CACHE_FILE}.new"
+ mv "${CACHE_FILE}.new" "$CACHE_FILE"
+}
+
# 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