From 610f44a9660aca4bfae9b8c9268af755187e2f66 Mon Sep 17 00:00:00 2001 From: Samaksh Agarwal Date: Tue, 29 Jul 2025 21:19:35 +0000 Subject: [PATCH 1/9] Added indicator when diffs are omitted due to too many changes --- doc-locale/ja-jp/api/commits.md | 1 + doc-locale/ja-jp/api/merge_requests.md | 6 ++++++ doc-locale/ja-jp/api/repositories.md | 1 + doc/api/commits.md | 1 + doc/api/merge_requests.md | 6 ++++++ doc/api/repositories.md | 1 + lib/api/entities/diff.rb | 1 + spec/lib/api/entities/diff_spec.rb | 1 + 8 files changed, 18 insertions(+) diff --git a/doc-locale/ja-jp/api/commits.md b/doc-locale/ja-jp/api/commits.md index 4b205643e7c003..380bbaf9a369b5 100644 --- a/doc-locale/ja-jp/api/commits.md +++ b/doc-locale/ja-jp/api/commits.md @@ -513,6 +513,7 @@ curl --header "PRIVATE-TOKEN: " \ [ { "diff": "@@ -71,6 +71,8 @@\n sudo -u git -H bundle exec rake migrate_keys RAILS_ENV=production\n sudo -u git -H bundle exec rake migrate_inline_notes RAILS_ENV=production\n \n+sudo -u git -H bundle exec rake gitlab:assets:compile RAILS_ENV=production\n+\n ```\n \n ### 6. Update config files", + "too_large": false, "new_path": "doc/update/5.4-to-6.0.md", "old_path": "doc/update/5.4-to-6.0.md", "a_mode": null, diff --git a/doc-locale/ja-jp/api/merge_requests.md b/doc-locale/ja-jp/api/merge_requests.md index e7b58ccf1590eb..745801773d8716 100644 --- a/doc-locale/ja-jp/api/merge_requests.md +++ b/doc-locale/ja-jp/api/merge_requests.md @@ -1856,6 +1856,7 @@ GET /projects/:id/merge_requests/:merge_request_iid/changes "a_mode": "100644", "b_mode": "100644", "diff": "@@ -1 +1 @@\ -1.9.7\ +1.9.8", + "too_large": false, "new_file": false, "renamed_file": false, "deleted_file": false @@ -1900,6 +1901,7 @@ GET /projects/:id/merge_requests/:merge_request_iid/diffs | `a_mode` | 文字列 | ファイルの古いファイルモード。 | | `b_mode` | 文字列 | ファイルの新しいファイルモード。 | | `diff` | 文字列 | ファイルに加えられた変更の差分の表現。 | +| `too_large` | ブール値 | 変更が多すぎるためにファイルの差分が除外されたかどうかを示します。| | `new_file` | ブール値 | ファイルが追加されたばかりかどうかを示します。 | | `renamed_file` | ブール値 | ファイル名が変更されたかどうかを示します。 | | `deleted_file` | ブール値 | ファイルが削除されたかどうかを示します。 | @@ -1922,6 +1924,7 @@ curl --header "PRIVATE-TOKEN: " \ "a_mode": "100644", "b_mode": "100644", "diff": "@@ -1 +1 @@\ -Title\ +README", + "too_large": false, "new_file": false, "renamed_file": false, "deleted_file": false, @@ -1933,6 +1936,7 @@ curl --header "PRIVATE-TOKEN: " \ "a_mode": "100644", "b_mode": "100644", "diff": "@@\ -1.9.7\ +1.9.8", + "too_large": false, "new_file": false, "renamed_file": false, "deleted_file": false, @@ -3681,6 +3685,7 @@ GET /projects/:id/merge_requests/:merge_request_iid/versions/:version_id | `created_at` | 日時 | マージリクエストの作成日時。 | | `diffs` | オブジェクト配列 | マージリクエスト差分バージョンでの差分。 | | `diffs[].diff` | 文字列 | 差分の内容。 | +| `diffs[].too_large` | ブール値 | 変更が多すぎるためにファイルの差分が除外されたかどうかを示します。| | `diffs[].new_path` | 文字列 | ファイルの新しいパス。 | | `diffs[].old_path` | 文字列 | ファイルの古いパス。 | | `diffs[].a_mode` | 文字列 | ファイルの古いファイルモード。 | @@ -3771,6 +3776,7 @@ curl --header "PRIVATE-TOKEN: " \ "a_mode": "0", "b_mode": "100644", "diff": "@@ -0,0 +1,21 @@\n+The MIT License (MIT)\n+\n+Copyright (c) 2018 Administrator\n+\n+Permission is hereby granted, free of charge, to any person obtaining a copy\n+of this software and associated documentation files (the \"Software\"), to deal\n+in the Software without restriction, including without limitation the rights\n+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+copies of the Software, and to permit persons to whom the Software is\n+furnished to do so, subject to the following conditions:\n+\n+The above copyright notice and this permission notice shall be included in all\n+copies or substantial portions of the Software.\n+\n+THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n+SOFTWARE.\n", + "too_large": false, "new_file": true, "renamed_file": false, "deleted_file": false, diff --git a/doc-locale/ja-jp/api/repositories.md b/doc-locale/ja-jp/api/repositories.md index 00d98b2e5bd458..b5a6debca82716 100644 --- a/doc-locale/ja-jp/api/repositories.md +++ b/doc-locale/ja-jp/api/repositories.md @@ -220,6 +220,7 @@ GET /projects/:id/repository/compare?from=main&to=feature "a_mode": null, "b_mode": "100644", "diff": "@@ -24,8 +24,10 @@\n //= require g.raphael-min\n //= require g.bar-min\n //= require branch-graph\n-//= require highlightjs.min\n-//= require ace/ace\n //= require_tree .\n //= require d3\n //= require underscore\n+\n+function fix() { \n+ alert(\"Fixed\")\n+}", + "too_large": false, "new_file": false, "renamed_file": false, "deleted_file": false diff --git a/doc/api/commits.md b/doc/api/commits.md index 62ad1fe4ee5017..8b18efb97a37fe 100644 --- a/doc/api/commits.md +++ b/doc/api/commits.md @@ -677,6 +677,7 @@ Example response: [ { "diff": "@@ -71,6 +71,8 @@\n sudo -u git -H bundle exec rake migrate_keys RAILS_ENV=production\n sudo -u git -H bundle exec rake migrate_inline_notes RAILS_ENV=production\n \n+sudo -u git -H bundle exec rake gitlab:assets:compile RAILS_ENV=production\n+\n ```\n \n ### 6. Update config files", + "too_large": false, "new_path": "doc/update/5.4-to-6.0.md", "old_path": "doc/update/5.4-to-6.0.md", "a_mode": null, diff --git a/doc/api/merge_requests.md b/doc/api/merge_requests.md index d7689f4f0e2494..6db3810a404ce1 100644 --- a/doc/api/merge_requests.md +++ b/doc/api/merge_requests.md @@ -1878,6 +1878,7 @@ Example response: "a_mode": "100644", "b_mode": "100644", "diff": "@@ -1 +1 @@\ -1.9.7\ +1.9.8", + "too_large": false, "new_file": false, "renamed_file": false, "deleted_file": false @@ -1923,6 +1924,7 @@ following response attributes: | `a_mode` | string | Old file mode of the file. | | `b_mode` | string | New file mode of the file. | | `diff` | string | Diff representation of the changes made to the file. | +| `too_large` | boolean | Indicates if file diffs are excluded due to too many changes. | | `new_file` | boolean | Indicates if the file has just been added. | | `renamed_file` | boolean | Indicates if the file has been renamed. | | `deleted_file` | boolean | Indicates if the file has been removed. | @@ -1945,6 +1947,7 @@ Example response: "a_mode": "100644", "b_mode": "100644", "diff": "@@ -1 +1 @@\ -Title\ +README", + "too_large": false, "new_file": false, "renamed_file": false, "deleted_file": false, @@ -1956,6 +1959,7 @@ Example response: "a_mode": "100644", "b_mode": "100644", "diff": "@@\ -1.9.7\ +1.9.8", + "too_large": false, "new_file": false, "renamed_file": false, "deleted_file": false, @@ -3726,6 +3730,7 @@ response attributes: | `created_at` | datetime | Creation date and time of the merge request. | | `diffs` | object array | Diffs in the merge request diff version. | | `diffs[].diff` | string | Content of the diff. | +| `diffs[].too_large` | boolean | Indicates if file diffs are excluded due to too many changes. | | `diffs[].new_path` | string | New path of the file. | | `diffs[].old_path` | string | Old path of the file. | | `diffs[].a_mode` | string | Old file mode of the file. | @@ -3816,6 +3821,7 @@ Example response: "a_mode": "0", "b_mode": "100644", "diff": "@@ -0,0 +1,21 @@\n+The MIT License (MIT)\n+\n+Copyright (c) 2018 Administrator\n+\n+Permission is hereby granted, free of charge, to any person obtaining a copy\n+of this software and associated documentation files (the \"Software\"), to deal\n+in the Software without restriction, including without limitation the rights\n+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+copies of the Software, and to permit persons to whom the Software is\n+furnished to do so, subject to the following conditions:\n+\n+The above copyright notice and this permission notice shall be included in all\n+copies or substantial portions of the Software.\n+\n+THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n+SOFTWARE.\n", + "too_large": false, "new_file": true, "renamed_file": false, "deleted_file": false, diff --git a/doc/api/repositories.md b/doc/api/repositories.md index 9ed815d965e770..d9fd44a92ecbb9 100644 --- a/doc/api/repositories.md +++ b/doc/api/repositories.md @@ -232,6 +232,7 @@ Example response: "a_mode": null, "b_mode": "100644", "diff": "@@ -24,8 +24,10 @@\n //= require g.raphael-min\n //= require g.bar-min\n //= require branch-graph\n-//= require highlightjs.min\n-//= require ace/ace\n //= require_tree .\n //= require d3\n //= require underscore\n+\n+function fix() { \n+ alert(\"Fixed\")\n+}", + "too_large": false, "new_file": false, "renamed_file": false, "deleted_file": false diff --git a/lib/api/entities/diff.rb b/lib/api/entities/diff.rb index e1e6ce2626333e..533936be08fdd4 100644 --- a/lib/api/entities/diff.rb +++ b/lib/api/entities/diff.rb @@ -9,6 +9,7 @@ class Diff < Grape::Entity } do |instance, options| options[:enable_unidiff] == true ? instance.unidiff : instance.json_safe_diff end + expose :too_large?, as: :too_large, documentation: { type: 'boolean' } expose :new_path, documentation: { type: 'string', example: 'doc/update/5.4-to-6.0.md' } expose :old_path, documentation: { type: 'string', example: 'doc/update/5.4-to-6.0.md' } expose :a_mode, documentation: { type: 'string', example: '100755' } diff --git a/spec/lib/api/entities/diff_spec.rb b/spec/lib/api/entities/diff_spec.rb index 535567d4d8dec2..a460a1d0b98d04 100644 --- a/spec/lib/api/entities/diff_spec.rb +++ b/spec/lib/api/entities/diff_spec.rb @@ -17,6 +17,7 @@ expect(entity.as_json).to eq( { diff: diff.diff, + too_large: diff.too_large?, new_path: diff.new_path, old_path: diff.old_path, a_mode: diff.a_mode, -- GitLab From ab1b64fa53fff2dba6451dea3f99b643d59a87f9 Mon Sep 17 00:00:00 2001 From: Samaksh Agarwal Date: Tue, 29 Jul 2025 21:33:38 +0000 Subject: [PATCH 2/9] Updated openapi doc --- doc/api/openapi/openapi_v2.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/api/openapi/openapi_v2.yaml b/doc/api/openapi/openapi_v2.yaml index 07de76c02fa107..e751e36ceabb06 100644 --- a/doc/api/openapi/openapi_v2.yaml +++ b/doc/api/openapi/openapi_v2.yaml @@ -54511,6 +54511,8 @@ definitions: diff: type: string example: "@@ -71,6 +71,8 @@\\n..." + too_large: + type: boolean new_path: type: string example: doc/update/5.4-to-6.0.md -- GitLab From ad39a255de672e55118109717c08ef4c626841d5 Mon Sep 17 00:00:00 2001 From: Samaksh Agarwal Date: Tue, 29 Jul 2025 21:57:04 +0000 Subject: [PATCH 3/9] Added description for exposed boolean for better clarity --- lib/api/entities/diff.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/api/entities/diff.rb b/lib/api/entities/diff.rb index 533936be08fdd4..6dc2b4fc5b2d4a 100644 --- a/lib/api/entities/diff.rb +++ b/lib/api/entities/diff.rb @@ -9,7 +9,8 @@ class Diff < Grape::Entity } do |instance, options| options[:enable_unidiff] == true ? instance.unidiff : instance.json_safe_diff end - expose :too_large?, as: :too_large, documentation: { type: 'boolean' } + expose :too_large?, as: :too_large, + documentation: { type: 'boolean', desc: 'Indicates if file diffs are excluded due to too many changes' } expose :new_path, documentation: { type: 'string', example: 'doc/update/5.4-to-6.0.md' } expose :old_path, documentation: { type: 'string', example: 'doc/update/5.4-to-6.0.md' } expose :a_mode, documentation: { type: 'string', example: '100755' } -- GitLab From 89e40957224c2ad2309a45942d6ed0ef5c2c8333 Mon Sep 17 00:00:00 2001 From: Samaksh Agarwal Date: Tue, 29 Jul 2025 22:25:18 +0000 Subject: [PATCH 4/9] Updated graphql and openapi docs accordingly --- doc-locale/ja-jp/api/graphql/reference/_index.md | 1 + doc/api/graphql/reference/_index.md | 1 + doc/api/openapi/openapi_v2.yaml | 1 + 3 files changed, 3 insertions(+) diff --git a/doc-locale/ja-jp/api/graphql/reference/_index.md b/doc-locale/ja-jp/api/graphql/reference/_index.md index 8a2bc50731fcdf..8f3f7dfcc1c8f2 100644 --- a/doc-locale/ja-jp/api/graphql/reference/_index.md +++ b/doc-locale/ja-jp/api/graphql/reference/_index.md @@ -24520,6 +24520,7 @@ DevopsAdoption用に有効になっているネームスペース。 | `bMode` | [`String`](#string) | ファイルの新しいファイルモード。 | | `deletedFile` | [`String`](#string) | ファイルが削除されたかどうかを示します。 | | `diff` | [`String`](#string) | ファイルに加えられた変更の差分の表現。 | +| `tooLarge` | [`String`](#string) | 変更が多すぎるためにファイルの差分が除外されたかどうかを示します。 | | `newFile` | [`String`](#string) | ファイルが追加されたばかりかどうかを示します。 | | `newPath` | [`String`](#string) | ファイルの新しいパス。 | | `oldPath` | [`String`](#string) | ファイルの古いパス。 | diff --git a/doc/api/graphql/reference/_index.md b/doc/api/graphql/reference/_index.md index 76d38d9a908d13..ab2ba225a5eb09 100644 --- a/doc/api/graphql/reference/_index.md +++ b/doc/api/graphql/reference/_index.md @@ -28603,6 +28603,7 @@ Snapshot. | `bMode` | [`String`](#string) | New file mode of the file. | | `deletedFile` | [`String`](#string) | Indicates if the file has been removed. | | `diff` | [`String`](#string) | Diff representation of the changes made to the file. | +| `tooLarge` | [`String`](#string) | Indicates if file diffs are excluded due to too many changes | | `newFile` | [`String`](#string) | Indicates if the file has just been added. | | `newPath` | [`String`](#string) | New path of the file. | | `oldPath` | [`String`](#string) | Old path of the file. | diff --git a/doc/api/openapi/openapi_v2.yaml b/doc/api/openapi/openapi_v2.yaml index e751e36ceabb06..22683551d75a19 100644 --- a/doc/api/openapi/openapi_v2.yaml +++ b/doc/api/openapi/openapi_v2.yaml @@ -54513,6 +54513,7 @@ definitions: example: "@@ -71,6 +71,8 @@\\n..." too_large: type: boolean + description: Indicates if file diffs are excluded due to too many changes new_path: type: string example: doc/update/5.4-to-6.0.md -- GitLab From c2bdb0e3596e923a6b26136057a5f1dfa616df84 Mon Sep 17 00:00:00 2001 From: Samaksh Agarwal Date: Wed, 30 Jul 2025 10:14:00 +0000 Subject: [PATCH 5/9] Made recommended changes to docs --- app/graphql/types/diff_type.rb | 2 ++ doc-locale/ja-jp/api/commits.md | 1 - doc-locale/ja-jp/api/graphql/reference/_index.md | 1 - doc-locale/ja-jp/api/merge_requests.md | 6 ------ doc-locale/ja-jp/api/repositories.md | 1 - doc/api/graphql/reference/_index.md | 2 +- lib/api/entities/diff.rb | 3 +-- 7 files changed, 4 insertions(+), 12 deletions(-) diff --git a/app/graphql/types/diff_type.rb b/app/graphql/types/diff_type.rb index 1c67c8c645a459..22188dd2c7e7e2 100644 --- a/app/graphql/types/diff_type.rb +++ b/app/graphql/types/diff_type.rb @@ -21,6 +21,8 @@ class DiffType < BaseObject description: 'Old path of the file.' field :renamed_file, GraphQL::Types::String, null: true, description: 'Indicates if the file has been renamed.' + field :too_large, GraphQL::Types::String, null: true, + description: 'Indicates if file diffs are excluded due to too many changes.' end # rubocop: enable Graphql/AuthorizeTypes end diff --git a/doc-locale/ja-jp/api/commits.md b/doc-locale/ja-jp/api/commits.md index 380bbaf9a369b5..4b205643e7c003 100644 --- a/doc-locale/ja-jp/api/commits.md +++ b/doc-locale/ja-jp/api/commits.md @@ -513,7 +513,6 @@ curl --header "PRIVATE-TOKEN: " \ [ { "diff": "@@ -71,6 +71,8 @@\n sudo -u git -H bundle exec rake migrate_keys RAILS_ENV=production\n sudo -u git -H bundle exec rake migrate_inline_notes RAILS_ENV=production\n \n+sudo -u git -H bundle exec rake gitlab:assets:compile RAILS_ENV=production\n+\n ```\n \n ### 6. Update config files", - "too_large": false, "new_path": "doc/update/5.4-to-6.0.md", "old_path": "doc/update/5.4-to-6.0.md", "a_mode": null, diff --git a/doc-locale/ja-jp/api/graphql/reference/_index.md b/doc-locale/ja-jp/api/graphql/reference/_index.md index 8f3f7dfcc1c8f2..8a2bc50731fcdf 100644 --- a/doc-locale/ja-jp/api/graphql/reference/_index.md +++ b/doc-locale/ja-jp/api/graphql/reference/_index.md @@ -24520,7 +24520,6 @@ DevopsAdoption用に有効になっているネームスペース。 | `bMode` | [`String`](#string) | ファイルの新しいファイルモード。 | | `deletedFile` | [`String`](#string) | ファイルが削除されたかどうかを示します。 | | `diff` | [`String`](#string) | ファイルに加えられた変更の差分の表現。 | -| `tooLarge` | [`String`](#string) | 変更が多すぎるためにファイルの差分が除外されたかどうかを示します。 | | `newFile` | [`String`](#string) | ファイルが追加されたばかりかどうかを示します。 | | `newPath` | [`String`](#string) | ファイルの新しいパス。 | | `oldPath` | [`String`](#string) | ファイルの古いパス。 | diff --git a/doc-locale/ja-jp/api/merge_requests.md b/doc-locale/ja-jp/api/merge_requests.md index 745801773d8716..e7b58ccf1590eb 100644 --- a/doc-locale/ja-jp/api/merge_requests.md +++ b/doc-locale/ja-jp/api/merge_requests.md @@ -1856,7 +1856,6 @@ GET /projects/:id/merge_requests/:merge_request_iid/changes "a_mode": "100644", "b_mode": "100644", "diff": "@@ -1 +1 @@\ -1.9.7\ +1.9.8", - "too_large": false, "new_file": false, "renamed_file": false, "deleted_file": false @@ -1901,7 +1900,6 @@ GET /projects/:id/merge_requests/:merge_request_iid/diffs | `a_mode` | 文字列 | ファイルの古いファイルモード。 | | `b_mode` | 文字列 | ファイルの新しいファイルモード。 | | `diff` | 文字列 | ファイルに加えられた変更の差分の表現。 | -| `too_large` | ブール値 | 変更が多すぎるためにファイルの差分が除外されたかどうかを示します。| | `new_file` | ブール値 | ファイルが追加されたばかりかどうかを示します。 | | `renamed_file` | ブール値 | ファイル名が変更されたかどうかを示します。 | | `deleted_file` | ブール値 | ファイルが削除されたかどうかを示します。 | @@ -1924,7 +1922,6 @@ curl --header "PRIVATE-TOKEN: " \ "a_mode": "100644", "b_mode": "100644", "diff": "@@ -1 +1 @@\ -Title\ +README", - "too_large": false, "new_file": false, "renamed_file": false, "deleted_file": false, @@ -1936,7 +1933,6 @@ curl --header "PRIVATE-TOKEN: " \ "a_mode": "100644", "b_mode": "100644", "diff": "@@\ -1.9.7\ +1.9.8", - "too_large": false, "new_file": false, "renamed_file": false, "deleted_file": false, @@ -3685,7 +3681,6 @@ GET /projects/:id/merge_requests/:merge_request_iid/versions/:version_id | `created_at` | 日時 | マージリクエストの作成日時。 | | `diffs` | オブジェクト配列 | マージリクエスト差分バージョンでの差分。 | | `diffs[].diff` | 文字列 | 差分の内容。 | -| `diffs[].too_large` | ブール値 | 変更が多すぎるためにファイルの差分が除外されたかどうかを示します。| | `diffs[].new_path` | 文字列 | ファイルの新しいパス。 | | `diffs[].old_path` | 文字列 | ファイルの古いパス。 | | `diffs[].a_mode` | 文字列 | ファイルの古いファイルモード。 | @@ -3776,7 +3771,6 @@ curl --header "PRIVATE-TOKEN: " \ "a_mode": "0", "b_mode": "100644", "diff": "@@ -0,0 +1,21 @@\n+The MIT License (MIT)\n+\n+Copyright (c) 2018 Administrator\n+\n+Permission is hereby granted, free of charge, to any person obtaining a copy\n+of this software and associated documentation files (the \"Software\"), to deal\n+in the Software without restriction, including without limitation the rights\n+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+copies of the Software, and to permit persons to whom the Software is\n+furnished to do so, subject to the following conditions:\n+\n+The above copyright notice and this permission notice shall be included in all\n+copies or substantial portions of the Software.\n+\n+THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n+SOFTWARE.\n", - "too_large": false, "new_file": true, "renamed_file": false, "deleted_file": false, diff --git a/doc-locale/ja-jp/api/repositories.md b/doc-locale/ja-jp/api/repositories.md index b5a6debca82716..00d98b2e5bd458 100644 --- a/doc-locale/ja-jp/api/repositories.md +++ b/doc-locale/ja-jp/api/repositories.md @@ -220,7 +220,6 @@ GET /projects/:id/repository/compare?from=main&to=feature "a_mode": null, "b_mode": "100644", "diff": "@@ -24,8 +24,10 @@\n //= require g.raphael-min\n //= require g.bar-min\n //= require branch-graph\n-//= require highlightjs.min\n-//= require ace/ace\n //= require_tree .\n //= require d3\n //= require underscore\n+\n+function fix() { \n+ alert(\"Fixed\")\n+}", - "too_large": false, "new_file": false, "renamed_file": false, "deleted_file": false diff --git a/doc/api/graphql/reference/_index.md b/doc/api/graphql/reference/_index.md index ab2ba225a5eb09..870ee903141d42 100644 --- a/doc/api/graphql/reference/_index.md +++ b/doc/api/graphql/reference/_index.md @@ -28603,11 +28603,11 @@ Snapshot. | `bMode` | [`String`](#string) | New file mode of the file. | | `deletedFile` | [`String`](#string) | Indicates if the file has been removed. | | `diff` | [`String`](#string) | Diff representation of the changes made to the file. | -| `tooLarge` | [`String`](#string) | Indicates if file diffs are excluded due to too many changes | | `newFile` | [`String`](#string) | Indicates if the file has just been added. | | `newPath` | [`String`](#string) | New path of the file. | | `oldPath` | [`String`](#string) | Old path of the file. | | `renamedFile` | [`String`](#string) | Indicates if the file has been renamed. | +| `tooLarge` | [`String`](#string) | Indicates if file diffs are excluded due to too many changes. | ### `DiffPosition` diff --git a/lib/api/entities/diff.rb b/lib/api/entities/diff.rb index 6dc2b4fc5b2d4a..533936be08fdd4 100644 --- a/lib/api/entities/diff.rb +++ b/lib/api/entities/diff.rb @@ -9,8 +9,7 @@ class Diff < Grape::Entity } do |instance, options| options[:enable_unidiff] == true ? instance.unidiff : instance.json_safe_diff end - expose :too_large?, as: :too_large, - documentation: { type: 'boolean', desc: 'Indicates if file diffs are excluded due to too many changes' } + expose :too_large?, as: :too_large, documentation: { type: 'boolean' } expose :new_path, documentation: { type: 'string', example: 'doc/update/5.4-to-6.0.md' } expose :old_path, documentation: { type: 'string', example: 'doc/update/5.4-to-6.0.md' } expose :a_mode, documentation: { type: 'string', example: '100755' } -- GitLab From abcc7fe33adf709622e5884eccaeb89b43ddd3df Mon Sep 17 00:00:00 2001 From: Samaksh Agarwal Date: Wed, 30 Jul 2025 10:22:15 +0000 Subject: [PATCH 6/9] Updated openapi docs --- doc/api/openapi/openapi_v2.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/api/openapi/openapi_v2.yaml b/doc/api/openapi/openapi_v2.yaml index 22683551d75a19..e751e36ceabb06 100644 --- a/doc/api/openapi/openapi_v2.yaml +++ b/doc/api/openapi/openapi_v2.yaml @@ -54513,7 +54513,6 @@ definitions: example: "@@ -71,6 +71,8 @@\\n..." too_large: type: boolean - description: Indicates if file diffs are excluded due to too many changes new_path: type: string example: doc/update/5.4-to-6.0.md -- GitLab From e63d4ab6cff58345ba515a7e113585d3c152db58 Mon Sep 17 00:00:00 2001 From: Samaksh Agarwal Date: Wed, 30 Jul 2025 11:26:53 +0000 Subject: [PATCH 7/9] Updated spec for diff type --- spec/graphql/types/diff_type_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/graphql/types/diff_type_spec.rb b/spec/graphql/types/diff_type_spec.rb index 04f4ff9feeda1b..54629ee0da7e8e 100644 --- a/spec/graphql/types/diff_type_spec.rb +++ b/spec/graphql/types/diff_type_spec.rb @@ -10,7 +10,7 @@ it 'contains attributes related to diff' do expect(described_class).to have_graphql_fields( - :a_mode, :b_mode, :deleted_file, :diff, :new_file, :new_path, :old_path, :renamed_file + :a_mode, :b_mode, :deleted_file, :diff, :new_file, :new_path, :old_path, :renamed_file, :too_large ) end -- GitLab From 4962170f1aaf4c1223d48d76821ab564c84e367f Mon Sep 17 00:00:00 2001 From: Samaksh Agarwal Date: Fri, 22 Aug 2025 14:08:51 +0000 Subject: [PATCH 8/9] Exposed collapsed indicator for file diffs --- app/graphql/types/diff_type.rb | 5 ++++- doc/api/commits.md | 1 + doc/api/graphql/reference/_index.md | 3 ++- doc/api/merge_requests.md | 10 ++++++++-- doc/api/openapi/openapi_v2.yaml | 2 ++ doc/api/repositories.md | 1 + lib/api/entities/diff.rb | 1 + spec/graphql/types/diff_type_spec.rb | 2 +- spec/lib/api/entities/diff_spec.rb | 1 + 9 files changed, 21 insertions(+), 5 deletions(-) diff --git a/app/graphql/types/diff_type.rb b/app/graphql/types/diff_type.rb index 22188dd2c7e7e2..d0631928cb43df 100644 --- a/app/graphql/types/diff_type.rb +++ b/app/graphql/types/diff_type.rb @@ -9,6 +9,9 @@ class DiffType < BaseObject description: 'Old file mode of the file.' field :b_mode, GraphQL::Types::String, null: true, description: 'New file mode of the file.' + field :collapsed, GraphQL::Types::String, null: true, + description: 'Indicates if file diffs are excluded due to too many changes, + but the content can be fetched if requested.' field :deleted_file, GraphQL::Types::String, null: true, description: 'Indicates if the file has been removed. ' field :diff, GraphQL::Types::String, null: true, @@ -22,7 +25,7 @@ class DiffType < BaseObject field :renamed_file, GraphQL::Types::String, null: true, description: 'Indicates if the file has been renamed.' field :too_large, GraphQL::Types::String, null: true, - description: 'Indicates if file diffs are excluded due to too many changes.' + description: 'Indicates if file diffs are excluded due to too many changes, and content cannot be retrieved.' end # rubocop: enable Graphql/AuthorizeTypes end diff --git a/doc/api/commits.md b/doc/api/commits.md index 8b18efb97a37fe..9995b936a65491 100644 --- a/doc/api/commits.md +++ b/doc/api/commits.md @@ -677,6 +677,7 @@ Example response: [ { "diff": "@@ -71,6 +71,8 @@\n sudo -u git -H bundle exec rake migrate_keys RAILS_ENV=production\n sudo -u git -H bundle exec rake migrate_inline_notes RAILS_ENV=production\n \n+sudo -u git -H bundle exec rake gitlab:assets:compile RAILS_ENV=production\n+\n ```\n \n ### 6. Update config files", + "collapsed": false, "too_large": false, "new_path": "doc/update/5.4-to-6.0.md", "old_path": "doc/update/5.4-to-6.0.md", diff --git a/doc/api/graphql/reference/_index.md b/doc/api/graphql/reference/_index.md index 870ee903141d42..dfe771f5cad525 100644 --- a/doc/api/graphql/reference/_index.md +++ b/doc/api/graphql/reference/_index.md @@ -28601,13 +28601,14 @@ Snapshot. | ---- | ---- | ----------- | | `aMode` | [`String`](#string) | Old file mode of the file. | | `bMode` | [`String`](#string) | New file mode of the file. | +| `collapsed` | [`String`](#string) | Indicates if file diffs are excluded due to too many changes, but the content can be fetched if requested. | | `deletedFile` | [`String`](#string) | Indicates if the file has been removed. | | `diff` | [`String`](#string) | Diff representation of the changes made to the file. | | `newFile` | [`String`](#string) | Indicates if the file has just been added. | | `newPath` | [`String`](#string) | New path of the file. | | `oldPath` | [`String`](#string) | Old path of the file. | | `renamedFile` | [`String`](#string) | Indicates if the file has been renamed. | -| `tooLarge` | [`String`](#string) | Indicates if file diffs are excluded due to too many changes. | +| `tooLarge` | [`String`](#string) | Indicates if file diffs are excluded due to too many changes, and content cannot be retrieved. | ### `DiffPosition` diff --git a/doc/api/merge_requests.md b/doc/api/merge_requests.md index 6db3810a404ce1..419e689f9c5e82 100644 --- a/doc/api/merge_requests.md +++ b/doc/api/merge_requests.md @@ -1878,6 +1878,7 @@ Example response: "a_mode": "100644", "b_mode": "100644", "diff": "@@ -1 +1 @@\ -1.9.7\ +1.9.8", + "collapsed": false, "too_large": false, "new_file": false, "renamed_file": false, @@ -1924,7 +1925,8 @@ following response attributes: | `a_mode` | string | Old file mode of the file. | | `b_mode` | string | New file mode of the file. | | `diff` | string | Diff representation of the changes made to the file. | -| `too_large` | boolean | Indicates if file diffs are excluded due to too many changes. | +| `collapsed` | boolean | Indicates if file diffs are excluded due to too many changes, but the content can still be fetched if requested. | +| `too_large` | boolean | Indicates if file diffs are excluded due to too many changes, and content cannot be retrieved. | | `new_file` | boolean | Indicates if the file has just been added. | | `renamed_file` | boolean | Indicates if the file has been renamed. | | `deleted_file` | boolean | Indicates if the file has been removed. | @@ -1947,6 +1949,7 @@ Example response: "a_mode": "100644", "b_mode": "100644", "diff": "@@ -1 +1 @@\ -Title\ +README", + "collapsed": false, "too_large": false, "new_file": false, "renamed_file": false, @@ -1959,6 +1962,7 @@ Example response: "a_mode": "100644", "b_mode": "100644", "diff": "@@\ -1.9.7\ +1.9.8", + "collapsed": false, "too_large": false, "new_file": false, "renamed_file": false, @@ -3730,7 +3734,8 @@ response attributes: | `created_at` | datetime | Creation date and time of the merge request. | | `diffs` | object array | Diffs in the merge request diff version. | | `diffs[].diff` | string | Content of the diff. | -| `diffs[].too_large` | boolean | Indicates if file diffs are excluded due to too many changes. | +| `diffs[].collapsed` | boolean | Indicates if file diffs are excluded due to too many changes, but the content can still be fetched if requested. | +| `diffs[].too_large` | boolean | Indicates if file diffs are excluded due to too many changes, and content cannot be retrieved. | | `diffs[].new_path` | string | New path of the file. | | `diffs[].old_path` | string | Old path of the file. | | `diffs[].a_mode` | string | Old file mode of the file. | @@ -3821,6 +3826,7 @@ Example response: "a_mode": "0", "b_mode": "100644", "diff": "@@ -0,0 +1,21 @@\n+The MIT License (MIT)\n+\n+Copyright (c) 2018 Administrator\n+\n+Permission is hereby granted, free of charge, to any person obtaining a copy\n+of this software and associated documentation files (the \"Software\"), to deal\n+in the Software without restriction, including without limitation the rights\n+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+copies of the Software, and to permit persons to whom the Software is\n+furnished to do so, subject to the following conditions:\n+\n+The above copyright notice and this permission notice shall be included in all\n+copies or substantial portions of the Software.\n+\n+THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n+SOFTWARE.\n", + "collapsed": false, "too_large": false, "new_file": true, "renamed_file": false, diff --git a/doc/api/openapi/openapi_v2.yaml b/doc/api/openapi/openapi_v2.yaml index e751e36ceabb06..3c2c409889551c 100644 --- a/doc/api/openapi/openapi_v2.yaml +++ b/doc/api/openapi/openapi_v2.yaml @@ -54511,6 +54511,8 @@ definitions: diff: type: string example: "@@ -71,6 +71,8 @@\\n..." + collapsed: + type: boolean too_large: type: boolean new_path: diff --git a/doc/api/repositories.md b/doc/api/repositories.md index d9fd44a92ecbb9..760bc90471cae8 100644 --- a/doc/api/repositories.md +++ b/doc/api/repositories.md @@ -232,6 +232,7 @@ Example response: "a_mode": null, "b_mode": "100644", "diff": "@@ -24,8 +24,10 @@\n //= require g.raphael-min\n //= require g.bar-min\n //= require branch-graph\n-//= require highlightjs.min\n-//= require ace/ace\n //= require_tree .\n //= require d3\n //= require underscore\n+\n+function fix() { \n+ alert(\"Fixed\")\n+}", + "collapsed": false, "too_large": false, "new_file": false, "renamed_file": false, diff --git a/lib/api/entities/diff.rb b/lib/api/entities/diff.rb index 533936be08fdd4..d533fd9ccadc15 100644 --- a/lib/api/entities/diff.rb +++ b/lib/api/entities/diff.rb @@ -9,6 +9,7 @@ class Diff < Grape::Entity } do |instance, options| options[:enable_unidiff] == true ? instance.unidiff : instance.json_safe_diff end + expose :collapsed?, as: :collapsed, documentation: { type: 'boolean' } expose :too_large?, as: :too_large, documentation: { type: 'boolean' } expose :new_path, documentation: { type: 'string', example: 'doc/update/5.4-to-6.0.md' } expose :old_path, documentation: { type: 'string', example: 'doc/update/5.4-to-6.0.md' } diff --git a/spec/graphql/types/diff_type_spec.rb b/spec/graphql/types/diff_type_spec.rb index 54629ee0da7e8e..44d8b66b81bd4c 100644 --- a/spec/graphql/types/diff_type_spec.rb +++ b/spec/graphql/types/diff_type_spec.rb @@ -10,7 +10,7 @@ it 'contains attributes related to diff' do expect(described_class).to have_graphql_fields( - :a_mode, :b_mode, :deleted_file, :diff, :new_file, :new_path, :old_path, :renamed_file, :too_large + :a_mode, :b_mode, :collapsed, :deleted_file, :diff, :new_file, :new_path, :old_path, :renamed_file, :too_large ) end diff --git a/spec/lib/api/entities/diff_spec.rb b/spec/lib/api/entities/diff_spec.rb index a460a1d0b98d04..7e17ece7b0ad23 100644 --- a/spec/lib/api/entities/diff_spec.rb +++ b/spec/lib/api/entities/diff_spec.rb @@ -17,6 +17,7 @@ expect(entity.as_json).to eq( { diff: diff.diff, + collapsed: diff.collapsed?, too_large: diff.too_large?, new_path: diff.new_path, old_path: diff.old_path, -- GitLab From 8780f1b35cba90e4b6dd7b0b2e43d0dfb03a0b72 Mon Sep 17 00:00:00 2001 From: Samaksh Agarwal Date: Tue, 26 Aug 2025 18:39:08 +0000 Subject: [PATCH 9/9] Modified docs for the changes --- app/graphql/types/diff_type.rb | 7 ++-- doc/api/commits.md | 22 +++++++++++++ doc/api/graphql/reference/_index.md | 4 +-- doc/api/merge_requests.md | 51 ++++++++++++++++------------- doc/api/repositories.md | 34 +++++++++++++++++++ 5 files changed, 90 insertions(+), 28 deletions(-) diff --git a/app/graphql/types/diff_type.rb b/app/graphql/types/diff_type.rb index d0631928cb43df..5bedf605dfbf6e 100644 --- a/app/graphql/types/diff_type.rb +++ b/app/graphql/types/diff_type.rb @@ -10,8 +10,8 @@ class DiffType < BaseObject field :b_mode, GraphQL::Types::String, null: true, description: 'New file mode of the file.' field :collapsed, GraphQL::Types::String, null: true, - description: 'Indicates if file diffs are excluded due to too many changes, - but the content can be fetched if requested.' + description: 'File diffs are excluded but can be fetched on request.', + method: :collapsed? field :deleted_file, GraphQL::Types::String, null: true, description: 'Indicates if the file has been removed. ' field :diff, GraphQL::Types::String, null: true, @@ -25,7 +25,8 @@ class DiffType < BaseObject field :renamed_file, GraphQL::Types::String, null: true, description: 'Indicates if the file has been renamed.' field :too_large, GraphQL::Types::String, null: true, - description: 'Indicates if file diffs are excluded due to too many changes, and content cannot be retrieved.' + description: 'File diffs are excluded and cannot be retrieved.', + method: :too_large? end # rubocop: enable Graphql/AuthorizeTypes end diff --git a/doc/api/commits.md b/doc/api/commits.md index 9995b936a65491..946466f857fec9 100644 --- a/doc/api/commits.md +++ b/doc/api/commits.md @@ -639,6 +639,12 @@ dry run. ## Get commit diff +{{< history >}} + +- `collapsed` and `too_large` response attributes [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/199633) in GitLab 18.4. + +{{< /history >}} + Get the diff of a commit in a project. ```plaintext @@ -671,6 +677,22 @@ curl --header "PRIVATE-TOKEN: " \ --url "https://gitlab.example.com/api/v4/projects/5/repository/commits/main/diff" ``` +If successful, returns [`200 OK`](rest/troubleshooting.md#status-codes) and the following +response attributes: + +| Attribute | Type | Description | +|----------------|---------|-------------| +| `a_mode` | string | Old file mode of the file. | +| `b_mode` | string | New file mode of the file. | +| `collapsed` | boolean | File diffs are excluded but can be fetched on request. | +| `deleted_file` | boolean | File has been removed. | +| `diff` | string | Diff representation of the changes made to the file. | +| `new_file` | boolean | File has been added. | +| `new_path` | string | New path of the file. | +| `old_path` | string | Old path of the file. | +| `renamed_file` | boolean | File has been renamed. | +| `too_large` | boolean | File diffs are excluded and cannot be retrieved. | + Example response: ```json diff --git a/doc/api/graphql/reference/_index.md b/doc/api/graphql/reference/_index.md index dfe771f5cad525..8df88b8eaf86ab 100644 --- a/doc/api/graphql/reference/_index.md +++ b/doc/api/graphql/reference/_index.md @@ -28601,14 +28601,14 @@ Snapshot. | ---- | ---- | ----------- | | `aMode` | [`String`](#string) | Old file mode of the file. | | `bMode` | [`String`](#string) | New file mode of the file. | -| `collapsed` | [`String`](#string) | Indicates if file diffs are excluded due to too many changes, but the content can be fetched if requested. | +| `collapsed` | [`String`](#string) | File diffs are excluded but can be fetched on request. | | `deletedFile` | [`String`](#string) | Indicates if the file has been removed. | | `diff` | [`String`](#string) | Diff representation of the changes made to the file. | | `newFile` | [`String`](#string) | Indicates if the file has just been added. | | `newPath` | [`String`](#string) | New path of the file. | | `oldPath` | [`String`](#string) | Old path of the file. | | `renamedFile` | [`String`](#string) | Indicates if the file has been renamed. | -| `tooLarge` | [`String`](#string) | Indicates if file diffs are excluded due to too many changes, and content cannot be retrieved. | +| `tooLarge` | [`String`](#string) | File diffs are excluded and cannot be retrieved. | ### `DiffPosition` diff --git a/doc/api/merge_requests.md b/doc/api/merge_requests.md index 419e689f9c5e82..5e47e25f307996 100644 --- a/doc/api/merge_requests.md +++ b/doc/api/merge_requests.md @@ -1878,8 +1878,6 @@ Example response: "a_mode": "100644", "b_mode": "100644", "diff": "@@ -1 +1 @@\ -1.9.7\ +1.9.8", - "collapsed": false, - "too_large": false, "new_file": false, "renamed_file": false, "deleted_file": false @@ -1896,6 +1894,7 @@ Example response: - `generated_file` [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/141576) in GitLab 16.9 [with a flag](../administration/feature_flags/_index.md) named `collapse_generated_diff_files`. Disabled by default. - [Enabled on GitLab.com and GitLab Self-Managed](https://gitlab.com/gitlab-org/gitlab/-/issues/432670) in GitLab 16.10. - `generated_file` [generally available](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/148478) in GitLab 16.11. Feature flag `collapse_generated_diff_files` removed. +- `collapsed` and `too_large` response attributes [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/199633) in GitLab 18.4. {{< /history >}} @@ -1918,19 +1917,19 @@ Supported attributes: If successful, returns [`200 OK`](rest/troubleshooting.md#status-codes) and the following response attributes: -| Attribute | Type | Description | -|----------------|---------|-------------| -| `old_path` | string | Old path of the file. | -| `new_path` | string | New path of the file. | -| `a_mode` | string | Old file mode of the file. | -| `b_mode` | string | New file mode of the file. | -| `diff` | string | Diff representation of the changes made to the file. | -| `collapsed` | boolean | Indicates if file diffs are excluded due to too many changes, but the content can still be fetched if requested. | -| `too_large` | boolean | Indicates if file diffs are excluded due to too many changes, and content cannot be retrieved. | -| `new_file` | boolean | Indicates if the file has just been added. | -| `renamed_file` | boolean | Indicates if the file has been renamed. | -| `deleted_file` | boolean | Indicates if the file has been removed. | -| `generated_file` | boolean | Indicates if the file is [marked as generated](../user/project/merge_requests/changes.md#collapse-generated-files). [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/141576) in GitLab 16.9. | +| Attribute | Type | Description | +|------------------|---------|-------------| +| `a_mode` | string | Old file mode of the file. | +| `b_mode` | string | New file mode of the file. | +| `collapsed` | boolean | File diffs are excluded but can be fetched on request. | +| `deleted_file` | boolean | File has been removed. | +| `diff` | string | Diff representation of the changes made to the file. | +| `generated_file` | boolean | File is [marked as generated](../user/project/merge_requests/changes.md#collapse-generated-files). | +| `new_file` | boolean | File has been added. | +| `new_path` | string | New path of the file. | +| `old_path` | string | Old path of the file. | +| `renamed_file` | boolean | File has been renamed. | +| `too_large` | boolean | File diffs are excluded and cannot be retrieved. | Example request: @@ -3693,6 +3692,12 @@ Example response: ## Get a single merge request diff version +{{< history >}} + +- `collapsed` and `too_large` response attributes [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/199633) in GitLab 18.4. + +{{< /history >}} + Get a single merge request diff version. ```plaintext @@ -3733,17 +3738,17 @@ response attributes: | `commits[].web_url` | string | Web URL of the merge request. | | `created_at` | datetime | Creation date and time of the merge request. | | `diffs` | object array | Diffs in the merge request diff version. | +| `diffs[].a_mode` | string | Old file mode of the file. | +| `diffs[].b_mode` | string | New file mode of the file. | +| `diffs[].collapsed` | boolean | File diffs are excluded but can be fetched on request. | +| `diffs[].deleted_file` | boolean | File has been removed. | | `diffs[].diff` | string | Content of the diff. | -| `diffs[].collapsed` | boolean | Indicates if file diffs are excluded due to too many changes, but the content can still be fetched if requested. | -| `diffs[].too_large` | boolean | Indicates if file diffs are excluded due to too many changes, and content cannot be retrieved. | +| `diffs[].generated_file` | boolean | File is [marked as generated](../user/project/merge_requests/changes.md#collapse-generated-files). | +| `diffs[].new_file` | boolean | File has been added. | | `diffs[].new_path` | string | New path of the file. | | `diffs[].old_path` | string | Old path of the file. | -| `diffs[].a_mode` | string | Old file mode of the file. | -| `diffs[].b_mode` | string | New file mode of the file. | -| `diffs[].new_file` | boolean | Indicates an added file. | -| `diffs[].renamed_file` | boolean | Indicates a renamed file. | -| `diffs[].deleted_file` | boolean | Indicates a removed file. | -| `diffs[].generated_file` | boolean | Indicates if the file is [marked as generated](../user/project/merge_requests/changes.md#collapse-generated-files). [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/141576) in GitLab 16.9. | +| `diffs[].renamed_file` | boolean | File has been renamed. | +| `diffs[].too_large` | boolean | File diffs are excluded and cannot be retrieved. | | `head_commit_sha` | string | HEAD commit of the source branch. | | `merge_request_id` | integer | ID of the merge request. | | `patch_id_sha` | string | [Patch ID](https://git-scm.com/docs/git-patch-id) for the merge request diff. | diff --git a/doc/api/repositories.md b/doc/api/repositories.md index 760bc90471cae8..bd1365383166c6 100644 --- a/doc/api/repositories.md +++ b/doc/api/repositories.md @@ -183,6 +183,12 @@ curl --header "PRIVATE-TOKEN: " \ ## Compare branches, tags or commits +{{< history >}} + +- `collapsed` and `too_large` response attributes [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/199633) in GitLab 18.4. + +{{< /history >}} + This endpoint can be accessed without authentication if the repository is publicly accessible. Diffs can have an empty diff string if diff limits are reached. @@ -202,6 +208,34 @@ Supported attributes: | `straight` | boolean | no | Comparison method: `true` for direct comparison between `from` and `to` (`from`..`to`), `false` to compare using merge base (`from`...`to`)'. Default is `false`. | | `unidiff` | boolean | No | Present diffs in the [unified diff](https://www.gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html) format. Default is false. [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/130610) in GitLab 16.5. | +If successful, returns [`200 OK`](rest/troubleshooting.md#status-codes) and the following +response attributes: + +| Attribute | Type | Description | +|-------------------------------|--------------|-------------| +| `commit` | object | Details of the latest commit in the comparison. | +| `commits` | object array | List of commits included in the comparison. | +| `commits[].author_email` | string | Commit author's email address. | +| `commits[].author_name` | string | Commit author's name. | +| `commits[].created_at` | datetime | Commit creation timestamp. | +| `commits[].id` | string | Full commit SHA. | +| `commits[].short_id` | string | Short commit SHA. | +| `commits[].title` | string | Commit title. | +| `compare_same_ref` | boolean | Comparison uses the same reference for both from and to. | +| `compare_timeout` | boolean | Comparison operation timed out. | +| `diffs` | object array | List of file differences. | +| `diffs[].a_mode` | string | Old file mode. | +| `diffs[].b_mode` | string | New file mode. | +| `diffs[].collapsed` | boolean | File diffs are excluded but can be fetched on request. | +| `diffs[].deleted_file` | boolean | File has been removed. | +| `diffs[].diff` | string | Diff content showing changes made to the file. | +| `diffs[].new_file` | boolean | File has been added. | +| `diffs[].new_path` | string | New path of the file. | +| `diffs[].old_path` | string | Old path of the file. | +| `diffs[].renamed_file` | boolean | File has been renamed. | +| `diffs[].too_large` | boolean | File diffs are excluded and cannot be retrieved. | +| `web_url` | string | Web URL for viewing the comparison. | + ```plaintext GET /projects/:id/repository/compare?from=main&to=feature ``` -- GitLab