diff --git a/app/graphql/types/repositories/commit_type.rb b/app/graphql/types/repositories/commit_type.rb index 1c6a6d22162cb2f81112ed27b87946674a3a45b3..e822dcaac88fa7a47c62d5633c1b9c76aa4a6bc4 100644 --- a/app/graphql/types/repositories/commit_type.rb +++ b/app/graphql/types/repositories/commit_type.rb @@ -65,10 +65,19 @@ class CommitType < BaseObject field :committer_name, type: GraphQL::Types::String, null: true, description: "Name of the committer." + field :committer_avatar_url, type: GraphQL::Types::String, null: true, + description: 'Avatar URL of the committer.' + + field :committer_web_url, type: GraphQL::Types::String, null: true, + description: 'Web URL of the committer.' + # models/commit lazy loads the author by email field :author, type: Types::UserType, null: true, description: 'Author of the commit.' + field :committer, type: Types::UserType, null: true, + description: 'Committer of the commit.' + field :diffs, [Types::DiffType], null: true, calls_gitaly: true, description: 'Diffs contained within the commit. ' \ 'This field can only be resolved for 10 diffs in any single request.' do @@ -93,6 +102,20 @@ def diffs def author_gravatar GravatarService.new.execute(object.author_email, 40) end + + def committer_avatar_url + if object.committer + object.committer.avatar_url + elsif object.committer_email + GravatarService.new.execute(object.committer_email, 40) + end + end + + def committer_web_url + return unless object.committer + + Gitlab::Routing.url_helpers.user_url(object.committer) + end end end end diff --git a/doc/api/graphql/reference/_index.md b/doc/api/graphql/reference/_index.md index cabfdeb803db7a25c3b1606bcb6efb41676e4250..5219c7ece153ae970a6cf9821d5a6e8cca32b993 100644 --- a/doc/api/graphql/reference/_index.md +++ b/doc/api/graphql/reference/_index.md @@ -26757,8 +26757,11 @@ Represents a summary of the compared codequality report. | `authorName` | [`String`](#string) | Commit authors name. | | `authoredDate` | [`Time`](#time) | Timestamp of when the commit was authored. | | `committedDate` | [`Time`](#time) | Timestamp of when the commit was committed. | +| `committer` | [`UserCore`](#usercore) | Committer of the commit. | +| `committerAvatarUrl` | [`String`](#string) | Avatar URL of the committer. | | `committerEmail` | [`String`](#string) | Email of the committer. | | `committerName` | [`String`](#string) | Name of the committer. | +| `committerWebUrl` | [`String`](#string) | Web URL of the committer. | | `description` | [`String`](#string) | Description of the commit message. | | `descriptionHtml` | [`String`](#string) | GitLab Flavored Markdown rendering of `description`. | | `diffs` | [`[Diff!]`](#diff) | Diffs contained within the commit. This field can only be resolved for 10 diffs in any single request. | diff --git a/spec/graphql/types/repositories/commit_type_spec.rb b/spec/graphql/types/repositories/commit_type_spec.rb index bc6da8931d3c67c85da740052bc44a387e16fb1d..d96cf719b6b7334c76ea1c8836894102202c5602 100644 --- a/spec/graphql/types/repositories/commit_type_spec.rb +++ b/spec/graphql/types/repositories/commit_type_spec.rb @@ -14,7 +14,8 @@ :id, :sha, :short_id, :title, :full_title, :full_title_html, :description, :description_html, :message, :title_html, :authored_date, :author_name, :author_email, :author_gravatar, :author, :diffs, :web_url, :web_path, - :pipelines, :signature_html, :signature, :committer_name, :committer_email, :committed_date, + :pipelines, :signature_html, :signature, :committer_name, :committer_email, :committer_avatar_url, + :committer_web_url, :committer, :committed_date, :name ) end