Fix handling of diff and commit comment URLs
While working on #1458, I noticed that the app handled diff URLs on PRs/commits and commit comment URLs incorrectly:
- URLs to diff lines in commits and PRs (those ending in `#diff-<hash>`) were being parsed as if the hash were the MD5 sum of the path, but the hash has been changed to be a SHA256 for a while now (at least since 2021 according to [some comments on StackOverflow](https://stackoverflow.com/questions/43996083/extraction-of-diff-hash-from-github-commit-url/69177495#69177495)) - fixed in d943b931
- the app incorrectly treated URLs ending in `#commitcomment-<id>` as URLs to comments _on the commit_ **or** to comments _on the commit diff_, but they can only be the former (fixed in 2300ddad84). The latter URLs always end in `#r<id>` instead (I suppose that GH changed them at some point to make them consistent with PR diff comment URLs).
In between those fixes I've made a few tweaks/optimizations:
- 823bd7f2: small change to preserve the same fallback behavior that was present before d943b931 when the diff hash in the URL is incorrect
- fd75edaa: I've removed the logic for fetching diff comments in `DiffLoadTask`s, which was duplicated with the one already present in `DiffViewerActivity`-s ([here](https://github.com/slapperwan/gh4a/blob/c00c5f3b4cdb505cf1313eebc5a0d6623e87fe88/app/src/main/java/com/gh4a/activities/CommitDiffViewerActivity.java#L89) and [here](https://github.com/slapperwan/gh4a/blob/c00c5f3b4cdb505cf1313eebc5a0d6623e87fe88/app/src/main/java/com/gh4a/activities/PullRequestDiffViewerActivity.java#L72)) that is triggered when comments are not passed in the Intent extras
- a3378d17: small optimization to parallelize API calls and avoid a duplicate request when handling a commit diff comment URL
I recommend reviewing this commit by commit.
合并状态:已合并 合并于 2025-04-19 关闭于 2025-04-19 0 条评论