Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[#56609] Fix translation for gitlab pushes without merge requests

Judith Roth9d8674a3787d
diff --git a/modules/gitlab_integration/config/locales/en.yml b/modules/gitlab_integration/config/locales/en.yml
index 270e5b14426..9660f5f1e10 100644
--- a/modules/gitlab_integration/config/locales/en.yml
+++ b/modules/gitlab_integration/config/locales/en.yml
@@ -99,6 +99,11 @@ en:
**Pushed in MR:** [%{gitlab_user}](%{gitlab_user_url}) pushed [%{commit_number}](%{commit_url})
to [%{repository}](%{repository_url}) at %{commit_timestamp}:
+ %{commit_note}
+ push_single_commit_comment_with_ref: >
+ **Pushed in %{reference}:** [%{gitlab_user}](%{gitlab_user_url}) pushed [%{commit_number}](%{commit_url})
+ to [%{repository}](%{repository_url}) at %{commit_timestamp}:
+
%{commit_note}
push_multiple_commits_comment: >
**Pushed in MR:** [%{gitlab_user}](%{gitlab_user_url}) pushed multiple commits [%{commit_number}](%{commit_url})
diff --git a/modules/gitlab_integration/lib/open_project/gitlab_integration/notification_handler/push_hook.rb b/modules/gitlab_integration/lib/open_project/gitlab_integration/notification_handler/push_hook.rb
index 50645832b56..ffa58558d09 100644
--- a/modules/gitlab_integration/lib/open_project/gitlab_integration/notification_handler/push_hook.rb
+++ b/modules/gitlab_integration/lib/open_project/gitlab_integration/notification_handler/push_hook.rb
@@ -55,7 +55,8 @@ module OpenProject::GitlabIntegration
def generate_notes(commit, payload)
commit_id = commit["id"]
- I18n.t("gitlab_integration.push_single_commit_comment",
+ I18n.t("gitlab_integration.push_single_commit_comment_with_ref",
+ reference: payload.ref,
commit_number: commit_id[0, 8],
commit_note: commit["message"].presence || commit["title"],
commit_url: commit["url"],
diff --git a/modules/gitlab_integration/spec/lib/open_project/gitlab_integration/notification_handler/push_hook_spec.rb b/modules/gitlab_integration/spec/lib/open_project/gitlab_integration/notification_handler/push_hook_spec.rb
index 85346989e4c..780a38ddf48 100644
--- a/modules/gitlab_integration/spec/lib/open_project/gitlab_integration/notification_handler/push_hook_spec.rb
+++ b/modules/gitlab_integration/spec/lib/open_project/gitlab_integration/notification_handler/push_hook_spec.rb
@@ -110,7 +110,7 @@ RSpec.describe OpenProject::GitlabIntegration::NotificationHandler::PushHook do
context "with a regular push" do
let(:comment) do
- "**Pushed in MR:** [Administrator]" \
+ "**Pushed in refs/heads/main:** [Administrator]" \
"(https://www.gravatar.com/avatar/65a222b844ced567fe0ed2594c0b4abdf62efa1322a385c919c41e7bbc16d4fc?s=80&d=identicon) " \
"pushed [a265d6b7](http://c7e7cd2d54c3/openprojecttest/test/-/commit/a265d6b7bcf836b77ed9e32f824b231585c6a355) " \
"to [Test](http://c7e7cd2d54c3/openprojecttest/test) at 2024-07-22T11:18:29+02:00:" \
@@ -132,7 +132,7 @@ RSpec.describe OpenProject::GitlabIntegration::NotificationHandler::PushHook do
end
let(:comment) do
- "**Pushed in MR:** [Administrator]" \
+ "**Pushed in refs/heads/main:** [Administrator]" \
"(https://www.gravatar.com/avatar/65a222b844ced567fe0ed2594c0b4abdf62efa1322a385c919c41e7bbc16d4fc?s=80&d=identicon) " \
"pushed [a265d6b7](http://c7e7cd2d54c3/openprojecttest/test/-/commit/a265d6b7bcf836b77ed9e32f824b231585c6a355) " \
"to [Test](http://c7e7cd2d54c3/openprojecttest/test) at 2024-07-22T11:18:29+02:00:\nMentioning OP##{work_package.id}\n"