Repository navigation
Conversation
Also fixes a bug where XXNetworkErrorXX wouldn’t be caught due to value of $? changing after rm call.
ekalinin
left a comment
There was a problem hiding this comment.
Thanks for the PR. A few things need to be fixed before it can be merged:
-
Conflicts with master. The PR is based on 0.10.0. The
$?fix is already on master ascurl_status(#172), and the whole-file shfmt reformat touches most of the functions changed since then (--depth,--numbered, lint fixes). Please rebase onto current master and keep only the bad-credentials change, without the reformat. -
--insertwipes the TOC on GNU sed. The shfmt commit changed the probe toif ! sed --version || true >/dev/null 2>&1, which is always true, so GNU sed also getssed -i "". On Linux the old TOC is deleted, the new one is not inserted, and the tool still prints!! TOC was added. With--no-backupthe backup is removed too. The existing tests don't catch it because they don't check the file after--insert. -
False "bad credentials" error.
awk '/Bad credentials/'runs over the rendered HTML of the user's document, so any markdown that mentions "Bad credentials" fails with exit 1 even with a valid token. Checking the HTTP status (401) instead of the response body would avoid this. -
No tests. Please add a test for the bad-credentials case, e.g.
GH_TOC_TOKEN=invalid gh-md-toc README.mdexpecting exit 1 and the error message.
The blanket reformat conflicts with most functions changed upstream and broke the GNU sed probe (sed -i "" on Linux). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Nj7TK1eX93Wj8qZBBkbvdR
Resolves conflicts with upstream (the curl exit-status fix already landed there as curl_status in ekalinin#172) and addresses review feedback: - Detect bad credentials via HTTP 401 instead of grepping the rendered HTML, so markdown that mentions "Bad credentials" no longer fails. - Only treat "API rate limit exceeded" as a rate limit on a non-200 response, fixing the same false positive. - Report other non-200 API responses as an error instead of producing an empty TOC. - Point the bad-credentials hint at whichever token source was used (GH_TOC_TOKEN or token.txt). - Add tests for an invalid token and for docs mentioning API error text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Nj7TK1eX93Wj8qZBBkbvdR
|
Thanks for the review. I've pushed changes for all four points:
The bad-credentials message now says which token source was used ( |
Also: