Closed a-t-0 closed 1 year ago
assert_set_build_status_of_github_commit_using_github_pat
function into can_set_build_status_of_github_commit_using_github_pat
right below it.The parent function calls the assert directly with expecting the state: pending
in:
has_working_github_pat() {
local github_username="$1"
local latest_commit_on_default_branch="$(get_latest_commit_public_github_repo "$github_username" "$PUBLIC_GITHUB_TEST_REPO_GLOBAL")"
# TODO: remove assert from has function.
pat_usage_output=$(assert_set_build_status_of_github_commit_using_github_pat "$github_username" "$PUBLIC_GITHUB_TEST_REPO_GLOBAL" "$latest_commit_on_default_branch" "$GITLAB_SERVER_HTTP_URL" "pending")
if [ "$pat_usage_output" == "USED GITHUB PAT" ]; then
echo "FOUND"
else
echo "NOTFOUND"
fi
}
However, if the commit status is already set to Pending, it needs to be swapped at least once to make a succesfull verification.
can_set_build_status_of_github_commit_using_github_pat
function returns FOUND
even if some of the above requirements are not met, e.g. output:
bash -c 'source src/import.sh && has_set_build_status_of_github_commit_using_github_pat a-t-0 sponsor_example 02c5fce3500d7b9e2d79cb5b7d886020a403cf58 http://127.0.0.1 pending'
The github personal access token is empty, whereas it shouldn't be.
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 165 100 90 100 75 232 193 --:--:-- --:--:-- --:--:-- 427
The github personal access token is not valid. Please make a new one (or try again, it has been deleted from ../personal_creds.txt). See https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token and ensure you tick. {
"message": "Bad credentials",
"documentation_url": "https://docs.github.com/rest"
}
urls_in_json="https://api.github.com/repos/a-t-0/sponsor_example/statuses/02c5fce3500d7b9e2d79cb5b7d886020a403cf58"
"https://api.github.com/repos/a-t-0/sponsor_example/statuses/02c5fce3500d7b9e2d79cb5b7d886020a403cf58"
"https://api.github.com/repos/a-t-0/sponsor_example/statuses/02c5fce3500d7b9e2d79cb5b7d886020a403cf58"
"https://api.github.com/repos/a-t-0/sponsor_example/statuses/02c5fce3500d7b9e2d79cb5b7d886020a403cf58"
"https://api.github.com/repos/a-t-0/sponsor_example/statuses/02c5fce3500d7b9e2d79cb5b7d886020a403cf58"
"https://api.github.com/repos/a-t-0/sponsor_example/statuses/02c5fce3500d7b9e2d79cb5b7d886020a403cf58"
"https://api.github.com/repos/a-t-0/sponsor_example/statuses/02c5fce3500d7b9e2d79cb5b7d886020a403cf58"
"https://api.github.com/repos/a-t-0/sponsor_example/statuses/02c5fce3500d7b9e2d79cb5b7d886020a403cf58"
"https://api.github.com/repos/a-t-0/sponsor_example/statuses/02c5fce3500d7b9e2d79cb5b7d886020a403cf58"
"https://api.github.com/repos/a-t-0/sponsor_example/statuses/02c5fce3500d7b9e2d79cb5b7d886020a403cf58"
"https://api.github.com/repos/a-t-0/sponsor_example/statuses/02c5fce3500d7b9e2d79cb5b7d886020a403cf58"
"https://api.github.com/repos/a-t-0/sponsor_example/statuses/02c5fce3500d7b9e2d79cb5b7d886020a403cf58"
"https://api.github.com/repos/a-t-0/sponsor_example/statuses/02c5fce3500d7b9e2d79cb5b7d886020a403cf58"
"https://api.github.com/repos/a-t-0/sponsor_example/statuses/02c5fce3500d7b9e2d79cb5b7d886020a403cf58"
"https://api.github.com/repos/a-t-0/sponsor_example/statuses/02c5fce3500d7b9e2d79cb5b7d886020a403cf58"
"https://api.github.com/repos/a-t-0/sponsor_example/statuses/02c5fce3500d7b9e2d79cb5b7d886020a403cf58"
"https://api.github.com/repos/a-t-0/sponsor_example/statuses/02c5fce3500d7b9e2d79cb5b7d886020a403cf58"
"https://api.github.com/repos/a-t-0/sponsor_example/statuses/02c5fce3500d7b9e2d79cb5b7d886020a403cf58"
"https://api.github.com/repos/a-t-0/sponsor_example/statuses/02c5fce3500d7b9e2d79cb5b7d886020a403cf58"
"https://api.github.com/repos/a-t-0/sponsor_example/statuses/02c5fce3500d7b9e2d79cb5b7d886020a403cf58"
"https://api.github.com/repos/a-t-0/sponsor_example/statuses/02c5fce3500d7b9e2d79cb5b7d886020a403cf58"
"https://api.github.com/repos/a-t-0/sponsor_example/statuses/02c5fce3500d7b9e2d79cb5b7d886020a403cf58"
"https://api.github.com/repos/a-t-0/sponsor_example/statuses/02c5fce3500d7b9e2d79cb5b7d886020a403cf58"
"https://api.github.com/repos/a-t-0/sponsor_example/statuses/02c5fce3500d7b9e2d79cb5b7d886020a403cf58"
"https://api.github.com/repos/a-t-0/sponsor_example/statuses/02c5fce3500d7b9e2d79cb5b7d886020a403cf58"
"https://api.github.com/repos/a-t-0/sponsor_example/statuses/02c5fce3500d7b9e2d79cb5b7d886020a403cf58"
"https://api.github.com/repos/a-t-0/sponsor_example/statuses/02c5fce3500d7b9e2d79cb5b7d886020a403cf58"
"https://api.github.com/repos/a-t-0/sponsor_example/statuses/02c5fce3500d7b9e2d79cb5b7d886020a403cf58"
"https://api.github.com/repos/a-t-0/sponsor_example/statuses/02c5fce3500d7b9e2d79cb5b7d886020a403cf58"
"https://api.github.com/repos/a-t-0/sponsor_example/statuses/02c5fce3500d7b9e2d79cb5b7d886020a403cf58"
expected_url=https://api.github.com/repos/a-t-0/sponsor_example/statuses/02c5fce3500d7b9e2d79cb5b7d886020a403cf58
found_state="state":"pending",
expected_state="state":"pending",
FOUND
So make sure those checks are required, and if yes, that the function does not return found if they are not satisfied.
Done. Used pre-existing alternative GitHub PAT is usable
function and removed the erroneous function. Verfied the alternative function works.
In
check_github_pat_usability.sh
: