module Upshop::Differ
Constants
- DifferResult
- ERROR_STATUS
- OK_STATUS
Public Class Methods
get_delta()
click to toggle source
# File lib/upshop/differ.rb, line 11 def get_delta @result = DifferResult.new begin discover_repository get_last_deployed_commit determine_diff rescue DifferError => e @result.status = ERROR_STATUS @result.message = e.message end @result end
Private Class Methods
determine_diff()
click to toggle source
# File lib/upshop/differ.rb, line 56 def determine_diff head = @repo.head.target last_deploy = @repo.lookup(@commit) diff = last_deploy.diff(head) deltas = diff.deltas.map do |delta| { path: delta.new_file[:path], status: delta.status } end @result.status = OK_STATUS @result.deltas = deltas end
discover_repository()
click to toggle source
# File lib/upshop/differ.rb, line 31 def discover_repository begin @repo = Rugged::Repository.new("./") rescue Rugged::RepositoryError raise DifferError, "Unable to find git repository in current folder" end end
extract_last_deployed_commit_from(file)
click to toggle source
# File lib/upshop/differ.rb, line 47 def extract_last_deployed_commit_from(file) begin @commit = file[:deploys][0].fetch(:commit) raise(DifferError) unless @repo.exists?(@commit) rescue KeyError, NoMethodError, TypeError, DifferError raise DifferError, "No valid last deployed commit found in deploy_file" end end
get_deploy_file()
click to toggle source
# File lib/upshop/differ.rb, line 39 def get_deploy_file begin YAML.load_file("deploy_file.yml") rescue Errno::ENOENT raise DifferError, "Unable to find deploy_file" end end
get_last_deployed_commit()
click to toggle source
# File lib/upshop/differ.rb, line 26 def get_last_deployed_commit deploy_file = get_deploy_file extract_last_deployed_commit_from deploy_file end