From be5822c459c476f7619a6b96cf96aabcf0017b69 Mon Sep 17 00:00:00 2001 From: Christian Schilling Date: Tue, 30 Aug 2022 09:44:56 +0200 Subject: [PATCH] Add full commit message to graphql api Change-Id: graphql-commit-message --- src/graphql.rs | 11 +++++++++++ tests/filter/graphql_history.t | 4 +++- tests/proxy/graphql_schema.t | 16 ++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/graphql.rs b/src/graphql.rs index 86ed451a5..c84177a27 100644 --- a/src/graphql.rs +++ b/src/graphql.rs @@ -125,6 +125,17 @@ impl Revision { Ok(filter_commit.summary().unwrap_or("").to_owned()) } + fn message(&self, context: &Context) -> FieldResult { + let transaction = context.transaction.lock()?; + let commit = transaction.repo().find_commit(self.commit_id)?; + let filter_commit = transaction.repo().find_commit(filter::apply_to_commit( + self.filter, + &commit, + &transaction, + )?)?; + Ok(filter_commit.message().unwrap_or("").to_owned()) + } + fn date(&self, format: String, context: &Context) -> FieldResult { let transaction = context.transaction.lock()?; let commit = transaction.repo().find_commit(self.commit_id)?; diff --git a/tests/filter/graphql_history.t b/tests/filter/graphql_history.t index 8abd5a009..84981a724 100644 --- a/tests/filter/graphql_history.t +++ b/tests/filter/graphql_history.t @@ -22,6 +22,7 @@ > rev(at: "HEAD", filter: ":workspace=ws") { > history(limit: 1) { > summary + > message > } > } > } @@ -32,7 +33,8 @@ "rev": { "history": [ { - "summary": "add ws" + "summary": "add ws", + "message": "add ws\n" } ] } diff --git a/tests/proxy/graphql_schema.t b/tests/proxy/graphql_schema.t index 9476b1297..b37b2f0b4 100644 --- a/tests/proxy/graphql_schema.t +++ b/tests/proxy/graphql_schema.t @@ -323,6 +323,22 @@ } } }, + { + "args": [], + "deprecationReason": null, + "description": null, + "isDeprecated": false, + "name": "message", + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + } + }, { "args": [ {