Skip to content

Better error reporting for when a repo can't be found #8

@dwilding

Description

@dwilding

For example, I don't have a fork of https://github.com/canonical/multipass. If I run gimmegit multipass, gimmegit tries to clone https://github.com/dwilding/multipass (because I have GIMMEGIT_GITHUB_TOKEN set), but there's no such repo. gimmegit crashes:

Getting repo details
Traceback (most recent call last):
  File "/home/david.wilding@canonical.com/.local/bin/gimmegit", line 10, in <module>
    sys.exit(main())
             ~~~~^^
  File "/home/david.wilding@canonical.com/.local/share/uv/tools/gimmegit/lib/python3.13/site-packages/gimmegit/_cli.py", line 86, in main
    context = get_context(args)
  File "/home/david.wilding@canonical.com/.local/share/uv/tools/gimmegit/lib/python3.13/site-packages/gimmegit/_cli.py", line 169, in get_context
    upstream = get_github_upstream(owner, project)
  File "/home/david.wilding@canonical.com/.local/share/uv/tools/gimmegit/lib/python3.13/site-packages/gimmegit/_cli.py", line 243, in get_github_upstream
    repo = api.get_repo(f"{owner}/{project}")
  File "/home/david.wilding@canonical.com/.local/share/uv/tools/gimmegit/lib/python3.13/site-packages/github/MainClass.py", line 473, in get_repo
    headers, data = self.__requester.requestJsonAndCheck("GET", url)
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
  File "/home/david.wilding@canonical.com/.local/share/uv/tools/gimmegit/lib/python3.13/site-packages/github/Requester.py", line 622, in requestJsonAndCheck
    return self.__check(
           ~~~~~~~~~~~~^
        *self.requestJson(
        ^^^^^^^^^^^^^^^^^^
    ...<7 lines>...
        )
        ^
    )
    ^
  File "/home/david.wilding@canonical.com/.local/share/uv/tools/gimmegit/lib/python3.13/site-packages/github/Requester.py", line 790, in __check
    raise self.createException(status, responseHeaders, data)
github.GithubException.UnknownObjectException: 404 {"message": "Not Found", "documentation_url": "https://docs.github.com/rest/repos/repos#get-a-repository", "status": "404"}

gimmegit should catch this and log a useful error message.

Ideally, gimmegit should list any clones that I already have. I might have cloned canonical/multipass before, in which case I need reminding to run gimmegit canonical/multipass instead of gimmegit multipass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions