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

feat: create-branch=false option #152

Merged
merged 4 commits into from
Nov 19, 2024

Conversation

dbushong
Copy link
Contributor

Fixes #151

Does not include test coverage, but adding it would mean a number of large copy-pastes or a significant refactor of src/edit-github-blob-test.ts

Copy link
Owner

@mislav mislav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, if you know your COMMITTER_TOKEN has permissions to bypass branch protections, it would be nice to have a create-branch: false that lets you push directly to the requested branch.

How about instead of adding a new feature, we change the logic to detect whether the committer has the ability to bypass branch protections?

This is the current logic:

const needsBranch =
inFork || branchRes.data.protected || params.makePR === true

I imagine a better condition would be something like

inFork ||
  (branchRes.data.protected && branchProtections.enforceAdmins.enabled || pushRepo.permissions.admin) ||
  params.makePR === true 

What do you think?

@dbushong
Copy link
Contributor Author

Good thought! Seems like it doesn't work for my use case, where this is a non-admin (bot) user that's been granted permission to push directly to the relevant branch:

  • pushRepo.permissions.admin === false
  • branchProtections (can't fetch (because not admin?))
  • branchRes.data.protected === true

I don't see a clear way in the API to detect that it's a protected branch, but OK for the currently auth'ed user (short of being admin)

@mislav mislav merged commit c1971d6 into mislav:main Nov 19, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Request: create-branch: false
2 participants