feat: Add default PR branch update style setting#37410
Conversation
Co-Authored-By: OpenAI Codex (GPT-5) <codex@openai.com>
|
this the first one shot test with Codex 5.5 |
|
Why is this option necessary? |
|
Same question. GitHub offers only merge style branch updates to my knowledge. I wonder what the benefit of other styles is exactly. New Options are good but I'm not sure we should overload users with them. |
|
Actually I was wrong, Github does support rebase updates: https://github.blog/changelog/2022-02-02-more-ways-to-keep-your-pull-request-branch-up-to-date/ So it makes sense for feature parity. Should be implemented with a dropdown-style on the "Update branch" button with similar UX than GitHub. Also I think GitHub has some condition on when they show the dropdown vs. regular button. Find out what that condition is. |
|
@silverwind I think this is a bit off-topic. This PR is intended to add an option that lets users choose whether the default update action should be Update with merge commit or Update with rebase. |
|
It describes the mechanism. I wasn't aware that Gitea seems to implement some of this already. A option is good to have in any case. |
|
Co-Authored-By: OpenAI Codex (GPT-5.5) <codex@openai.com>
Co-Authored-By: OpenAI Codex (GPT-5.5) <codex@openai.com>
|
Doing some fixups. |
- API `POST /pulls/{id}/update` with no `style` continues to mean "merge"
rather than the repo's DefaultUpdateStyle, preserving the historical
contract for existing API clients.
- Centralize update-settings validation as
`(*PullRequestsConfig).ValidateUpdateSettings()` with sentinel errors,
reused by both the API and web routers.
- Inline two trivial single-caller helpers; introduce a small
`ResolveUpdateStyle(requested, fallback)` so the API and web paths
share the resolution shape.
- Gate API EditRepoOption update-style validation on the new fields
being supplied, so unrelated PATCH calls don't return 422.
- Web settings handler maps the model sentinels to locale strings.
- Collapse three FromDB tests into a table-driven test and add a
legacy-JSON regression case (pre-PR row with AllowRebaseUpdate=false
and the new fields absent must preserve the historical setting).
- Extract setupOutdatedPRWithConfig helper for the new integration tests.
- Template: bind $isRebase once, drop redundant doc comments.
Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
|
Done, among other cleanups, it fixed an api break when no |
There was a problem hiding this comment.
Pull request overview
Adds repository-level configuration for “Update branch” behavior on pull requests, letting repo admins choose a default update style (merge vs rebase) and independently enable/disable each update method, while preserving API back-compat when the style parameter is omitted.
Changes:
- Introduce
UpdateStyleand new PR unit config fields:AllowMergeUpdate,AllowRebaseUpdate,DefaultUpdateStyle, plus validation helpers. - Wire the new settings through web UI, API edit-repo endpoints, API/struct conversion, and swagger docs.
- Update PR “outdated” UI and add/extend unit + integration tests (including API back-compat/validation cases).
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/integration/pull_update_test.go | Adds integration coverage for API update behavior (no-style back-compat; disabled style forbidden) and shared setup helpers. |
| tests/integration/api_repo_edit_test.go | Extends repo edit test helpers to include new fields and adds validation tests for invalid combinations. |
| templates/swagger/v1_openapi3_json.tmpl | Documents new allow_merge_update and default_update_style fields in OpenAPI v3 template. |
| templates/swagger/v1_json.tmpl | Documents new allow_merge_update and default_update_style fields in swagger v1 template. |
| templates/repo/settings/options.tmpl | Adds repo settings controls for merge-update enablement and default update style selection. |
| templates/repo/issue/view_content/update_branch_by_merge.tmpl | Switches outdated-PR update UI to data-driven primary action + optional style dropdown. |
| services/pull/update.go | Adds helpers to resolve requested vs default style and applies new repo config gates for merge/rebase update permissions. |
| services/pull/update_test.go | Adds unit test for default update style retrieval and extends permission tests for merge-update disablement. |
| services/forms/repo_form.go | Extends repo settings form with new update settings fields. |
| services/convert/repository.go | Exposes new update settings fields in API repository conversion output. |
| routers/web/repo/setting/setting.go | Prepares template data for default update style dropdown and validates new settings on save. |
| routers/web/repo/pull.go | Makes web “Update branch” route respect repo default style when style is omitted. |
| routers/web/repo/issue_view.go | Builds primary update action + dropdown options based on repo default and allowed styles. |
| routers/api/v1/repo/repo.go | Applies and validates new update settings fields in repo PATCH endpoint (422 on invalid combos). |
| routers/api/v1/repo/pull.go | Preserves API back-compat: no style parameter continues to mean merge update. |
| options/locale/locale_en-US.json | Adds English strings for the new repo settings UI labels. |
| modules/structs/repo.go | Adds new fields to API structs (Repository, EditRepoOption). |
| models/repo/repo_unit.go | Extends PullRequestsConfig with new update settings + validation methods and DB defaulting behavior. |
| models/repo/pull_request_default_test.go | Adds unit tests for config DB unmarshalling defaults and validation failures. |
| models/repo/git.go | Introduces UpdateStyle type and constants (merge, rebase). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
* origin/main: (39 commits) fix: Add missed token scope checking (go-gitea#37735) chore: Use giteabot instead of backporter (go-gitea#37422) fix: Allow direct commits for unprotected files with push restrictions (go-gitea#37657) chore: Conventional adjustments (go-gitea#37677) chore(db): introduce db.Session and db.EngineMigration interfaces (go-gitea#37746) fix(migrations): preserve unique constraints in v334 sync (go-gitea#37743) feat(web): also display PR counts in repo list (go-gitea#37739) feat: execute post run cleanup when workflow is cancelled (go-gitea#37275) fix(actions): wrong assumption that run id always >= job id (go-gitea#37737) fix(icon): use repo-forked icon to display forks count (go-gitea#37731) fix(oauth): strengthen PKCE validation and refresh token replay protection (go-gitea#37706) fix(web): enforce token scopes on raw, media, and attachment downloads (go-gitea#37698) feat: Add bypass allowlist for branch protection (go-gitea#36514) refactor(glob): use strings.Builder for regexp compilation (go-gitea#37730) feat(oauth): Support AWS Cognito OAuth2 provider (go-gitea#37607) feat: Add default PR branch update style setting (go-gitea#37410) refactor: move `workflowpattern` into `modules/actions` (go-gitea#37717) ci: add `zizmor` to `lint-actions` (go-gitea#37720) chore(doctor): remove four obsolete doctor check implementations (go-gitea#37728) chore(renovate): enable dockerfile manager (go-gitea#37719) ... # Conflicts: # modules/globallock/locker_test.go

Adds repository-level settings for pull request branch updates so admins can choose the default update method and disable merge or rebase updates.