Skip to content

Commit

Permalink
Support multiple links in the tmt link command
Browse files Browse the repository at this point in the history
In order to make the syntax consistent with the `tmt test create`
command and to allow providing multiple links in a single command
let's use a ``--link`` option instead of the first argument for
provide the `relation:target` pairs.
  • Loading branch information
psss committed Oct 22, 2024
1 parent c05919d commit 83fedec
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ later using the ``tmt link`` command:

.. code-block:: shell
tmt link verifies:https://issues.redhat.com/browse/YOUR-ISSUE tests/core/smoke
tmt link --link verifies:https://issues.redhat.com/browse/YOUR-ISSUE tests/core/smoke
In order to enable this feature, create a configuration file
``.config/tmt/link.fmf`` and define an ``issue-tracker`` section
Expand Down
4 changes: 4 additions & 0 deletions docs/releases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ to override the default locations.

__ https://www.redhat.com/en/technologies/linux-platforms/enterprise-linux/image-mode

The ``tmt link`` command now supports providing multiple links by
using the ``--link`` option. See the :ref:`link-issues` section
for example usage.


tmt-1.37.0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
23 changes: 16 additions & 7 deletions tmt/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2242,14 +2242,19 @@ def completion_fish(context: Context, install: bool, **kwargs: Any) -> None:

@main.command(name='link')
@pass_context
@click.argument('link', nargs=1, metavar='[RELATION:]TARGET')
@click.argument('names', nargs=-1, metavar='[TEST|PLAN|STORY]...')
@option(
'--link', 'links', metavar='[RELATION:]TARGET', multiple=True,
help="""
Issue to which tests, plans or stories should be linked.
Can be provided multiple times.
""")
@option(
'--separate', is_flag=True,
help="Create linking separately for multiple passed objects.")
def link(context: Context,
names: list[str],
link: str,
links: list[str],
separate: bool,
) -> None:
"""
Expand All @@ -2268,8 +2273,12 @@ def link(context: Context,
if not tmt_objects:
raise tmt.utils.GeneralError("No test, plan or story found for linking.")

tmt.utils.jira.link(
tmt_objects=tmt_objects,
links=tmt.base.Links(data=link),
separate=separate,
logger=context.obj.logger)
if not links:
raise tmt.utils.GeneralError("Provide at least one link using the '--link' option.")

for link in links:
tmt.utils.jira.link(
tmt_objects=tmt_objects,
links=tmt.base.Links(data=link),
separate=separate,
logger=context.obj.logger)

0 comments on commit 83fedec

Please sign in to comment.