Class: RollbackUpgrade

Inherits:
Object
  • Object
show all
Defined in:
lib/rollback.rb

Constant Summary collapse

DATE_FORMAT =
'date_%m-%d-%Y_time_%H.%M.%S'

Instance Method Summary collapse

Constructor Details

#initialize(repo_url, remote, current_branch, rollback_branch, metadata) ⇒ RollbackUpgrade

Returns a new instance of RollbackUpgrade.



23
24
25
26
27
28
29
# File 'lib/rollback.rb', line 23

def initialize repo_url, remote, current_branch, rollback_branch, 
  @repo_url = repo_url
  @remote = remote
  @current_branch = current_branch
  @rollback_branch = rollback_branch
  @metadata = 
end

Instance Method Details

#create_rollback_tagObject



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/rollback.rb', line 31

def create_rollback_tag
  versioning = SemverVersioning.new
  semver_file = @config_map..semver.file
  if @config_map..should_publish_nuget && semver_file != nil && semver_file != GlobalConstants::EMPTY
    semver_file.capitalize
    ver_tag = versioning.get_current_version @config_map..semver.location, semver_file
    return "rollback-#{ver_tag}"
  else
    utc_now = DateTime.now.utc
    date_tag = utc_now.strftime(DATE_FORMAT) 
    return "rollback-#{date_tag}"
  end
end

#DoObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/rollback.rb', line 45

def Do
  commit_hashes = GithubApi.BranchCommitDiff(@rollback_branch, @current_branch)
  if commit_hashes.length == 0
    puts `No difference between branches #{current_branch} and #{rollback_branch}, aborting rollback.`
    return false
  end

  # check hashes for version upgrade commit message
  if !commit_hashes.any?{ |c_hash| GithubApi.ShowCommitInfoLocal(c_hash).include? Upgrade::VERSION_UPGRADE_COMMIT }
    puts `No version upgrade commit detected to roll back, aborting rollback.`
    return false
  end

  GithubApi.RevertLocal(@current_branch, commit_hashes)

  puts `@<--- Rollback branch revert completed. @<---`
  return true
end