diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-02 00:12:08 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-02 00:12:08 +0300 |
commit | d170c7eeef81debb74afa518c256358ccb7e231c (patch) | |
tree | dc4adba24cead9505703600189bbba712f442661 /scripts/api | |
parent | 3bfb19d99e3508b2a42c49d09e5a3236d2ce3a29 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'scripts/api')
-rw-r--r-- | scripts/api/commit_merge_requests.rb | 29 |
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 |