Strip a duplicate task prefix from the Phorge issues URL

What does this MR do and why?

Phorge task IDs already carry their T prefix — a task is T123, not 123. GitLab's Phorge integration substitutes the full ID into the :id placeholder of the issues URL, so the correct template is https://phorge.example.com/:id.

Anyone who copies a configuration over from the generic custom issue tracker, or who reasons from Phorge's own URLs, naturally writes https://phorge.example.com/T:id instead. That saves without complaint and then every reference renders as https://phorge.example.com/TT123, which 404s. It's an easy mistake with a confusing failure, and the user has no way to tell from the settings page that anything is wrong.

This MR adds a before_validation callback to Integrations::Base::Phorge that rewrites T:id to :id in issues_url before the URL is validated, so the pasted form is silently corrected to the working one. The rewrite is scoped to the exact T:id sequence: a URL that already uses a plain :id is untouched, and nothing else in the URL is changed. The Phorge integration docs now say this happens and show the before/after URL.

References

  • Resolves #458934
  • The T prefix comes from Phorge's object reference format; the integration's reference_pattern already matches T\d+ for the same reason.

Differences

Before: Saving the Phorge integration with an issues URL of https://phorge.example.com/T:id succeeded, and issue_url('T123') produced https://phorge.example.com/TT123, a broken link on every issue reference.

After: The same input is normalised to https://phorge.example.com/:id on save, and issue_url('T123') produces https://phorge.example.com/T123. An issues URL entered correctly as https://phorge.example.com/:id is unchanged. The docs describe the normalisation.

How to set up and validate locally

  1. In a project, go to Settings > Integrations > Phorge, enable it, and set Issue URL to https://phorge.example.com/T:id with any valid project URL.
  2. Save. Reopen the integration: the Issue URL field now shows https://phorge.example.com/:id.
  3. In a Rails console, confirm the generated link:
integration = Project.find_by_full_path('<group>/<project>').phorge_integration
integration.issues_url        # => "https://phorge.example.com/:id"
integration.issue_url('T123') # => "https://phorge.example.com/T123"
  1. Repeat with https://phorge.example.com/:id as the input and confirm it is stored as entered.

Specs:

bin/rspec spec/models/integrations/phorge_spec.rb

The shared examples in spec/support/shared_examples/models/concerns/integrations/base/phorge_shared_examples.rb gain a #issues_url normalization block asserting that T:id is rewritten to :id and that the resulting issue_url('T123') is correct, and that a plain :id URL is left as-is.

MR acceptance checklist

  • The change is limited to the Phorge integration model and its docs; no database, API, or frontend changes.
  • Normalisation runs in before_validation, so the corrected URL is what gets validated and saved; the existing presence and public_url validations are unchanged.
  • The rewrite is scoped to the literal T:id sequence; URLs that already use :id are untouched.
  • Shared-example specs cover the rewrite, the resulting issue link, and the no-op case.
  • Documentation updated in doc/user/project/integrations/phorge.md to describe the behaviour, with a before/after URL.
  • Changelog: added trailer is on the commit.
  • No feature flag needed; the change is small, additive, and only affects a URL shape that was already broken.
Edited by Jeston Singh

Merge request reports

Loading
Loading