jeffwidman / bitbucket-issue-migration

A small script for migrating repo issues from Bitbucket to GitHub
GNU General Public License v3.0
316 stars 95 forks source link

Doesn't work for private Github repos #115

Closed Daniel15 closed 5 years ago

Daniel15 commented 5 years ago

I get this error when I try to import into a private repo:

λ python3 migrate.py -bu Daniel15 Daniel15/example Daniel15/example Daniel15
Please enter your GitHub password.
Note: If your GitHub account has authentication enabled, you must use a personal access token from https://github.com/settings/tokens in place of a password for this script.

Traceback (most recent call last):
  File "migrate.py", line 877, in <module>
    sys.exit(main(options))
  File "migrate.py", line 198, in main
    raise RuntimeError("Could not find a GitHub repo at: " + gh_repo_url)
RuntimeError: Could not find a GitHub repo at: https://api.github.com/repos/Daniel15/example

It works fine for public repos, so I just temporarily made my repo public in order to import the issues.

Now that Github allows everyone to have private repos (even free users), this should be easy to replicate.

Daniel15 commented 5 years ago

Actually ignore me, I think this was just me not configuring the permissions properly. It worked the second time I tried.

jeffwidman commented 5 years ago

Glad you figured it out and thanks for letting me know.

Blaisorblade commented 5 years ago

Actually ignore me, I think this was just me not configuring the permissions properly. It worked the second time I tried.

Well, this tool could document what permissions are needed. write:discussion and repo:status are not enough. It worked for me with repo, write:discussion. I'm PRing a tentative documentation fix.

Also, the error-reporting code gives a misleading message (altho it doesn't have extra info).

   if gh_repo_status == 401:
        raise RuntimeError("Failed to login to GitHub.")
    elif gh_repo_status == 403:
        raise RuntimeError(
            "GitHub login succeeded, but user '{}' either doesn't have "
            "permission to access the repo at: {}\n"
            "or is over their GitHub API rate limit.\n"
            "You can read more about GitHub's API rate limiting policies here: "
            "https://developer.github.com/v3/#rate-limiting"
            .format(options.github_username, gh_repo_url)
        )
    elif gh_repo_status == 404:
        raise RuntimeError("Could not find a GitHub repo at: " + gh_repo_url)

EDIT: forgot an important thing: thanks for this very useful tool!