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 possible TypeError for gitlab system hook without commit message

Judith Roth49a7f0d55be3
diff --git a/modules/gitlab_integration/lib/open_project/gitlab_integration/notification_handler/system_hook.rb b/modules/gitlab_integration/lib/open_project/gitlab_integration/notification_handler/system_hook.rb
index 5e91993c0f4..0a94226af68 100644
--- a/modules/gitlab_integration/lib/open_project/gitlab_integration/notification_handler/system_hook.rb
+++ b/modules/gitlab_integration/lib/open_project/gitlab_integration/notification_handler/system_hook.rb
@@ -40,7 +40,9 @@ module OpenProject::GitlabIntegration
payload.commits.each do |commit|
user = User.find_by_id(payload.open_project_user_id)
- text = commit["title"] + " - " + commit["message"]
+ text = [commit["title"], commit["message"]]
+ .select(&:present?)
+ .join(" - ")
work_packages = find_mentioned_work_packages(text, user)
notes = generate_notes(commit, payload)
comment_on_referenced_work_packages(work_packages, user, notes)
@@ -55,7 +57,7 @@ module OpenProject::GitlabIntegration
commit_id = commit["id"]
I18n.t("gitlab_integration.push_single_commit_comment",
commit_number: commit_id[0, 8],
- commit_note: commit["message"],
+ commit_note: commit["message"].presence || commit["title"],
commit_url: commit["url"],
commit_timestamp: commit["timestamp"],
repository: payload.repository.name,