Class: Gemstar::Commands::Diff
- Defined in:
- lib/gemstar/commands/diff.rb
Instance Attribute Summary collapse
-
#considered_commits ⇒ Object
readonly
Returns the value of attribute considered_commits.
-
#ecosystem ⇒ Object
readonly
Returns the value of attribute ecosystem.
-
#failed ⇒ Object
readonly
Returns the value of attribute failed.
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#git_repo ⇒ Object
readonly
Returns the value of attribute git_repo.
-
#lockfile ⇒ Object
readonly
Returns the value of attribute lockfile.
-
#lockfile_full_path ⇒ Object
readonly
Returns the value of attribute lockfile_full_path.
-
#output_file ⇒ Object
readonly
Returns the value of attribute output_file.
-
#output_format ⇒ Object
readonly
Returns the value of attribute output_format.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#since ⇒ Object
readonly
Returns the value of attribute since.
-
#since_cutoff_commit ⇒ Object
readonly
Returns the value of attribute since_cutoff_commit.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
-
#updates ⇒ Object
readonly
Returns the value of attribute updates.
Instance Method Summary collapse
- #format_commit(commit, fallback_revision:) ⇒ Object
-
#initialize(options) ⇒ Diff
constructor
A new instance of Diff.
- #project_name ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(options) ⇒ Diff
Returns a new instance of Diff.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/gemstar/commands/diff.rb', line 27 def initialize() super @debug_gem_regex = Regexp.new([:debug_gem_regex] || ENV["GEMSTAR_DEBUG_GEM_REGEX"] || ".*") @since = normalize_since([:since]) @from = [:from] || "HEAD" @to = [:to] @lockfile = [:lockfile] || "Gemfile.lock" @output_format = normalize_output_format([:format] || [:output_format]) @output_file = [:output_file] || default_output_file @project = [:project] ? Gemstar::Project.from_cli_argument([:project]) : nil @ecosystem = normalize_ecosystem([:ecosystem]) @considered_commits = [] @since_cutoff_commit = nil @git_repo = project ? project.git_repo : Gemstar::GitRepo.new(File.dirname(@lockfile)) @from = resolve_since_commit if since end |
Instance Attribute Details
#considered_commits ⇒ Object (readonly)
Returns the value of attribute considered_commits.
24 25 26 |
# File 'lib/gemstar/commands/diff.rb', line 24 def considered_commits @considered_commits end |
#ecosystem ⇒ Object (readonly)
Returns the value of attribute ecosystem.
22 23 24 |
# File 'lib/gemstar/commands/diff.rb', line 22 def ecosystem @ecosystem end |
#failed ⇒ Object (readonly)
Returns the value of attribute failed.
13 14 15 |
# File 'lib/gemstar/commands/diff.rb', line 13 def failed @failed end |
#from ⇒ Object (readonly)
Returns the value of attribute from.
14 15 16 |
# File 'lib/gemstar/commands/diff.rb', line 14 def from @from end |
#git_repo ⇒ Object (readonly)
Returns the value of attribute git_repo.
17 18 19 |
# File 'lib/gemstar/commands/diff.rb', line 17 def git_repo @git_repo end |
#lockfile ⇒ Object (readonly)
Returns the value of attribute lockfile.
16 17 18 |
# File 'lib/gemstar/commands/diff.rb', line 16 def lockfile @lockfile end |
#lockfile_full_path ⇒ Object (readonly)
Returns the value of attribute lockfile_full_path.
18 19 20 |
# File 'lib/gemstar/commands/diff.rb', line 18 def lockfile_full_path @lockfile_full_path end |
#output_file ⇒ Object (readonly)
Returns the value of attribute output_file.
19 20 21 |
# File 'lib/gemstar/commands/diff.rb', line 19 def output_file @output_file end |
#output_format ⇒ Object (readonly)
Returns the value of attribute output_format.
20 21 22 |
# File 'lib/gemstar/commands/diff.rb', line 20 def output_format @output_format end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
21 22 23 |
# File 'lib/gemstar/commands/diff.rb', line 21 def project @project end |
#since ⇒ Object (readonly)
Returns the value of attribute since.
23 24 25 |
# File 'lib/gemstar/commands/diff.rb', line 23 def since @since end |
#since_cutoff_commit ⇒ Object (readonly)
Returns the value of attribute since_cutoff_commit.
25 26 27 |
# File 'lib/gemstar/commands/diff.rb', line 25 def since_cutoff_commit @since_cutoff_commit end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
15 16 17 |
# File 'lib/gemstar/commands/diff.rb', line 15 def to @to end |
#updates ⇒ Object (readonly)
Returns the value of attribute updates.
12 13 14 |
# File 'lib/gemstar/commands/diff.rb', line 12 def updates @updates end |
Instance Method Details
#format_commit(commit, fallback_revision:) ⇒ Object
126 127 128 129 130 131 132 |
# File 'lib/gemstar/commands/diff.rb', line 126 def format_commit(commit, fallback_revision:) return fallback_revision.to_s if commit.nil? date = commit[:authored_at].to_s.split("T").first label = [commit[:short_sha] || commit[:id], commit[:subject]].compact.join(" ") date.empty? ? label : "#{label} (#{date})" end |
#project_name ⇒ Object
142 143 144 145 146 |
# File 'lib/gemstar/commands/diff.rb', line 142 def project_name return project.name if project Pathname.getwd.basename.to_s end |
#run ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/gemstar/commands/diff.rb', line 47 def run project ? run_project_diff : run_lockfile_diff @considered_commits = collect_considered_commits rendered_output = output_renderer.render_diff(self) File.write(output_file, rendered_output) puts "✅ Changelog report created: #{output_file_url}" if failed.any? puts "\n⚠️ The following gems failed to process:" failed.each { |gem, msg| puts " - #{gem}: #{msg}" } end end |