Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-02-02 00:12:08 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-02-02 00:12:08 +0300
commitd170c7eeef81debb74afa518c256358ccb7e231c (patch)
treedc4adba24cead9505703600189bbba712f442661 /scripts/api
parent3bfb19d99e3508b2a42c49d09e5a3236d2ce3a29 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'scripts/api')
-rw-r--r--scripts/api/commit_merge_requests.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/scripts/api/commit_merge_requests.rb b/scripts/api/commit_merge_requests.rb
new file mode 100644
index 00000000000..3cf8dc87497
--- /dev/null
+++ b/scripts/api/commit_merge_requests.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+require 'gitlab'
+require_relative 'default_options'
+
+class CommitMergeRequests
+ def initialize(options)
+ @project = options.fetch(:project)
+ @sha = options.fetch(:sha)
+
+ # If api_token is nil, it's set to '' to allow unauthenticated requests (for forks).
+ api_token = options.fetch(:api_token, '')
+
+ warn "No API token given." if api_token.empty?
+
+ @client = Gitlab.client(
+ endpoint: options.fetch(:endpoint, API::DEFAULT_OPTIONS[:endpoint]),
+ private_token: api_token
+ )
+ end
+
+ def execute
+ client.commit_merge_requests(project, sha)
+ end
+
+ private
+
+ attr_reader :project, :sha, :client
+end