Skip to content

Commit 4d1dbfa

Browse files
committed
cmd/mr_discussion.go: Switch from NotePosition to PositionOptions
The new gitlab library version uses PositionOptions and replaces NotePosition. Signed-off-by: Prarit Bhargava <prarit@redhat.com>
1 parent f6d3c86 commit 4d1dbfa

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

cmd/mr_discussion.go

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ var mrCreateDiscussionCmd = &cobra.Command{
121121
return
122122
}
123123

124-
var notePos *gitlab.NotePosition
124+
var notePos gitlab.PositionOptions
125125
if position != "" {
126126
if commit == "" {
127127
// We currently only support "--position" when commenting on individual commits within an MR.
@@ -137,23 +137,28 @@ var mrCreateDiscussionCmd = &cobra.Command{
137137
log.Fatal(err)
138138
}
139139
// WORKAROUND For added (-) and deleted (+) lines we only need one line number parameter, but for context lines we need both. https://gitlab.com/gitlab-org/gitlab/-/issues/325161
140-
newLine := posLineNumberNew
140+
newLine64 := posLineNumberNew
141141
if posLineType == '-' {
142-
newLine = 0
142+
newLine64 = 0
143143
}
144-
oldLine := posLineNumberOld
144+
newLine := int(newLine64)
145+
146+
oldLine64 := posLineNumberOld
145147
if posLineType == '+' {
146-
oldLine = 0
148+
oldLine64 = 0
147149
}
148-
notePos = &gitlab.NotePosition{
149-
BaseSHA: parentSHA,
150-
StartSHA: parentSHA,
151-
HeadSHA: commit,
152-
PositionType: "text",
153-
NewPath: posFile,
154-
NewLine: int(newLine),
155-
OldPath: posFile,
156-
OldLine: int(oldLine),
150+
oldLine := int(oldLine64)
151+
152+
positionType := "text"
153+
notePos = gitlab.PositionOptions{
154+
BaseSHA: &parentSHA,
155+
StartSHA: &parentSHA,
156+
HeadSHA: &commit,
157+
PositionType: &positionType,
158+
NewPath: &posFile,
159+
NewLine: &newLine,
160+
OldPath: &posFile,
161+
OldLine: &oldLine,
157162
}
158163
}
159164

@@ -168,7 +173,7 @@ var mrCreateDiscussionCmd = &cobra.Command{
168173
discussionURL, err := lab.MRCreateDiscussion(rn, int(mrNum), &gitlab.CreateMergeRequestDiscussionOptions{
169174
Body: &body,
170175
CommitID: commitID,
171-
Position: notePos,
176+
Position: &notePos,
172177
})
173178
if err != nil {
174179
log.Fatal(err)

0 commit comments

Comments
 (0)