Archived
Add OpenProject Gitea integration plugin
Implements a Gitea integration for OpenProject following the same patterns as the bundled GitHub and GitLab integrations. - Webhook endpoint at /webhooks/gitea with HMAC-SHA256 verification - Handles pull_request and issue_comment events - Links Gitea PRs to work packages via OP# references or URLs - Posts journal comments on WPs for PR lifecycle events - Gitea tab on the work package split view - V3 API endpoint: GET /api/v3/work_packages/:id/gitea_pull_requests - Admin settings UI for bot user and webhook secret - Nightly cron job to clean up unlinked PR records
This commit is contained in:
45 files changed
+2561
No files matched your search
@@ -0,0 +1,37 @@
|
||||
#-- copyright
|
||||
# OpenProject is an open source project management software.
|
||||
# Copyright (C) the OpenProject GmbH
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License version 3.
|
||||
#
|
||||
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
# Copyright (C) 2010-2013 the ChiliProject Team
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# See COPYRIGHT and LICENSE files for more details.
|
||||
#++
|
||||
|
||||
module API
|
||||
module V3
|
||||
module GiteaPullRequests
|
||||
class GiteaPullRequestCollectionRepresenter < ::API::Decorators::UnpaginatedCollection
|
||||
element_representer ::API::V3::GiteaPullRequests::GiteaPullRequestRepresenter
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,98 @@
|
||||
#-- copyright
|
||||
# OpenProject is an open source project management software.
|
||||
# Copyright (C) the OpenProject GmbH
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License version 3.
|
||||
#
|
||||
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
# Copyright (C) 2010-2013 the ChiliProject Team
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# See COPYRIGHT and LICENSE files for more details.
|
||||
#++
|
||||
|
||||
require "roar/decorator"
|
||||
require "roar/json/hal"
|
||||
|
||||
module API
|
||||
module V3
|
||||
module GiteaPullRequests
|
||||
class GiteaPullRequestRepresenter < ::API::Decorators::Single
|
||||
include API::Caching::CachedRepresenter
|
||||
include API::Decorators::DateProperty
|
||||
include API::Decorators::FormattableProperty
|
||||
include API::Decorators::LinkedResource
|
||||
|
||||
def initialize(model, current_user:, **_opts)
|
||||
super(model, current_user:, embed_links: true)
|
||||
end
|
||||
|
||||
cached_representer key_parts: %i[gitea_user merged_by]
|
||||
|
||||
property :id
|
||||
|
||||
property :number
|
||||
|
||||
property :gitea_html_url, as: :htmlUrl
|
||||
|
||||
property :state,
|
||||
render_nil: true
|
||||
|
||||
property :repository,
|
||||
render_nil: true
|
||||
|
||||
date_time_property :gitea_updated_at,
|
||||
render_nil: true,
|
||||
setter: ->(*) {}
|
||||
|
||||
property :title,
|
||||
render_nil: true
|
||||
|
||||
formattable_property :body,
|
||||
render_nil: true
|
||||
|
||||
property :draft,
|
||||
render_nil: true
|
||||
|
||||
property :merged,
|
||||
render_nil: true
|
||||
|
||||
property :labels
|
||||
|
||||
associated_resource :gitea_user,
|
||||
representer: ::API::V3::GiteaPullRequests::GiteaUserRepresenter,
|
||||
link_title_attribute: :gitea_login
|
||||
|
||||
associated_resource :merged_by,
|
||||
representer: ::API::V3::GiteaPullRequests::GiteaUserRepresenter,
|
||||
v3_path: :gitea_user,
|
||||
link_title_attribute: :gitea_login
|
||||
|
||||
date_time_property :created_at
|
||||
|
||||
date_time_property :updated_at
|
||||
|
||||
def _type
|
||||
"GiteaPullRequest"
|
||||
end
|
||||
|
||||
self.to_eager_load = %i[gitea_user merged_by]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,52 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
#-- copyright
|
||||
# OpenProject is an open source project management software.
|
||||
# Copyright (C) the OpenProject GmbH
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License version 3.
|
||||
#
|
||||
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
# Copyright (C) 2010-2013 the ChiliProject Team
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# See COPYRIGHT and LICENSE files for more details.
|
||||
#++
|
||||
|
||||
module API
|
||||
module V3
|
||||
module GiteaPullRequests
|
||||
class GiteaPullRequestsByWorkPackageAPI < ::API::OpenProjectAPI
|
||||
after_validation do
|
||||
authorize_in_work_package(:show_gitea_content, work_package: @work_package)
|
||||
@gitea_pull_requests = @work_package.gitea_pull_requests
|
||||
end
|
||||
|
||||
resources :gitea_pull_requests do
|
||||
get do
|
||||
path = api_v3_paths.gitea_pull_requests_by_work_package(@work_package.id)
|
||||
GiteaPullRequestCollectionRepresenter.new(@gitea_pull_requests,
|
||||
@gitea_pull_requests.count,
|
||||
self_link: path,
|
||||
current_user:)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,52 @@
|
||||
#-- copyright
|
||||
# OpenProject is an open source project management software.
|
||||
# Copyright (C) the OpenProject GmbH
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License version 3.
|
||||
#
|
||||
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
# Copyright (C) 2010-2013 the ChiliProject Team
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# See COPYRIGHT and LICENSE files for more details.
|
||||
#++
|
||||
|
||||
require "roar/decorator"
|
||||
require "roar/json/hal"
|
||||
|
||||
module API
|
||||
module V3
|
||||
module GiteaPullRequests
|
||||
class GiteaUserRepresenter < ::API::Decorators::Single
|
||||
property :id
|
||||
|
||||
property :gitea_id, as: :giteaId
|
||||
|
||||
property :gitea_name, as: :name
|
||||
|
||||
property :gitea_login, as: :login
|
||||
|
||||
property :gitea_avatar_url, as: :avatarUrl
|
||||
|
||||
def _type
|
||||
"GiteaUser"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user