Class: SugarJar::Commands

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/sugarjar/commands.rb

Overview

This is the workhorse of SugarJar. Short of #initialize, all other public methods are “commands”. Anything in private is internal implementation details.

Constant Summary collapse

MAIN_BRANCHES =
%w{master main}.freeze

Instance Method Summary collapse

Methods included from Util

#all_local_branches, #all_remote_branches, #all_remotes, #assert_common_main_branch, #assert_in_repo, #branch_from_ref, #canonicalize_repo, #checkout_main_branch, #color, #current_branch, #determine_main_branch, #die, #dirty?, #extract_org, #extract_repo, #fetch, #fetch_upstream, #forked_repo, #fprefix, #gh_avail?, #ghcli, #ghcli_nofail, #git, #git_nofail, #in_repo, #main_branch, #main_remote_branch, #most_main, #pastel, #push_org, #repo_name, #repo_root, #run_prepush, #set_commit_template, #subfeature?, #tracked_branch, #upstream, #which, #which_nofail

Constructor Details

#initialize(options) ⇒ Commands

Returns a new instance of Commands.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/sugarjar/commands.rb', line 26

def initialize(options)
  SugarJar::Log.debug("Commands.initialize options: #{options}")
  @ignore_dirty = options['ignore_dirty']
  @ignore_prerun_failure = options['ignore_prerun_failure']
  @repo_config = SugarJar::RepoConfig.config
  SugarJar::Log.debug("Repoconfig: #{@repo_config}")
  @color = options['color']
  @pr_autofill = options['pr_autofill']
  @pr_autostack = options['pr_autostack']
  @feature_prefix = options['feature_prefix']
  @checks = {}
  @main_branch = nil
  @main_remote_branches = {}
  @ghuser = @repo_config['github_user'] || options['github_user']
  @ghhost = @repo_config['github_host'] || options['github_host']

  die("No 'gh' found, please install 'gh'") unless gh_avail?

  # Tell the 'gh' cli where to talk to, if not github.com
  ENV['GH_HOST'] = @ghhost if @ghhost

  return if options['no_change']

  set_commit_template if @repo_config['commit_template']
end