Skip to content

Resolve "`/tag` quick action on Commit comments"

What does this MR do?

Implements the /tag quick action on commit comments as described in #45663 (closed).

Are there points in the code the reviewer needs to double check?

Screenshots (if relevant)

gitlab-tag-commit

Does this MR meet the acceptance criteria?

What are the relevant issue numbers?

Closes #45663 (closed)

Notes

TODOs

  • Implement Commits::TagService Commits::UpdateService
    • Tag the actual commit (aka git tag equivalent) using Tags::CreateService
    • Unit tests
    • Check authorization
  • Add new tag command in InterpretService
    • Define condition based on type Commit
    • Check authorization
  • Feature tests (equivalent to issues/user_uses_slash_command_spec.rb)
    • Add some more
  • Make sure that "Preview" is working
  • Refactor find/building noteables
    • Move building noteables from AutocompleteService#commands in AutocompleteSourcesController#target
    • Build issues/merge_request (@project.issues.build) if provided type_id is empty or could not be found (in AutocompleteSourcesController#target)
    • Remove Issueable type-check from AutocompleteService#commands
  • Do not show Command applied if tagging fails
    • Currently, errors from commands are discarded
      • Example: /move non_existent_repo won't show an error nor Command applied
    • Should errors be shown?
  • Verify that users are allowed to tag commits (push_code?)
    • CommitPolicy is empty
    • Auto complete /tag only if user is authorized
    • Authorize user before executing Commits::TagService
      • Not needed because it's already done in Tag::CreateService.
  • Tag commits asynchronously?
    • Yes, from the UX point of view
  • A Commit is not Issueable
    • Avoid type checks (is_a?(Issuable)) in QuickActions::IntepretService
    • Introduce some kind of presenter to wrap Issue, MergeRequest and Commit
    • Adding methods like Commit#to_ability_name feels wrong
    • Type checks are fine and the presenter is not needed

Open questions

Merge request reports