Skip to content

Commit 471fb52

Browse files
committed
Update position to struct
Position defines a specific location, identified by paths line numbers and image coordinates, within a specific diff, identified by start, head and base commit ids. Text position will have: new_line and old_line Image position will have: width, height, x, y
1 parent 1751865 commit 471fb52

File tree

3 files changed

+130
-49
lines changed

3 files changed

+130
-49
lines changed

gitlab/payload.go

Lines changed: 68 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -307,51 +307,74 @@ type Repository struct {
307307

308308
// ObjectAttributes contains all of the GitLab object attributes information
309309
type ObjectAttributes struct {
310-
ID int64 `json:"id"`
311-
Title string `json:"title"`
312-
AssigneeID int64 `json:"assignee_id"`
313-
AuthorID int64 `json:"author_id"`
314-
ProjectID int64 `json:"project_id"`
315-
CreatedAt customTime `json:"created_at"`
316-
UpdatedAt customTime `json:"updated_at"`
317-
Position int64 `json:"position"`
318-
BranchName string `json:"branch_name"`
319-
Description string `json:"description"`
320-
MilestoneID int64 `json:"milestone_id"`
321-
State string `json:"state"`
322-
IID int64 `json:"iid"`
323-
URL string `json:"url"`
324-
Action string `json:"action"`
325-
TargetBranch string `json:"target_branch"`
326-
SourceBranch string `json:"source_branch"`
327-
SourceProjectID int64 `json:"source_project_id"`
328-
TargetProjectID int64 `json:"target_project_id"`
329-
StCommits string `json:"st_commits"`
330-
MergeStatus string `json:"merge_status"`
331-
Content string `json:"content"`
332-
Format string `json:"format"`
333-
Message string `json:"message"`
334-
Slug string `json:"slug"`
335-
Ref string `json:"ref"`
336-
Tag bool `json:"tag"`
337-
SHA string `json:"sha"`
338-
BeforeSHA string `json:"before_sha"`
339-
Status string `json:"status"`
340-
Stages []string `json:"stages"`
341-
Duration int64 `json:"duration"`
342-
Note string `json:"note"`
343-
NotebookType string `json:"noteable_type"`
344-
At customTime `json:"attachment"`
345-
LineCode string `json:"line_code"`
346-
CommitID string `json:"commit_id"`
347-
NoteableID int64 `json:"noteable_id"`
348-
System bool `json:"system"`
349-
WorkInProgress bool `json:"work_in_progress"`
350-
StDiffs []StDiff `json:"st_diffs"`
351-
Source Source `json:"source"`
352-
Target Target `json:"target"`
353-
LastCommit LastCommit `json:"last_commit"`
354-
Assignee Assignee `json:"assignee"`
310+
ID int64 `json:"id"`
311+
Title string `json:"title"`
312+
AssigneeID int64 `json:"assignee_id"`
313+
AuthorID int64 `json:"author_id"`
314+
ProjectID int64 `json:"project_id"`
315+
CreatedAt customTime `json:"created_at"`
316+
UpdatedAt customTime `json:"updated_at"`
317+
ChangePosition Position `json:"change_position"`
318+
OriginalPosition Position `json:"original_position"`
319+
Position Position `json:"position"`
320+
BranchName string `json:"branch_name"`
321+
Description string `json:"description"`
322+
MilestoneID int64 `json:"milestone_id"`
323+
State string `json:"state"`
324+
IID int64 `json:"iid"`
325+
URL string `json:"url"`
326+
Action string `json:"action"`
327+
TargetBranch string `json:"target_branch"`
328+
SourceBranch string `json:"source_branch"`
329+
SourceProjectID int64 `json:"source_project_id"`
330+
TargetProjectID int64 `json:"target_project_id"`
331+
StCommits string `json:"st_commits"`
332+
MergeStatus string `json:"merge_status"`
333+
Content string `json:"content"`
334+
Format string `json:"format"`
335+
Message string `json:"message"`
336+
Slug string `json:"slug"`
337+
Ref string `json:"ref"`
338+
Tag bool `json:"tag"`
339+
SHA string `json:"sha"`
340+
BeforeSHA string `json:"before_sha"`
341+
Status string `json:"status"`
342+
Stages []string `json:"stages"`
343+
Duration int64 `json:"duration"`
344+
Note string `json:"note"`
345+
NotebookType string `json:"noteable_type"`
346+
At customTime `json:"attachment"`
347+
LineCode string `json:"line_code"`
348+
CommitID string `json:"commit_id"`
349+
NoteableID int64 `json:"noteable_id"`
350+
System bool `json:"system"`
351+
WorkInProgress bool `json:"work_in_progress"`
352+
StDiffs []StDiff `json:"st_diffs"`
353+
Source Source `json:"source"`
354+
Target Target `json:"target"`
355+
LastCommit LastCommit `json:"last_commit"`
356+
Assignee Assignee `json:"assignee"`
357+
}
358+
359+
// Position defines a specific location, identified by paths line numbers and
360+
// image coordinates, within a specific diff, identified by start, head and
361+
// base commit ids.
362+
//
363+
// Text position will have: new_line and old_line
364+
// Image position will have: width, height, x, y
365+
type Position struct {
366+
BaseSHA string `json:"base_sha"`
367+
StartSHA string `json:"start_sha"`
368+
HeadSHA string `json:"head_sha"`
369+
OldPath string `json:"old_path"`
370+
NewPath string `json:"new_path"`
371+
PositionType string `json:"position_type"`
372+
OldLine int64 `json:"old_line"`
373+
NewLine int64 `json:"new_line"`
374+
Width int64 `json:"width"`
375+
Height int64 `json:"height"`
376+
X int64 `json:"x"`
377+
Y int64 `json:"y"`
355378
}
356379

357380
// MergeRequest contains all of the GitLab merge request information

testdata/gitlab/confidential-issue-event.json

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,36 @@
3535
"project_id": 14,
3636
"created_at": "2013-12-03T17:15:43Z",
3737
"updated_at": "2013-12-03T17:15:43Z",
38-
"position": 0,
38+
"change_position": {
39+
"base_sha": null,
40+
"start_sha": null,
41+
"head_sha": null,
42+
"old_path": null,
43+
"new_path": null,
44+
"position_type": "text",
45+
"old_line": null,
46+
"new_line": null
47+
},
48+
"original_position": {
49+
"base_sha": "0a87d409a2d5ffbf586ed3e7ff36396ca59c3c14",
50+
"start_sha": "5f7519856cb2a7c05427a8c1e83f941828567923",
51+
"head_sha": "562e173be03b8ff2efb05345d12df18815438a4b",
52+
"old_path": "core/src/main/java/com/example/server/CorbaServer.java",
53+
"new_path": "core/src/main/java/com/example/server/CorbaServer.java",
54+
"position_type": "text",
55+
"old_line": null,
56+
"new_line": 74
57+
},
58+
"position": {
59+
"base_sha": "0a87d409a2d5ffbf586ed3e7ff36396ca59c3c14",
60+
"start_sha": "5f7519856cb2a7c05427a8c1e83f941828567923",
61+
"head_sha": "562e173be03b8ff2efb05345d12df18815438a4b",
62+
"old_path": "core/src/main/java/com/example/server/CorbaServer.java",
63+
"new_path": "core/src/main/java/com/example/server/CorbaServer.java",
64+
"position_type": "text",
65+
"old_line": null,
66+
"new_line": 74
67+
},
3968
"branch_name": null,
4069
"description": "Create new API for manipulations with repository",
4170
"milestone_id": null,
@@ -49,4 +78,4 @@
4978
"username": "user1",
5079
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon"
5180
}
52-
}
81+
}

testdata/gitlab/issue-event.json

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,36 @@
3535
"project_id": 14,
3636
"created_at": "2013-12-03T17:15:43Z",
3737
"updated_at": "2013-12-03T17:15:43Z",
38-
"position": 0,
38+
"change_position": {
39+
"base_sha": null,
40+
"start_sha": null,
41+
"head_sha": null,
42+
"old_path": null,
43+
"new_path": null,
44+
"position_type": "text",
45+
"old_line": null,
46+
"new_line": null
47+
},
48+
"original_position": {
49+
"base_sha": "0a87d409a2d5ffbf586ed3e7ff36396ca59c3c14",
50+
"start_sha": "5f7519856cb2a7c05427a8c1e83f941828567923",
51+
"head_sha": "562e173be03b8ff2efb05345d12df18815438a4b",
52+
"old_path": "core/src/main/java/com/example/server/CorbaServer.java",
53+
"new_path": "core/src/main/java/com/example/server/CorbaServer.java",
54+
"position_type": "text",
55+
"old_line": null,
56+
"new_line": 74
57+
},
58+
"position": {
59+
"base_sha": "0a87d409a2d5ffbf586ed3e7ff36396ca59c3c14",
60+
"start_sha": "5f7519856cb2a7c05427a8c1e83f941828567923",
61+
"head_sha": "562e173be03b8ff2efb05345d12df18815438a4b",
62+
"old_path": "core/src/main/java/com/example/server/CorbaServer.java",
63+
"new_path": "core/src/main/java/com/example/server/CorbaServer.java",
64+
"position_type": "text",
65+
"old_line": null,
66+
"new_line": 74
67+
},
3968
"branch_name": null,
4069
"description": "Create new API for manipulations with repository",
4170
"milestone_id": null,
@@ -49,4 +78,4 @@
4978
"username": "user1",
5079
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon"
5180
}
52-
}
81+
}

0 commit comments

Comments
 (0)