Class: Entitlements::Auditor::GitRepo
- Inherits:
-
Base
- Object
- Base
- Entitlements::Auditor::GitRepo
- Includes:
- Contracts::Core
- Defined in:
- lib/entitlements/auditor/gitrepo.rb
Constant Summary collapse
- C =
::Contracts
Instance Method Summary collapse
Instance Method Details
#commit(actions:, successful_actions:, provider_exception:) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/entitlements/auditor/gitrepo.rb', line 50 def commit(actions:, successful_actions:, provider_exception:) raise "Must run setup method before running commit method" unless @repo sync_changes = {} valid_changes = {} commitable_actions = actions_with_membership_change(actions) action_hash = commitable_actions.map { |action| [action.dn, action] }.to_h %w[update_files delete_files].each do |m| send( m.to_sym, action_hash:, successful_actions:, sync_changes:, valid_changes: ) end # If there is anything out-of-sync and the provider did not throw an exception, create # a special sync commit to update things. if sync_changes.any? if provider_exception logger.warn "Not committing #{sync_changes.size} unrecognized change(s) due to provider exception" else logger.warn "Sync changes required: count=#{sync_changes.size}" commit_changes(sync_changes, :sync, ) end end # If there are any valid changes, create a commit to update things. if valid_changes.any? logger.debug "Committing #{valid_changes.size} change(s) to git repository" commit_changes(valid_changes, :valid, ) elsif sync_changes.empty? logger.debug "No changes to git repository" end end |
#setup ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/entitlements/auditor/gitrepo.rb', line 21 def setup operation = File.directory?(checkout_directory) ? :pull : :clone logger.debug "Preparing #{checkout_directory}" @repo = Entitlements::Util::GitRepo.new( repo: config["repo"], sshkey: Base64.decode64(config["sshkey"]), logger: ) @repo.github = config["github_override"] if config["github_override"] @repo.send(operation, checkout_directory) @repo.configure(checkout_directory, config["git_name"], config["git_email"]) logger.debug "Directory #{checkout_directory} prepared" end |