Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

issue create and mr create escape #430

Merged
merged 4 commits into from
Dec 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions commands/issue/create/issue_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,10 @@ func generateIssueWebURL(opts *CreateOpts, repo glrepo.Interface) (string, error
// this uses the slash commands to add labels to the description
// See https://docs.gitlab.com/ee/user/project/quick_actions.html
// See also https://gitlab.com/gitlab-org/gitlab-foss/-/issues/19731#note_32550046
description += fmt.Sprintf("\n/label ~%s", strings.Join(opts.Labels, " ~"))
description += "\n/label "
for _, label := range opts.Labels {
description += fmt.Sprintf("~%q", label)
}
}
if len(opts.Assignees) > 0 {
// this uses the slash commands to add assignees to the description
Expand All @@ -319,6 +322,6 @@ func generateIssueWebURL(opts *CreateOpts, repo glrepo.Interface) (string, error
u.RawQuery = fmt.Sprintf(
"utf8=✓&issue[title]=%s&issue[description]=%s",
opts.Title,
description)
url.QueryEscape(description))
return u.String(), nil
}
7 changes: 5 additions & 2 deletions commands/mr/create/mr_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,10 @@ func generateMRCompareURL(opts *CreateOpts) (string, error) {
// this uses the slash commands to add labels to the description
// See https://docs.gitlab.com/ee/user/project/quick_actions.html
// See also https://gitlab.com/gitlab-org/gitlab-foss/-/issues/19731#note_32550046
description += fmt.Sprintf("\n/label ~%s", strings.Join(opts.Labels, " ~"))
description += "\n/label "
for _, label := range opts.Labels {
description += fmt.Sprintf("~%q", label)
}
}
if len(opts.Assignees) > 0 {
// this uses the slash commands to add assignees to the description
Expand All @@ -502,7 +505,7 @@ func generateMRCompareURL(opts *CreateOpts) (string, error) {
u.RawQuery = fmt.Sprintf(
"utf8=✓&merge_request[title]=%s&merge_request[description]=%s&merge_request[source_branch]=%s&merge_request[target_branch]=%s&merge_request[source_project_id]=%d&merge_request[target_project_id]=%d",
opts.Title,
description,
url.QueryEscape(description),
opts.SourceBranch,
opts.TargetBranch,
opts.SourceProject.ID,
Expand Down