gitlab-customer-support-operations_gitlab 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9d87f3aa25af0d3fb4b30b940a3b80ac6edc6d11cdd1b764c2aa5d28fff3522
4
- data.tar.gz: 00c29d5f699227da68e2a0ec58d3253dd8967b353e1550353e5e90f52ace5113
3
+ metadata.gz: 71687a461947fcd0ef79ae6b77c110746499c7e3c23607c46be9d6f7768e6229
4
+ data.tar.gz: a2fc0278140d19b4519b67d6ccda3626853fd4c359afb6acb82f21b9f20474a5
5
5
  SHA512:
6
- metadata.gz: d874a83d467ac3ae18af6d418bf72745f79996a0d830df122dba4e29df66dfaf90370fefcda8bb4f49f838dd6b5f10b213258813bf99176bd9df98f7b81323c7
7
- data.tar.gz: 87a2498deae3edf4f20a3bfdc019d5230487592be087331ce10864efd083f0b471630c8259fe25442861576444902b4d7ea8f614dac8b5699cc9d4a53b8eaa48
6
+ metadata.gz: d0d7d993347170672bfdfc86af99d889bb356ce3523ae40555f17beae5a738879900f5fba37b6747d6e00a02485d98bf0c0779c421cae1518c64e74c2864bebb
7
+ data.tar.gz: c45d5fc1e8fcfb803d99ee17667ad92133181df5caa57d439e03c1020eb2e4fa6a854f05d2eb555b443d42ed05122faf3158b1705d26128c7092a56a4d05ed64
@@ -312,6 +312,11 @@ module SupportOps
312
312
  contributors_record
313
313
  end
314
314
 
315
+ def diffs
316
+ ensure_client_present!
317
+ diffs_record
318
+ end
319
+
315
320
  def client=(new_client)
316
321
  @client = new_client
317
322
  end
@@ -547,6 +552,10 @@ module SupportOps
547
552
  def contributors_record
548
553
  raise NotImplementedError
549
554
  end
555
+
556
+ def diffs_record
557
+ raise NotImplementedError
558
+ end
550
559
  end
551
560
  end
552
561
  end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Defines the module SupportOps.
4
+ module SupportOps
5
+ # Defines the module GitLab
6
+ module GitLab
7
+ ##
8
+ # Defines the class MergeRequestDiffs within the module {SupportOps::GitLab}.
9
+ #
10
+ # @author Jason Colyer
11
+ # @since 1.2.0
12
+ # @attr [String] a_mode Old file mode of the file
13
+ # @attr [String] b_mode New file mode of the file
14
+ # @attr [Boolean] deleted_file Indicates if the file has been removed
15
+ # @attr [String] diff Diff representation of the changes made to the file
16
+ # @attr [Boolean] generated_file Indicates if the file is marked as generated
17
+ # @attr [String] old_path Old path of the file
18
+ # @attr [Boolean] new_file Indicates if the file has just been added
19
+ # @attr [String] new_path New path of the file
20
+ # @attr [Boolean] renamed_file Indicates if the file has been renamed
21
+ class MergeRequestDiffs < SupportOps::GitLab::Base
22
+ define_attributes :a_mode, :b_mode, :deleted_file, :diff, :generated_file,
23
+ :old_path, :new_file, :new_path, :renamed_file
24
+ readonly_attributes :a_mode, :b_mode, :deleted_file, :diff,
25
+ :generated_file, :old_path, :new_file, :new_path,
26
+ :renamed_file
27
+
28
+ private
29
+ end
30
+ end
31
+ end
@@ -127,6 +127,31 @@ module SupportOps
127
127
  # # pp notes.count
128
128
  # # # => 7
129
129
  # def notes; end
130
+ # @!parse
131
+ # # List diffs on a merge request
132
+ # #
133
+ # # @author Jason Colyer
134
+ # # @since 1.2.0
135
+ # # @return [Boolean]
136
+ # # @note This is inherited from {SupportOps::GitLab::Base#diffs}
137
+ # # @see
138
+ # # https://docs.gitlab.com/api/merge_requests/#list-merge-request-diffs
139
+ # # GitLab API > Merge requests > List merge request diffs
140
+ # # @example
141
+ # # require 'support_ops_gitlab'
142
+ # #
143
+ # # SupportOps::GitLab::Configuration.configure do |config|
144
+ # # config.token = ENV.fetch('GL_TOKEN')
145
+ # # config.url = 'https://gitlab.com/api/v4'
146
+ # # end
147
+ # #
148
+ # # existing_mr = SupportOps::GitLab::MergeRequests.get(iid: 28, project_id: 123456)
149
+ # # diffs = existing_mr.diffs
150
+ # # pp diffs.count
151
+ # # # => 3
152
+ # # pp diffs.first.diff
153
+ # # # => "@@ -17,10 +17,11..."
154
+ # def diffs; end
130
155
  define_attributes :allow_collaboration, :allow_maintainer_to_push,
131
156
  :assignee, :assignees, :author, :closed_at, :closed_by,
132
157
  :created_at, :description, :detailed_merge_status,
@@ -406,6 +431,22 @@ module SupportOps
406
431
  def notes_record
407
432
  Notes.list(type: 'MergeRequest', type_id: self.iid, project_id: self.project_id)
408
433
  end
434
+
435
+ ##
436
+ # @private
437
+ def diffs_record
438
+ array = []
439
+ page = 1
440
+ loop do
441
+ url = "projects/#{self.project_id}/merge_requests/#{self.iid}/diffs?per_page=100&page=#{page}"
442
+ response = self.client.connection.get(url)
443
+ body = Oj.load(response.body)
444
+ array += body.map { |d| MergeRequestDiffs.new(d) }
445
+ break if body.count < 100
446
+ page += 1
447
+ end
448
+ array
449
+ end
409
450
  end
410
451
  end
411
452
  end
@@ -24,6 +24,7 @@ module SupportOps
24
24
  require "#{__dir__}/gitlab/issues"
25
25
  require "#{__dir__}/gitlab/jobs"
26
26
  require "#{__dir__}/gitlab/markdown"
27
+ require "#{__dir__}/gitlab/merge_request_diffs"
27
28
  require "#{__dir__}/gitlab/merge_requests"
28
29
  require "#{__dir__}/gitlab/milestones"
29
30
  require "#{__dir__}/gitlab/namespaces"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-customer-support-operations_gitlab
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Colyer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-07-09 00:00:00.000000000 Z
11
+ date: 2025-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -206,6 +206,7 @@ files:
206
206
  - lib/support_ops_gitlab/gitlab/issues.rb
207
207
  - lib/support_ops_gitlab/gitlab/jobs.rb
208
208
  - lib/support_ops_gitlab/gitlab/markdown.rb
209
+ - lib/support_ops_gitlab/gitlab/merge_request_diffs.rb
209
210
  - lib/support_ops_gitlab/gitlab/merge_requests.rb
210
211
  - lib/support_ops_gitlab/gitlab/milestones.rb
211
212
  - lib/support_ops_gitlab/gitlab/namespaces.rb