RFR: Accept trailing slash in URIs for git fork.

Jan Lahoda jlahoda at openjdk.java.net
Thu Apr 9 09:51:31 UTC 2020


Consider a command like this:
$ git fork https://github.com/openjdk/skara/

This fails with a fairly cryptic error:
Apr 09, 2020 11:39:44 AM org.openjdk.skara.network.RestRequest transformBadResponse
WARNING: org.openjdk.skara.network.RestRequest$QueryBuilder at 2a17b7b6
Apr 09, 2020 11:39:44 AM org.openjdk.skara.network.RestRequest transformBadResponse
WARNING: {"message":"Not Found","documentation_url":"https://developer.github.com/v3"}
Exception in thread "main" java.lang.RuntimeException: Request returned bad status: 404
        at org.openjdk.skara.network/org.openjdk.skara.network.RestRequest.transformBadResponse(RestRequest.java:285)
        at org.openjdk.skara.network/org.openjdk.skara.network.RestRequest.execute(RestRequest.java:325)
        at org.openjdk.skara.network/org.openjdk.skara.network.RestRequest$QueryBuilder.execute(RestRequest.java:156)
        at org.openjdk.skara.forge/org.openjdk.skara.forge.github.GitHubRepository.fork(GitHubRepository.java:231)
        at org.openjdk.skara.cli/org.openjdk.skara.cli.GitFork.main(GitFork.java:278)
        at org.openjdk.skara.cli/org.openjdk.skara.cli.GitSkara.main(GitSkara.java:186)

The cause is the trailing '/', which is normally accepted when accessing the repository through a web browser, or when
cloning the repository. This patch changes the git fork to also accept trailing slashes, by removing them before the
GitHubRepository repository instance is created. It is not quite clear if this should be solved at some other level,
but felt like a better approach to keep the APIs clean (i.e. just plain repository names), and do normalization in the
UI tools.

-------------

Commit messages:
 - Accept trailing slash in URIs for git fork.

Changes: https://git.openjdk.java.net/skara/pull/575/files
 Webrev: https://webrevs.openjdk.java.net/skara/575/webrev.00
  Stats: 8 lines in 1 file changed: 7 ins; 0 del; 1 mod
  Patch: https://git.openjdk.java.net/skara/pull/575.diff
  Fetch: git fetch https://git.openjdk.java.net/skara pull/575/head:pull/575

PR: https://git.openjdk.java.net/skara/pull/575


More information about the skara-dev mailing list