Skip to content
Snippets Groups Projects
Verified Commit b3fc0d54 authored by Daniel Duvall's avatar Daniel Duvall Committed by GitLab
Browse files

Fixed Phorge reference_pattern

Modified `Integrations::Phorge#reference_pattern` to use a regular
expression more closely resembling that of Phorge's own parser, and
documented the method's expected behavior as well as justifications for
the regex differences.

Implemented additional specs for cases where the pattern should and
should not match.
parent df3048c6
No related branches found
No related tags found
1 merge request!145863Support Phorge as an external issue tracker
Showing
with 273 additions and 1 deletion
......@@ -22,7 +22,7 @@ class Integration < ApplicationRecord
asana assembla bamboo bugzilla buildkite campfire clickup confluence custom_issue_tracker
datadog diffblue_cover discord drone_ci emails_on_push ewm external_wiki
gitlab_slack_application hangouts_chat harbor irker jira
mattermost mattermost_slash_commands microsoft_teams packagist pipelines_email
mattermost mattermost_slash_commands microsoft_teams packagist phorge pipelines_email
pivotaltracker prometheus pumble pushover redmine slack slack_slash_commands squash_tm teamcity telegram
unify_circuit webex_teams youtrack zentao
].freeze
......
# frozen_string_literal: true
module Integrations
class Phorge < BaseIssueTracker
include HasIssueTrackerFields
validates :project_url, :issues_url, :new_issue_url, presence: true, public_url: true, if: :activated?
# See https://we.phorge.it/source/phorge/browse/master/src/infrastructure/markup/rule/PhabricatorObjectRemarkupRule.php
# for a canonical source of the regular expression used to parse Phorge
# object references.
#
# > The "(?<![#@-])" prevents us from linking "#abcdef" or similar, and
# > "ABC-T1" (see T5714), and from matching "@T1" as a task (it is a user)
# > (see T9479).
#
# Note that object references in Phorge are prefixed with letters unique
# to their underlying application, so T123 (a Maniphest task) is
# distinct from D123 (a Differential patch). Keeping the T as part of
# the task ID is appropriate here as it leaves room for expanding
# reference parsing/linking to other types of Phorge entities.
#
# Also note, a prefix of # is being allowed here due to: 1) an assumed
# likelihood of use; and b) lack of collision with native GitLab issues
# since all Phorge identifiers have the application specific alpha prefix.
def reference_pattern(*)
@reference_pattern ||= /\b(?<![@-])(?<issue>T\d+)\b/
end
def self.title
'Phorge'
end
def self.description
s_("IssueTracker|Use Phorge as this project's issue tracker.")
end
# rubocop:disable Rails/OutputSafety -- It is fine to call html_safe here
def self.help
docs_link = ActionController::Base.helpers.link_to _('Learn more.'),
Rails.application.routes.url_helpers.help_page_url('user/project/integrations/phorge'),
target: '_blank',
rel: 'noopener noreferrer'
# rubocop:disable Gitlab/Rails/SafeFormat -- See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/145863#note_1845580057
format(
s_("IssueTracker|Use Phorge as this project's issue tracker. %{docs_link}").html_safe,
docs_link: docs_link.html_safe
)
# rubocop:enable Gitlab/Rails/SafeFormat
end
# rubocop:enable Rails/OutputSafety
def self.to_param
'phorge'
end
end
end
......@@ -234,6 +234,7 @@ def self.integration_association_name(name)
has_one :mock_ci_integration, class_name: 'Integrations::MockCi'
has_one :mock_monitoring_integration, class_name: 'Integrations::MockMonitoring'
has_one :packagist_integration, class_name: 'Integrations::Packagist'
has_one :phorge_integration, class_name: 'Integrations::Phorge'
has_one :pipelines_email_integration, class_name: 'Integrations::PipelinesEmail'
has_one :pivotaltracker_integration, class_name: 'Integrations::Pivotaltracker'
has_one :prometheus_integration, class_name: 'Integrations::Prometheus', inverse_of: :project
......
---
key_path: counts.projects_phorge_active
description: Count of groups with active integrations for Phorge
product_section: dev
product_stage: manage
product_group: integrations
value_type: number
status: active
milestone: "16.11"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/145863
time_frame: all
data_source: database
data_category: optional
performance_indicator_type: []
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
key_path: counts.projects_inheriting_phorge_active
description: Count of active projects inheriting integrations for Phorge
product_section: dev
product_stage: manage
product_group: integrations
value_type: number
status: active
milestone: "16.11"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/145863
time_frame: all
data_source: database
data_category: optional
performance_indicator_type: []
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
key_path: counts.instances_phorge_active
description: Count of active instance-level integrations for Phorge
product_section: dev
product_stage: manage
product_group: integrations
value_type: number
status: active
milestone: "16.11"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/145863
time_frame: all
data_source: database
data_category: optional
performance_indicator_type: []
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
key_path: counts.groups_phorge_active
description: Count of groups with active integrations for Phorge
product_section: dev
product_stage: manage
product_group: integrations
value_type: number
status: active
milestone: "16.11"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/145863
time_frame: all
data_source: database
data_category: optional
performance_indicator_type: []
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
key_path: counts.groups_inheriting_phorge_active
description: Count of active groups inheriting integrations for Phorge
product_section: dev
product_stage: manage
product_group: integrations
value_type: number
status: active
milestone: "16.11"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/145863
time_frame: all
data_source: database
data_category: optional
performance_indicator_type: []
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
......@@ -561,6 +561,7 @@ Mailroom
Makefile
Makefiles
malloc
Maniphest
Markdown
markdownlint
Marketo
......@@ -687,6 +688,7 @@ Phabricator
phaser
phasers
phpenv
Phorge
PHPUnit
PIDs
pipenv
......
......@@ -33145,6 +33145,7 @@ State of a Sentry error.
| <a id="servicetypemattermost_slash_commands_service"></a>`MATTERMOST_SLASH_COMMANDS_SERVICE` | MattermostSlashCommandsService type. |
| <a id="servicetypemicrosoft_teams_service"></a>`MICROSOFT_TEAMS_SERVICE` | MicrosoftTeamsService type. |
| <a id="servicetypepackagist_service"></a>`PACKAGIST_SERVICE` | PackagistService type. |
| <a id="servicetypephorge_service"></a>`PHORGE_SERVICE` | PhorgeService type. |
| <a id="servicetypepipelines_email_service"></a>`PIPELINES_EMAIL_SERVICE` | PipelinesEmailService type. |
| <a id="servicetypepivotaltracker_service"></a>`PIVOTALTRACKER_SERVICE` | PivotaltrackerService type. |
| <a id="servicetypeprometheus_service"></a>`PROMETHEUS_SERVICE` | PrometheusService type. |
......@@ -1417,6 +1417,41 @@ Get the Packagist integration settings for a project.
GET /projects/:id/integrations/packagist
```
## Phorge
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/145863) in GitLab 16.11.
### Set up Phorge
Set up the Phorge integration for a project.
```plaintext
PUT /projects/:id/integrations/phorge
```
Parameters:
| Parameter | Type | Required | Description |
|-----------------|--------|----------|-----------------------|
| `issues_url` | string | true | URL of the issue. |
| `project_url` | string | true | URL of the project. |
### Disable Phorge
Disable the Phorge integration for a project. Integration settings are reset.
```plaintext
DELETE /projects/:id/integrations/phorge
```
### Get Phorge settings
Get the Phorge integration settings for a project.
```plaintext
GET /projects/:id/integrations/phorge
```
## Pipeline status emails
### Set up pipeline status emails
......
......@@ -46,5 +46,6 @@ You can configure any of the following external issue trackers:
- [Custom issue tracker](../user/project/integrations/custom_issue_tracker.md)
- [Engineering Workflow Management (EWM)](../user/project/integrations/ewm.md)
- [Jira](../integration/jira/index.md)
- [Phorge](../user/project/integrations/phorge.md)
- [Redmine](../user/project/integrations/redmine.md)
- [YouTrack](../user/project/integrations/youtrack.md)
......@@ -145,6 +145,7 @@ To use custom settings for a project or group integration:
| [Mattermost slash commands](mattermost_slash_commands.md) | Run slash commands from a Mattermost chat environment. | **{dotted-circle}** No |
| [Microsoft Teams notifications](microsoft_teams.md) | Receive event notifications in Microsoft Teams. | **{dotted-circle}** No |
| Packagist | Update your PHP dependencies in Packagist. | **{check-circle}** Yes |
| [Phorge](phorge.md) | Use Phorge as an issue tracker. | **{dotted-circle}** No |
| [Pipeline status emails](pipeline_status_emails.md) | Send the pipeline status to a list of recipients by email. | **{dotted-circle}** No |
| [Pivotal Tracker](pivotal_tracker.md) | Add commit messages as comments to Pivotal Tracker stories. | **{dotted-circle}** No |
| [Pumble](pumble.md) | Send event notifications to a Pumble channel. | **{dotted-circle}** No |
......
---
stage: Manage
group: Import and Integrate
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://handbook.gitlab.com/handbook/product/ux/technical-writing/#assignments
---
# Phorge
DETAILS:
**Tier:** Free, Premium, Ultimate
**Offering:** GitLab.com, Self-managed, GitLab Dedicated
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/145863) in GitLab 16.11.
You can use [Phorge](https://we.phorge.it/) as an external issue tracker in GitLab.
## Configure the integration
To configure Phorge in a GitLab project:
1. On the left sidebar, select **Search or go to** and find your project.
1. Select **Settings > Integrations**.
1. Select **Phorge**.
1. Under **Enable integration**, select the **Active** checkbox.
1. In **Project URL**, enter the URL to the Phorge project.
1. In **Issue URL**, enter the URL to the Phorge project issue.
The URL must contain `:id`. GitLab replaces this token with the Maniphest task ID (for example, `T123`).
1. In **New issue URL**, enter the URL to a new Phorge project issue.
To prefill tags related to this project, you can use `?tags=`.
1. Optional. Select **Test settings**.
1. Select **Save changes**.
In that GitLab project, you can see a link to your Phorge project.
You can now reference your Phorge issues and tasks in GitLab with
`T<ID>`, where `<ID>` is a Maniphest task ID (for example, `T123`).
......@@ -397,6 +397,7 @@ def self.integrations
desc: 'The server'
}
],
'phorge' => ::Integrations::Phorge.api_fields,
'pipelines-email' => [
{
required: true,
......@@ -658,6 +659,7 @@ def self.integration_classes
::Integrations::MattermostSlashCommands,
::Integrations::MicrosoftTeams,
::Integrations::Packagist,
::Integrations::Phorge,
::Integrations::PipelinesEmail,
::Integrations::Pivotaltracker,
::Integrations::Prometheus,
......
......@@ -27973,6 +27973,12 @@ msgstr ""
msgid "IssueTracker|Use JetBrains YouTrack as this project's issue tracker. %{docs_link}"
msgstr ""
 
msgid "IssueTracker|Use Phorge as this project's issue tracker."
msgstr ""
msgid "IssueTracker|Use Phorge as this project's issue tracker. %{docs_link}"
msgstr ""
msgid "IssueTracker|Use Redmine as the issue tracker. %{docs_link}"
msgstr ""
 
......@@ -82,6 +82,12 @@
server { 'https://packagist.example.comp' }
end
factory :phorge_integration, class: 'Integrations::Phorge' do
project
active { true }
issue_tracker
end
factory :prometheus_integration, class: 'Integrations::Prometheus' do
project
active { true }
......
......@@ -92,4 +92,5 @@ def fill_form(disable: false, skip_new_issue_url: false)
it_behaves_like 'external issue tracker activation', tracker: 'Custom issue tracker'
it_behaves_like 'external issue tracker activation', tracker: 'EWM', skip_test: true
it_behaves_like 'external issue tracker activation', tracker: 'ClickUp', skip_new_issue_url: true
it_behaves_like 'external issue tracker activation', tracker: 'Phorge'
end
......@@ -32,6 +32,7 @@ def core_service_enums
MATTERMOST_SLASH_COMMANDS_SERVICE
MICROSOFT_TEAMS_SERVICE
PACKAGIST_SERVICE
PHORGE_SERVICE
PIPELINES_EMAIL_SERVICE
PIVOTALTRACKER_SERVICE
PROMETHEUS_SERVICE
......
......@@ -325,6 +325,23 @@
end
end
context "phorge project" do
before_all do
create(:phorge_integration, project: project)
end
before do
project.update!(issues_enabled: false)
end
context "with right markdown" do
let(:issue) { ExternalIssue.new("T123", project) }
let(:reference) { issue.to_reference }
it_behaves_like "external issue tracker"
end
end
context 'checking N+1' do
let_it_be(:integration) { create(:redmine_integration, project: project) }
let_it_be(:issue1) { ExternalIssue.new("#123", project) }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment