debian-mirror-gitlab/tooling/bin/find_changes

22 lines
617 B
Text
Raw Normal View History

2021-11-11 11:23:49 +05:30
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'gitlab'
2021-12-11 22:18:48 +05:30
gitlab_token = ENV.fetch('PROJECT_TOKEN_FOR_CI_SCRIPTS_API_USAGE', '')
2021-11-11 11:23:49 +05:30
gitlab_endpoint = ENV.fetch('CI_API_V4_URL')
mr_project_path = ENV.fetch('CI_MERGE_REQUEST_PROJECT_PATH')
mr_iid = ENV.fetch('CI_MERGE_REQUEST_IID')
output_file = ARGV.shift
Gitlab.configure do |config|
config.endpoint = gitlab_endpoint
config.private_token = gitlab_token
end
mr_changes = Gitlab.merge_request_changes(mr_project_path, mr_iid)
file_changes = mr_changes.changes.map { |change| change['new_path'] }
File.write(output_file, file_changes.join(' '))