From 9af1e198dfc811ded9d319b74c107982d7e3de09 Mon Sep 17 00:00:00 2001 From: Raph Cohn Date: Mon, 16 Nov 2015 11:43:50 +0000 Subject: [PATCH 1/3] Minor adjustment to make it easier to follow local variables --- api/v3/releases.functions | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/api/v3/releases.functions b/api/v3/releases.functions index e3d9396..ae0d6a4 100644 --- a/api/v3/releases.functions +++ b/api/v3/releases.functions @@ -118,10 +118,13 @@ github_api_v3_releases_uploadAsset() local contentType="$3" local label="$4" + local urlencode_template_variable_name="$(core_compatibility_basename "$filePath")" + local urlencode_template_variable_label="$label" + local url="$(urlencode_template "$uploadUrlTemplate")" + local curl_uploadFile="$filePath" local curl_httpStatusCode - local urlencode_template_variable_name="$(core_compatibility_basename "$filePath")" - _github_api_v3_absolute_PUT "$(urlencode_template "$uploadUrlTemplate")" 'Content-Type' "$contentType" + _github_api_v3_absolute_PUT "$url" 'Content-Type' "$contentType" unset curl_uploadFile if [ $curl_httpStatusCode -ne 201 ]; then From 7005ef2b90d990119bc992b974312de89450bc9d Mon Sep 17 00:00:00 2001 From: Raphael Cohn Date: Wed, 25 Nov 2015 12:07:28 +0000 Subject: [PATCH 2/3] Extra debugging --- api/v3/v3.functions | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/api/v3/v3.functions b/api/v3/v3.functions index 799d687..05e3a30 100644 --- a/api/v3/v3.functions +++ b/api/v3/v3.functions @@ -50,8 +50,11 @@ github_api_v3_timestampToEpochSeconds() core_dependency_requires '*' cat _github_api_v3_errorMessageExit() { - local errorMessage='' - local requestId='' + local verb="$1" + local url="$2" + + local errorMessage='(unknown)' + local requestId='(unknown)' local resource='' local code='' @@ -106,15 +109,15 @@ _github_api_v3_errorMessageExit() case $(core_variable_array_length errors) in 0) - core_exitError $core_commandLine_exitCode_DATAERR "GitHub error for request '$requestId' ($curl_httpStatusCode) was '$errorMessage'." + core_exitError $core_commandLine_exitCode_DATAERR "GitHub error for verb '$verb' to URL '$url' for request '$requestId' ($curl_httpStatusCode) was '$errorMessage'." ;; 1) - core_exitError $core_commandLine_exitCode_DATAERR "GitHub error for request '$requestId' ($curl_httpStatusCode) was '$errorMessage': $(core_variable_array_string errors "")" + core_exitError $core_commandLine_exitCode_DATAERR "GitHub error for verb '$verb' to URL '$url' for request '$requestId' ($curl_httpStatusCode) was '$errorMessage': $(core_variable_array_string errors "")" ;; *) - core_exitError $core_commandLine_exitCode_DATAERR "GitHub errors for request '$requestId' ($curl_httpStatusCode) was '$errorMessage' (Details: $(core_variable_array_string errors " "))" + core_exitError $core_commandLine_exitCode_DATAERR "GitHub errors for verb '$verb' to URL '$url' for request '$requestId' ($curl_httpStatusCode) was '$errorMessage' (Details: $(core_variable_array_string errors " "))" ;; esac @@ -216,22 +219,22 @@ _github_api_v3_absolute() # Bad Request (we sent an invalid JSON) 400) - _github_api_v3_errorMessageExit + _github_api_v3_errorMessageExit "$verb" "$url" ;; # Unprocessable Entity (we sent an invalid field in the body) 422) - _github_api_v3_errorMessageExit + _github_api_v3_errorMessageExit "$verb" "$url" ;; # Unauthorized (not always) 401) - _github_api_v3_errorMessageExit + _github_api_v3_errorMessageExit "$verb" "$url" ;; # Unauthorized or Rate-Limited 403) - _github_api_v3_errorMessageExit + _github_api_v3_errorMessageExit "$verb" "$url" ;; esac From 66766d16be52b4261154be00435ee9486dc60405 Mon Sep 17 00:00:00 2001 From: Raphael Cohn Date: Wed, 25 Nov 2015 12:31:23 +0000 Subject: [PATCH 3/3] Removing use of '' which doesn't work in all shells --- api/v3/v3.functions | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api/v3/v3.functions b/api/v3/v3.functions index 05e3a30..85b606d 100644 --- a/api/v3/v3.functions +++ b/api/v3/v3.functions @@ -15,6 +15,7 @@ core_usesIn urlencode template core_usesIn jsonreader core_usesIn jsonwriter +core_dependency_requires '*' cat github_api_v3_initialise() { local tokenFilePath="$1" @@ -25,8 +26,9 @@ github_api_v3_initialise() else github_api_v3_endpoint='https://api.github.com' fi - - local githubOAuth2PersonalAccessToken="$(<"$tokenFilePath")" + + # "$(