aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2018-04-18 21:59:42 +0200
committerTeddy Wing2018-04-18 21:59:42 +0200
commitc3f749355ecde0f1d79524fa9b00f47e32e1437f (patch)
treed4befa8e929fea28ee94d2038674e56c335e19a8
parent66e904022aaf55e66b2348ea1d6a45b0b089b59c (diff)
downloadredprine-c3f749355ecde0f1d79524fa9b00f47e32e1437f.tar.bz2
new_pull_requests(): Use custom JSON structure
This function was broken because we were trying to subtract untreated GitHub JSON from our custom saved JSON hashes. To fix it, run the newly-fetched GitHub JSON through a version of our data extractor that for now is just copy-pasted from above.
-rwxr-xr-xredprine22
1 files changed, 21 insertions, 1 deletions
diff --git a/redprine b/redprine
index 7ab7b94..dadba2a 100755
--- a/redprine
+++ b/redprine
@@ -68,7 +68,10 @@ function cache_my_pull_requests () {
function new_pull_requests () {
local pull_requests=$(fetch_pull_requests)
- local new=$(jq "${pull_requests} - ." "$CACHE_FILE")
+ local my_prs=$(extract_data_from_pull_request_json "$pull_requests")
+ # echo "$my_prs"
+
+ local new=$(jq "${my_prs} - ." "$CACHE_FILE")
echo "$new"
}
@@ -76,6 +79,23 @@ function new_pull_requests () {
# jq '[ { "html_url": "https://github.com/owner/repo/pull/487", "number": 487, "user": "teddywing", "ref": "9999-this-is-a-test", "created_at": "2018-04-16T16:17:52Z" } ] - .' pulls-my.json #=> []
# jq '[ { "html_url": "https://github.com/owner/repo/pull/487", "number": 487, "user": "teddywing", "ref": "9999-this-is-a-test", "created_at": "2018-04-16T16:17:52Z" } ] - . | length' pulls-my.json #=> 0
+function extract_data_from_pull_request_json () {
+ local pull_requests="$1"
+
+ printf "%s\n" "$pull_requests" |
+ jq --compact-output '. |
+ map({
+ html_url,
+ number,
+ user: .user.login,
+ ref: .head.ref,
+ created_at
+ }) |
+ map(
+ select(.user == "teddywing")
+ )'
+}
+
function extract_redmine_issue_numbers_from_pull_request () {
local pull_requests="$1"