Feat: Allow setting security_and_analysis settings in gh repo edit#10139
Feat: Allow setting security_and_analysis settings in gh repo edit#10139
Conversation
jtmcg
left a comment
There was a problem hiding this comment.
Really good start, here! I was confused about why this looks so different from the other edit fields when I first dived into this, but after digging into the docs I understand why you wrote it the way you did 🙌
I've left a few comments about some slight changes to logical grouping and testing that I think we can leverage to make this easier to parse and understand. I hope I did a good job explaining my thoughts, but I'm happy to write some code to demonstrate what I mean if that would be helpful.
jtmcg
left a comment
There was a problem hiding this comment.
Changes are great! One more change and test required, I think. Thanks for the timely edits on this
There was a problem hiding this comment.
🔥
Nice work, @ChandranshuRao14! I appreciate all the back and forth. This was a fun one, for sure 🙌
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [cli/cli](https://github.com/cli/cli) | minor | `v2.64.0` -> `v2.65.0` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>cli/cli (cli/cli)</summary> ### [`v2.65.0`](https://github.com/cli/cli/releases/tag/v2.65.0): GitHub CLI 2.65.0 [Compare Source](cli/cli@v2.64.0...v2.65.0) #### What's Changed - Document the base repo resolution functions by [@​williammartin](https://github.com/williammartin) in cli/cli#10110 - Update releasing.md by [@​andyfeller](https://github.com/andyfeller) in cli/cli#10116 - Document how to set gh-merge-base by [@​heaths](https://github.com/heaths) in cli/cli#10112 - Upgrade golang.org/x/net to v0.33.0 by [@​jtmcg](https://github.com/jtmcg) in cli/cli#10135 - add pending status for workflow runs by [@​dziamidchyk](https://github.com/dziamidchyk) in cli/cli#10143 - Remove release discussion posts and clean up related block in deployment yml by [@​shauryatiwari1](https://github.com/shauryatiwari1) in cli/cli#10145 - docs(repo): make explicit which branch is used when creating a repo by [@​nobe4](https://github.com/nobe4) in cli/cli#10163 - feat: Add support for listing autolink references by [@​hoffm](https://github.com/hoffm) in cli/cli#10124 - Add mention of classic token in gh auth login docs by [@​jtmcg](https://github.com/jtmcg) in cli/cli#10164 - Feat: Allow setting security_and_analysis settings in gh repo edit by [@​ChandranshuRao14](https://github.com/ChandranshuRao14) in cli/cli#10139 - Upgrade generated workflows by [@​jsoref](https://github.com/jsoref) in cli/cli#10181 - Myriad fixes to provide clarity on determining tracking ref in MR create by [@​williammartin](https://github.com/williammartin) in cli/cli#10187 - Handle missing upstream configs for `gh pr create` by [@​cmbrose](https://github.com/cmbrose) in cli/cli#10177 - fix(repo fork): add non-TTY output when fork is newly created by [@​aryanbhosale](https://github.com/aryanbhosale) in cli/cli#10158 - Bump cli/go-gh for indirect security vulnerability by [@​andyfeller](https://github.com/andyfeller) in cli/cli#10190 #### New Contributors - [@​dziamidchyk](https://github.com/dziamidchyk) made their first contribution in cli/cli#10143 - [@​shauryatiwari1](https://github.com/shauryatiwari1) made their first contribution in cli/cli#10145 - [@​hoffm](https://github.com/hoffm) made their first contribution in cli/cli#10124 - [@​ChandranshuRao14](https://github.com/ChandranshuRao14) made their first contribution in cli/cli#10139 **Full Changelog**: cli/cli@v2.64.0...v2.65.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS45MS4yIiwidXBkYXRlZEluVmVyIjoiMzkuOTEuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
Fixes #10091
I took a stab at implementing changes to
security_and_analysisproperties in gh repo edit. My Go is a bit rusty, but I did my best to match the project's style. Would love any feedback on how to make this better!A few notes:
security_and_analysisproperties don't seem to be available in the GraphQL API which is used by interactive mode ingh repo edit. For that reason, I didn't include the ability to change these properties in interactive mode for now.--enable-secret-scanning-push-protectioncannot be enabled unless--enable-secret-scanningis enabled, but the API doesn't throw an error for this, the UI will simply not reflect the change. I didn't add a check for this ingh repo editfor now.From this comment on the issue:
If a user doesn't have admin permissions:
HTTP 404: Not Found (https://api.github.com/repos/<owner>/<repo>)If features are not supported:
HTTP 422: Secret scanning is not available for this repository.(https://api.github.com/repos/<owner>/<repo>)