class DependencyUpdater::GitlabHandler
Attributes
gitlab[RW]
Public Class Methods
new()
click to toggle source
# File lib/dependency_updater/handlers/gitlab_handler.rb, line 11 def initialize config = DependencyUpdater.configuration @project_id = config.project_id @production_branch = config.production_branch @target_branch = config.merge_target_branch @new_branch = nil @mr = nil @messenger = Messengers::GitlabMessenger.new @gitlab = Gitlab.client @today = Time.zone.today end
Public Instance Methods
backout()
click to toggle source
# File lib/dependency_updater/handlers/gitlab_handler.rb, line 54 def backout @gitlab.delete_branch(@project_id, @new_branch) @messenger.backing_out(@new_branch) end
build_commit_action(filepath, content)
click to toggle source
# File lib/dependency_updater/handlers/gitlab_handler.rb, line 29 def build_commit_action(filepath, content) { action: 'update', file_path: filepath, content: content } end
commit(message, actions)
click to toggle source
# File lib/dependency_updater/handlers/gitlab_handler.rb, line 37 def commit(message, actions) signed_msg = "#{message} -- using Dependency Updater'" @gitlab.create_commit(@project_id, @new_branch, signed_msg, actions) @messenger.commit(signed_msg) end
create_mr()
click to toggle source
# File lib/dependency_updater/handlers/gitlab_handler.rb, line 43 def create_mr title = "WIP: Dependency Update, #{@today}" @mr = @gitlab.create_merge_request(@project_id, title, { source_branch: @new_branch, target_branch: @target_branch, description: 'Dependency Updater has updated the gems and/or ruby version declarations.', remove_source_branch: true }) @messenger.new_mr(@mr.title, @mr.web_url) end
new_branch()
click to toggle source
# File lib/dependency_updater/handlers/gitlab_handler.rb, line 23 def new_branch @new_branch = unique_branch_name @gitlab.create_branch(@project_id, @new_branch, @production_branch) @messenger.new_branch(@new_branch) end
Private Instance Methods
unique_branch_name()
click to toggle source
# File lib/dependency_updater/handlers/gitlab_handler.rb, line 61 def unique_branch_name updater_branches = @gitlab.branches(@project_id, { search: '^dependency-update' }).map(&:name) highest_id = updater_branches.map { |b| b.slice(/\/update-(\d+)/, 1).to_i }.max highest_id = 0 if highest_id.nil? "dependency-update/#{@today}/update-#{highest_id + 1}" end