Pull request support in the Edit menu
Currently, editing via the Edit menu requires the user to have direct push access to the repository. External contributors – subject-matter experts, pilot participants, and others without repo access – cannot contribute via the built-in interface.
Pull request support would allow any GitHub user to suggest changes with the same simple user experience as the current direct flow.
Proposed flow
- User opens the edit dialog and makes changes as normal
- On save: GitHub API creates a new branch (
<login>/patch-<date>) and commits there instead of directly tomain - GitHub API then creates a pull request from this branch against
main - User sees a confirmation with a link to the PR instead of the build indicator
Permission detection
The GitHub API endpoint GET /repos/SAMT-X/samt-bu-docs/collaborators/<login>/permission returns the user’s permission level (admin, write, read, none). This can be used to select the flow automatically:
| Permission level | Flow |
|---|---|
write / admin | Direct commit to main (current flow) |
read / none | Branch + pull request |
Alternatively: always offer the PR flow as an option in the dialog, regardless of permissions.
Technical feasibility
All required functionality is available in the GitHub REST API:
| Operation | Endpoint |
|---|---|
Get current SHA for main | GET /repos/.../git/ref/heads/main |
| Create branch | POST /repos/.../git/refs |
| Commit to branch | PUT /repos/.../contents/<path> with branch parameter |
| Create PR | POST /repos/.../pulls |
The existing createFilesInOneCommit() in custom-footer.html already uses most of these – branch support is largely an extension of what is already there.
Challenges
- Fork flow: Users without read access to a private repo must fork first. Handled by
POST /repos/.../forks+ commit to fork + PR from fork. More complex flow. - Conflict handling: A PR may have merge conflicts that the user cannot resolve via the interface.
- Build status: PR builds are not triggered by
hugo.yml(only push tomain) – the pending indicator does not make sense for the PR flow. Builds occur only after merge.
Priority
Medium – significantly increases accessibility for contributors without changing the experience for existing users with push access.
Related
themes/hugo-theme-samt-bu/layouts/partials/custom-footer.html–createFilesInOneCommit(),doGitHubLogin()themes/hugo-theme-samt-bu/layouts/partials/edit-switcher.html– Edit menu and dialogs