Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚀 Feature: Fail setup more gracefully for branch protections on private, non-Pro repos #401

Closed
3 tasks done
JoshuaKGoldberg opened this issue May 3, 2023 · 3 comments · Fixed by #423
Closed
3 tasks done
Labels
status: accepting prs Please, send a pull request to resolve this! type: feature New enhancement or request

Comments

@JoshuaKGoldberg
Copy link
Owner

Bug Report Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have pulled the latest main branch of the repository.
  • I have searched for related issues and found none that matched my issue.

Overview

Forking from #398: apparently you must have GitHub Pro to set branch protections on a private repo. TIL. Right now the setup script fails with:


◇  ❌ Error hydrating initial repository settings.
│
└  Looks like there was a problem. Correct it and try again? 😕


Error: Could not hydrate initial repository settings. 
    at withSpinner (file:///Users/josh/repos/testing-private-repo/script/setup.js:166:10)
    at async file:///Users/josh/repos/testing-private-repo/script/setup.js:430:3 {
  [cause]: RequestError [HttpError]: Not Found
      at /Users/josh/repos/testing-private-repo/node_modules/.pnpm/@[email protected]/node_modules/@octokit/request/dist-node/index.js:78:21
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async requestWithGraphqlErrorHandling (/Users/josh/repos/testing-private-repo/node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@octokit/plugin-retry/dist-node/index.js:42:20)
      at async Job.doExecute (/Users/josh/repos/testing-private-repo/node_modules/.pnpm/[email protected]/node_modules/bottleneck/light.js:405:18) {
    status: 404,
    response: {
      url: 'https://api.github.com/repos/asdf/testing-private-repo',
      status: 404,
      headers: [Object],
      data: [Object]
    },
    request: {
      method: 'PATCH',
      url: 'https://api.github.com/repos/asdf/testing-private-repo',
      headers: [Object],
      body: '{"allow_auto_merge":true,"allow_rebase_merge":false,"allow_squash_merge":true,"default_branch":"main","delete_branch_on_merge":true,"description":"asdf","has_wiki":false}',
      request: [Object]
    }
  }
}

...so much noise! And there's really no need to cancel the rest of setup & mark the whole thing as failed.

Instead, let's mention the error and continue gracefully. How about something like...


◇  ✅ Hydrated initial repository settings.
│
◇  ⚠️ Could not hydrate branch protection settings: private repositories require GitHub Pro for that API.
│
◇  ✅ Finished API hydration.

(that's just a starting suggestion I haven't put much thought into - please improve it if you have any ideas!)

Additional Info

To get this complaint:

  1. Fork this template into a new private repo on GitHub
  2. Clone that repo locally
  3. pnpm install
  4. pnpm run setup
@JoshuaKGoldberg JoshuaKGoldberg added type: feature New enhancement or request status: accepting prs Please, send a pull request to resolve this! labels May 3, 2023
@RNR1
Copy link
Contributor

RNR1 commented May 11, 2023

On it

JoshuaKGoldberg pushed a commit that referenced this issue May 12, 2023
<!-- 👋 Hi, thanks for sending a PR to template-typescript-node-package!
💖.
Please fill out all fields below and make sure each item is true and [x]
checked.
Otherwise we may not be able to review your PR. -->

## PR Checklist

- [x] Addresses an existing open issue: fixes #401 
- [x] That issue was marked as [`status: accepting
prs`](https://github.com/JoshuaKGoldberg/template-typescript-node-package/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22)
- [x] Steps in
[CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/template-typescript-node-package/blob/main/.github/CONTRIBUTING.md)
were taken

## Overview

Fail gracefully for branch protection settings for private repos
(non-Pro).
- Added `warnText` field to the "withSpinner" options
- `withSpinner` will now store its callback return value, and will show
`warnText` in case the value is `false`

Bonus: I changed all the `catch (err)` to `catch (error)` just for
consistency (git blame on me)

I'm honestly not so excited about this solution, but submitting it
anyway to hear your thoughts
@github-actions
Copy link

🎉 This is included in version v1.27.80 🎉

The release is available on:

Cheers! 📦🚀

1 similar comment
@github-actions
Copy link

🎉 This is included in version v1.27.80 🎉

The release is available on:

Cheers! 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepting prs Please, send a pull request to resolve this! type: feature New enhancement or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants