ezyang / ghstack

Submit stacked diffs to GitHub on the command line
MIT License
657 stars 55 forks source link

`ghstack land` doesn't work on private non-pro repositories #249

Open Artamus opened 7 months ago

Artamus commented 7 months ago

Hi ghstack team,

During my playing around with ghstack in a private repository I found that ghstack land won't work on private repositories that don't have GitHub Pro.

This is the error message I'm receiving when trying to land a PR:

ghstack land https://github.com/Artamus/stacked-diff-test/pull/10
ERROR: Fatal exception
Traceback (most recent call last):
  File "/home/artamus/.local/lib/python3.10/site-packages/ghstack/github_real.py", line 198, in rest
    resp.raise_for_status()
  File "/home/artamus/.local/lib/python3.10/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://api.github.com/repos/Artamus/stacked-diff-test/branches/main/protection

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/artamus/.local/lib/python3.10/site-packages/ghstack/logs.py", line 105, in manager
    yield
  File "/home/artamus/.local/lib/python3.10/site-packages/ghstack/cli.py", line 46, in cli_context
    yield shell, config, github
  File "/home/artamus/.local/lib/python3.10/site-packages/ghstack/cli.py", line 135, in land
    ghstack.land.main(
  File "/home/artamus/.local/lib/python3.10/site-packages/ghstack/land.py", line 72, in main
    protection = github.get(
  File "/home/artamus/.local/lib/python3.10/site-packages/ghstack/github.py", line 67, in get
    return self.rest("get", path, **kwargs)
  File "/home/artamus/.local/lib/python3.10/site-packages/ghstack/github_real.py", line 200, in rest
    raise RuntimeError(pretty_json)
RuntimeError: {
 "message": "Upgrade to GitHub Pro or make this repository public to enable this feature.",
 "documentation_url": "https://docs.github.com/rest/branches/branch-protection#get-branch-protection"
}

To reproduce, simply create a private repository and try to create a stack of 2 commits and land them with ghstack.

ezyang commented 7 months ago

lol. you can comment out the protection test and it won't affect anything else haha

Artamus commented 7 months ago

Thanks, that definitely works when running it for my own uses :D.

As far as I can tell ghstack is used as part of the Sapling tooling? Also, is there some sort of publicly available roadmap / design doc for ghstack (I'm interested in where you'd like this project to end up)?