Skip to content

Commit d4d4b3c

Browse files
committed
feat: impl mergerequest api
1 parent 0ac7b47 commit d4d4b3c

31 files changed

+1275
-348
lines changed

api/swagger.yml

Lines changed: 152 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,19 @@ components:
164164
type: string
165165
description:
166166
type: string
167+
MergeMergeRequest:
168+
type: object
169+
required:
170+
- msg
171+
- conflict_resolve
172+
properties:
173+
msg:
174+
type: string
175+
conflict_resolve:
176+
description: use to record the resolution of the conflict, example({"b/a.txt":"base"})
177+
type: object
178+
additionalProperties:
179+
type: string
167180
MergeRequest:
168181
type: object
169182
required:
@@ -209,6 +222,56 @@ components:
209222
updated_at:
210223
type: string
211224
format: date-time
225+
MergeRequestFullState:
226+
type: object
227+
required:
228+
- id
229+
- target_branch
230+
- source_branch
231+
- source_repo_id
232+
- target_repo_id
233+
- title
234+
- changes
235+
- merge_status
236+
- author_id
237+
- created_at
238+
- updated_at
239+
properties:
240+
id:
241+
type: integer
242+
format: uint64
243+
target_branch:
244+
type: string
245+
format: uuid
246+
source_branch:
247+
type: string
248+
format: uuid
249+
source_repo_id:
250+
type: string
251+
format: uuid
252+
target_repo_id:
253+
type: string
254+
format: uuid
255+
title:
256+
type: string
257+
merge_status:
258+
type: integer
259+
format: int
260+
description:
261+
type: string
262+
author_id:
263+
type: string
264+
format: uuid
265+
changes:
266+
type: array
267+
items:
268+
$ref: "#/components/schemas/ChangePair"
269+
created_at:
270+
type: string
271+
format: date-time
272+
updated_at:
273+
type: string
274+
format: date-time
212275
MergeRequestList:
213276
type: object
214277
required:
@@ -534,6 +597,13 @@ components:
534597
updated_at:
535598
type: string
536599
format: date-time
600+
UpdateWip:
601+
type: object
602+
properties:
603+
base_commit:
604+
type: string
605+
current_tree:
606+
type: string
537607
Change:
538608
type: object
539609
required:
@@ -549,6 +619,20 @@ components:
549619
type: string
550620
to_hash:
551621
type: string
622+
ChangePair:
623+
type: object
624+
required:
625+
- path
626+
- is_conflict
627+
properties:
628+
path:
629+
type: string
630+
left:
631+
$ref: "#/components/schemas/Change"
632+
right:
633+
$ref: "#/components/schemas/Change"
634+
is_conflict:
635+
type: boolean
552636
UserUpdate:
553637
type: object
554638
required:
@@ -1099,6 +1183,26 @@ paths:
10991183
description: Unauthorized
11001184
403:
11011185
description: Forbidden
1186+
post:
1187+
tags:
1188+
- wip
1189+
operationId: updateWip
1190+
summary: update wip
1191+
requestBody:
1192+
required: true
1193+
content:
1194+
application/json:
1195+
schema:
1196+
$ref: "#/components/schemas/UpdateWip"
1197+
responses:
1198+
200:
1199+
description: update working in process success
1200+
400:
1201+
description: ValidationError
1202+
401:
1203+
description: Unauthorized
1204+
403:
1205+
description: Forbidden
11021206
delete:
11031207
tags:
11041208
- wip
@@ -1592,7 +1696,53 @@ paths:
15921696
500:
15931697
description: Internal Server Error
15941698

1595-
/mergequest/{owner}/{repository}/mr/{mrId}:
1699+
/mergequest/{owner}/{repository}/{mrId}/merge:
1700+
parameters:
1701+
- in: path
1702+
name: owner
1703+
required: true
1704+
schema:
1705+
type: string
1706+
- in: path
1707+
name: repository
1708+
required: true
1709+
schema:
1710+
type: string
1711+
- in: path
1712+
name: mrId
1713+
required: true
1714+
schema:
1715+
type: integer
1716+
format: uint64
1717+
post:
1718+
tags:
1719+
- mergerequest
1720+
operationId: merge
1721+
summary: merge a mergerequest
1722+
requestBody:
1723+
required: true
1724+
content:
1725+
application/json:
1726+
schema:
1727+
$ref: "#/components/schemas/MergeMergeRequest"
1728+
responses:
1729+
200:
1730+
description: merge mergerequest success
1731+
content:
1732+
application/json:
1733+
schema:
1734+
type: array
1735+
items:
1736+
$ref: "#/components/schemas/Commit"
1737+
401:
1738+
description: Unauthorized
1739+
404:
1740+
description: Resource Not Found
1741+
420:
1742+
description: Too many requests
1743+
500:
1744+
description: Internal Server Error
1745+
/mergequest/{owner}/{repository}/{mrId}:
15961746
parameters:
15971747
- in: path
15981748
name: owner
@@ -1621,7 +1771,7 @@ paths:
16211771
content:
16221772
application/json:
16231773
schema:
1624-
$ref: "#/components/schemas/MergeRequest"
1774+
$ref: "#/components/schemas/MergeRequestFullState"
16251775
401:
16261776
description: Unauthorized
16271777
404:
@@ -1669,7 +1819,6 @@ paths:
16691819
500:
16701820
description: Internal Server Error
16711821

1672-
16731822
/users/{owner}/repos:
16741823
parameters:
16751824
- in: path

controller/commit_ctl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (commitCtl CommitController) GetEntriesInRef(ctx context.Context, w *api.Ji
4848
return
4949
}
5050

51-
treeHash := hash.EmptyHash
51+
treeHash := hash.Empty
5252
if params.Type == api.RefTypeWip {
5353
refName := repository.HEAD
5454
if params.Ref != nil {

0 commit comments

Comments
 (0)