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

Enable issue linking for issue creation #351

Closed
mimor opened this issue Dec 4, 2020 · 4 comments · Fixed by #613
Closed

Enable issue linking for issue creation #351

mimor opened this issue Dec 4, 2020 · 4 comments · Fixed by #613
Labels
cmd: issue Related to issues management enhancement New feature or request help wanted Extra attention is needed

Comments

@mimor
Copy link

mimor commented Dec 4, 2020

We can link MR's to an issue, but we are not able to link related issues through the cli.

The current flow is:

  • create an issue glab issue create --title "" --description ""
  • go to the web-interface to link the relevant issue.

Possible solution:

Introduce a --linked-issue flag, that takes an issue ulr/id from the cli.

@profclems profclems added cmd: issue Related to issues management enhancement New feature or request labels Dec 4, 2020
@profclems
Copy link
Owner

Thanks @mimor for your suggestion.
We are very careful implementing features that are limited by GitLab tiers and newer.

glab relies heavily on the GitLab API and it seems the Issues Link API falls into the two categories I have mentioned.

The simple “relates to” relationship moved to GitLab Core in 13.4.

We may however, consider this one since it is now supported for GitLab.com Free. My only concern is it being new for GitLab Core users.

@profclems
Copy link
Owner

profclems commented Dec 4, 2020

While you wait as we work on this, you can easily implement this with the glab api command as it helps you interact with the GitLab API directly.

glab api /projects/<PROJECT_ID_OR_PATH>/issues/1/links -X POST -F target_project_id=<PROJECT_ID_OR_PATH> -F target_issue_iid=<TARGET_ISSUE_ID>

Here is an example:

glab api /projects/glab-cli%2Ftest/issues/1/links -X POST -F target_project_id=glab-cli/test -F target_issue_iid=2

You can set a short alias for this command with:

glab alias set linkIssue 'api /projects/$1/issues/$2/links -X POST -F target_project_id=$1 -F target_issue_iid=$3'

and now you should be able to use glab linkIssue command like:

glab linkIssue <PROJECT_ID_OR_PATH> <ISSUE_ID> <TARGET_ISSUE_ID>

Example:

glab linkIssue glab-cli%2Ftest 1 2

glab is highly customizable so you can use it whichever way you want it.

@mimor
Copy link
Author

mimor commented Dec 4, 2020

I'd like to complement you on this awesome and complete response 👏

@profclems profclems pinned this issue Dec 5, 2020
@profclems profclems added the help wanted Extra attention is needed label Dec 5, 2020
@profclems profclems unpinned this issue Dec 30, 2020
This was referenced Feb 10, 2021
@wwalker
Copy link

wwalker commented Apr 12, 2022

@profclems Thank you for a great program!!

Slight correction to help others wanting to link issues.

This doesn't work for me:

glab alias set linkIssue 'api /projects/$1/issues/$2/links -X POST -F target_project_id=$1 -F target_issue_iid=$3'
glab linkIssue glab-cli%2Ftest 1 2

However, this does, because, in the uri path, you need %2F (url-encoded /) but in the target_project_id you need /:

glab alias set linkIssue 'api /projects/$1%2F$2/issues/$3/links -X POST -F target_project_id=$1/$2 -F target_issue_iid=$4'
glab linkIssue glab-cli test 1 2

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cmd: issue Related to issues management enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants