mirror of
https://github.com/go-gitea/gitea.git
synced 2026-11-27 22:07:33 +08:00
Adds a merge queue for protected branches, modeled on GitHub's. Merging
into a branch that requires it queues the pull request, tests it with
the ones ahead of it in `merge_group` runs and fast-forwards the base
once the required checks pass. Failing or conflicting pull requests are
removed.
Rules configure merge method, group sizes, grouping and timeouts. Each
queue has a page at `/{owner}/{repo}/queue/{branch}`. The API can queue,
jump, look up and remove a pull request and list or clear a queue, and
webhooks and Actions get the `merge_group` event and
`enqueued`/`dequeued` actions. The merge box's command line hint now
sits beside the merge buttons like on GitHub, also outside of merge
queues.
One notable difference from GitHub is that Gitea allows merge queue to
be enabled in any repo, as opposed to GitHub which only allows it in
organization repos.
| View | Screenshot |
| --- | --- |
| Merge box, ready | <img width="440" alt="Merge box, ready"
src="https://github.com/user-attachments/assets/7d2ac984-90c4-4744-8ac8-5daf37cd96e9"
/> |
| Merge box, queued | <img width="440" alt="Merge box, queued"
src="https://github.com/user-attachments/assets/33b85cab-dfd6-405f-8ffd-283cd920e59f"
/> |
| Pull request header, queued | <img width="600" alt="Pull request
header, queued"
src="https://github.com/user-attachments/assets/d61c635b-8552-4b47-a900-e493912e8c16"
/> |
| Timeline, removal after failed checks | <img width="440"
alt="Timeline, removal after failed checks"
src="https://github.com/user-attachments/assets/bee95e79-4c76-4592-ad35-82109d9da4ed"
/> |
| Queue page | <img width="600" alt="Queue page"
src="https://github.com/user-attachments/assets/847a595a-1e13-4099-aa37-7f44018dc188"
/> |
| Pull request list, queued | <img width="600" alt="Pull request list,
queued"
src="https://github.com/user-attachments/assets/a382a143-a67f-4298-aa11-594e281d54db"
/> |
| Merge queue settings | <img width="600" alt="Merge queue settings"
src="https://github.com/user-attachments/assets/cdaf4aa5-350e-4570-a095-c91c41d03cde"
/> |
Fixes: https://github.com/go-gitea/gitea/issues/36392
Docs: https://gitea.com/gitea/docs/pulls/655
Assisted-by: Claude Code:claude-opus-5-5
---------
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: TheFox0x7 <thefox0x7@gmail.com>
49 lines
1.8 KiB
Go
49 lines
1.8 KiB
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package structs
|
|
|
|
import "time"
|
|
|
|
// swagger:enum MergeQueueEntryState
|
|
type MergeQueueEntryState string
|
|
|
|
const (
|
|
MergeQueueStateQueued MergeQueueEntryState = "queued"
|
|
MergeQueueStateAwaitingChecks MergeQueueEntryState = "awaiting_checks"
|
|
MergeQueueStateMergeable MergeQueueEntryState = "mergeable"
|
|
MergeQueueStateUnmergeable MergeQueueEntryState = "unmergeable"
|
|
)
|
|
|
|
// MergeQueueEntry is a pull request waiting in a merge queue
|
|
type MergeQueueEntry struct {
|
|
// Position in the queue, starting at 1
|
|
Position int `json:"position"`
|
|
// queued, awaiting_checks, mergeable or unmergeable
|
|
State MergeQueueEntryState `json:"state"`
|
|
// Index of the pull request
|
|
PullRequestIndex int64 `json:"pull_request_index"`
|
|
// Branch the pull request merges into
|
|
BaseBranch string `json:"base_branch"`
|
|
// Head commit of the pull request when it was added
|
|
HeadSHA string `json:"head_sha"`
|
|
// Queue commit testing the pull request, empty until it is built
|
|
MergeGroupHeadSHA string `json:"merge_group_head_sha"`
|
|
// Ref of the queue commit, empty until it is built
|
|
MergeGroupHeadRef string `json:"merge_group_head_ref"`
|
|
// Whether the pull request jumped to the front of the queue
|
|
Jump bool `json:"jump"`
|
|
// User who added the pull request
|
|
Enqueuer *User `json:"enqueuer"`
|
|
// swagger:strfmt date-time
|
|
EnqueuedAt time.Time `json:"enqueued_at"`
|
|
}
|
|
|
|
// AddToMergeQueueOption options for adding a pull request to the merge queue
|
|
type AddToMergeQueueOption struct {
|
|
// Put the pull request at the front of the queue, even if already queued, requires repository admin
|
|
Jump bool `json:"jump"`
|
|
// Only add the pull request if its head is still this commit
|
|
HeadCommitID string `json:"head_commit_id"`
|
|
}
|