detached 4d9eaac

fix(usecase): drop the unused repository read before the merge lock

merge reads the repository again under the lock; the first read only checks access.
commit
4d9eaac4572380c0442cdd5c443314a3eda9d517
author
brice · · 2026-10-19 20:15 UTC
parent
05fc636
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
checks
7/8
1 file · +2 -3
M internal/usecase/mergerequests.go +2 -3
@@ -1002,8 +1002,7 @@ func (m *MergeRequests) checkMode(ctx context.Context, mr domain.MergeRequest, m
10021002 }
10031003
10041004 func (m *MergeRequests) merge(ctx context.Context, p domain.Principal, name domain.RepoName, number int64, params ports.MergeParams) (domain.MergeRequest, error) {
1005- repo, err := m.writable(ctx, p, name, domain.ScopeMRMerge)
1006- if err != nil {
1005+ if _, err := m.writable(ctx, p, name, domain.ScopeMRMerge); err != nil {
10071006 return domain.MergeRequest{}, err
10081007 }
10091008 mode := params.Mode
@@ -1048,7 +1047,7 @@ func (m *MergeRequests) merge(ctx context.Context, p domain.Principal, name doma
10481047 return domain.MergeRequest{}, fmt.Errorf("%w: !%d is a draft: mark it ready for review first", domain.ErrPreconditionFailed, number)
10491048 }
10501049 // The settings are read again under the lock: a change applies at once.
1051- repo, err = m.meta.Get(ctx, name)
1050+ repo, err := m.meta.Get(ctx, name)
10521051 if err != nil {
10531052 if errors.Is(err, domain.ErrNotFound) {
10541053 return domain.MergeRequest{}, err // deleted meanwhile
@@ -1002,8 +1002,7 @@ func (m *MergeRequests) checkMode(ctx context.Context, mr domain.MergeRequest, m
1002 }1002 }
1003 1003
1004 func (m *MergeRequests) merge(ctx context.Context, p domain.Principal, name domain.RepoName, number int64, params ports.MergeParams) (domain.MergeRequest, error) {1004 func (m *MergeRequests) merge(ctx context.Context, p domain.Principal, name domain.RepoName, number int64, params ports.MergeParams) (domain.MergeRequest, error) {
1005- repo, err := m.writable(ctx, p, name, domain.ScopeMRMerge)1005+ if _, err := m.writable(ctx, p, name, domain.ScopeMRMerge); err != nil {
1006- if err != nil {
1007 return domain.MergeRequest{}, err1006 return domain.MergeRequest{}, err
1008 }1007 }
1009 mode := params.Mode1008 mode := params.Mode
@@ -1048,7 +1047,7 @@ func (m *MergeRequests) merge(ctx context.Context, p domain.Principal, name doma
1048 return domain.MergeRequest{}, fmt.Errorf("%w: !%d is a draft: mark it ready for review first", domain.ErrPreconditionFailed, number)1047 return domain.MergeRequest{}, fmt.Errorf("%w: !%d is a draft: mark it ready for review first", domain.ErrPreconditionFailed, number)
1049 }1048 }
1050 // The settings are read again under the lock: a change applies at once.1049 // The settings are read again under the lock: a change applies at once.
1051- repo, err = m.meta.Get(ctx, name)1050+ repo, err := m.meta.Get(ctx, name)
1052 if err != nil {1051 if err != nil {
1053 if errors.Is(err, domain.ErrNotFound) {1052 if errors.Is(err, domain.ErrNotFound) {
1054 return domain.MergeRequest{}, err // deleted meanwhile1053 return domain.MergeRequest{}, err // deleted meanwhile

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 2

Tags 44

↑↓ moveenter openesc close