gem_hadar 2.13.1 → 2.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/gem_hadar.gemspec +4 -4
- data/lib/gem_hadar/changelog_config.rb +52 -0
- data/lib/gem_hadar/changelog_generator.rb +13 -8
- data/lib/gem_hadar/editor.rb +85 -0
- data/lib/gem_hadar/template_compiler.rb +15 -3
- data/lib/gem_hadar/version.rb +1 -1
- data/lib/gem_hadar.rb +64 -54
- metadata +5 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c1526fc633cc4869edfeebe3b9b80abc73737c70484fef234517076870b8a809
|
|
4
|
+
data.tar.gz: 5cc2ad8d79884970d57130c2f7bb43a9d9d681834ff7bec707effb74a03f73b7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1fce02764c683dab0b0a96294d9050868f20edcdb0c5843aa91b500f2d09e9866c4f4c945bbacbee59eb8502a67092e578f3eb118f346b938ad1a0bbfa9c062a
|
|
7
|
+
data.tar.gz: 1398928830339c43d4005e53d2629cb7ed90ca46b34ee3e2dede5e06be41a54b215e14919de22d2772c7266ec7a3692223817a50acfb1b37b70902390b2bcc59
|
data/README.md
CHANGED
|
@@ -470,8 +470,11 @@ $ rake -T
|
|
|
470
470
|
- `rake changes:current` - Show changes between two latest version tags
|
|
471
471
|
- `rake changes:range` - Show changes for a specific Git range (e.g., v1.0.0..v1.2.0)
|
|
472
472
|
- `rake changes:full` - Generate complete changelog from first tag
|
|
473
|
-
- `rake changes:add` - Append to
|
|
473
|
+
- `rake changes:add` - Append to changelog file
|
|
474
|
+
- `rake changes:edit` - Edit changelog file
|
|
474
475
|
- `rake changes:added` - Check if current version was added to changelog
|
|
476
|
+
- `rake changes:commit` - Commit changes to changelog file
|
|
477
|
+
- `rake changes:update` - Add and commit changes to changelog file
|
|
475
478
|
|
|
476
479
|
### Documentation
|
|
477
480
|
|
data/gem_hadar.gemspec
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
|
-
# stub: gem_hadar 2.
|
|
2
|
+
# stub: gem_hadar 2.14.0 ruby lib
|
|
3
3
|
|
|
4
4
|
Gem::Specification.new do |s|
|
|
5
5
|
s.name = "gem_hadar".freeze
|
|
6
|
-
s.version = "2.
|
|
6
|
+
s.version = "2.14.0".freeze
|
|
7
7
|
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
|
9
9
|
s.require_paths = ["lib".freeze]
|
|
@@ -12,8 +12,8 @@ Gem::Specification.new do |s|
|
|
|
12
12
|
s.description = "This library contains some useful functionality to support the development of Ruby Gems".freeze
|
|
13
13
|
s.email = "flori@ping.de".freeze
|
|
14
14
|
s.executables = ["gem_hadar".freeze]
|
|
15
|
-
s.extra_rdoc_files = ["README.md".freeze, "lib/gem_hadar.rb".freeze, "lib/gem_hadar/changelog_generator.rb".freeze, "lib/gem_hadar/github.rb".freeze, "lib/gem_hadar/ollama_support.rb".freeze, "lib/gem_hadar/prompt_template.rb".freeze, "lib/gem_hadar/rvm_config.rb".freeze, "lib/gem_hadar/setup.rb".freeze, "lib/gem_hadar/simplecov.rb".freeze, "lib/gem_hadar/template_compiler.rb".freeze, "lib/gem_hadar/utils.rb".freeze, "lib/gem_hadar/version.rb".freeze, "lib/gem_hadar/version_spec.rb".freeze, "lib/gem_hadar/warn.rb".freeze]
|
|
16
|
-
s.files = [".all_images.yml".freeze, ".github/workflows/static.yml".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "bin/gem_hadar".freeze, "gem_hadar.gemspec".freeze, "lib/gem_hadar.rb".freeze, "lib/gem_hadar/changelog_generator.rb".freeze, "lib/gem_hadar/github.rb".freeze, "lib/gem_hadar/github_workflows/static.yml.erb".freeze, "lib/gem_hadar/ollama_support.rb".freeze, "lib/gem_hadar/prompt_template.rb".freeze, "lib/gem_hadar/rvm_config.rb".freeze, "lib/gem_hadar/setup.rb".freeze, "lib/gem_hadar/simplecov.rb".freeze, "lib/gem_hadar/template_compiler.rb".freeze, "lib/gem_hadar/utils.rb".freeze, "lib/gem_hadar/version.rb".freeze, "lib/gem_hadar/version_spec.rb".freeze, "lib/gem_hadar/warn.rb".freeze, "spec/gem_hadar_spec.rb".freeze, "spec/spec_helper.rb".freeze]
|
|
15
|
+
s.extra_rdoc_files = ["README.md".freeze, "lib/gem_hadar.rb".freeze, "lib/gem_hadar/changelog_config.rb".freeze, "lib/gem_hadar/changelog_generator.rb".freeze, "lib/gem_hadar/editor.rb".freeze, "lib/gem_hadar/github.rb".freeze, "lib/gem_hadar/ollama_support.rb".freeze, "lib/gem_hadar/prompt_template.rb".freeze, "lib/gem_hadar/rvm_config.rb".freeze, "lib/gem_hadar/setup.rb".freeze, "lib/gem_hadar/simplecov.rb".freeze, "lib/gem_hadar/template_compiler.rb".freeze, "lib/gem_hadar/utils.rb".freeze, "lib/gem_hadar/version.rb".freeze, "lib/gem_hadar/version_spec.rb".freeze, "lib/gem_hadar/warn.rb".freeze]
|
|
16
|
+
s.files = [".all_images.yml".freeze, ".github/workflows/static.yml".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "bin/gem_hadar".freeze, "gem_hadar.gemspec".freeze, "lib/gem_hadar.rb".freeze, "lib/gem_hadar/changelog_config.rb".freeze, "lib/gem_hadar/changelog_generator.rb".freeze, "lib/gem_hadar/editor.rb".freeze, "lib/gem_hadar/github.rb".freeze, "lib/gem_hadar/github_workflows/static.yml.erb".freeze, "lib/gem_hadar/ollama_support.rb".freeze, "lib/gem_hadar/prompt_template.rb".freeze, "lib/gem_hadar/rvm_config.rb".freeze, "lib/gem_hadar/setup.rb".freeze, "lib/gem_hadar/simplecov.rb".freeze, "lib/gem_hadar/template_compiler.rb".freeze, "lib/gem_hadar/utils.rb".freeze, "lib/gem_hadar/version.rb".freeze, "lib/gem_hadar/version_spec.rb".freeze, "lib/gem_hadar/warn.rb".freeze, "spec/gem_hadar_spec.rb".freeze, "spec/spec_helper.rb".freeze]
|
|
17
17
|
s.homepage = "https://github.com/flori/gem_hadar".freeze
|
|
18
18
|
s.licenses = ["MIT".freeze]
|
|
19
19
|
s.rdoc_options = ["--title".freeze, "GemHadar - Library for the development of Ruby Gems".freeze, "--main".freeze, "README.md".freeze]
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# A class that encapsulates changelog configuration settings for a gem project.
|
|
2
|
+
#
|
|
3
|
+
# This class provides a structured way to define and manage settings related to
|
|
4
|
+
# changelog generation within the GemHadar framework. It allows configuration
|
|
5
|
+
# of the changelog filename and the commit message used when adding entries.
|
|
6
|
+
#
|
|
7
|
+
# @example Configuring changelog settings
|
|
8
|
+
# GemHadar do
|
|
9
|
+
# changelog do
|
|
10
|
+
# filename 'CHANGELOG.md'
|
|
11
|
+
# commit_message 'Update changelog'
|
|
12
|
+
# end
|
|
13
|
+
# end
|
|
14
|
+
class GemHadar::ChangelogConfig
|
|
15
|
+
extend DSLKit::DSLAccessor
|
|
16
|
+
|
|
17
|
+
# This method creates a new instance of the ChangelogConfig class and then
|
|
18
|
+
# evaluates the provided block in the context of the new instance to
|
|
19
|
+
# configure the changelog settings.
|
|
20
|
+
#
|
|
21
|
+
# @param block [Proc] the block to be evaluated for configuring the changelog
|
|
22
|
+
# settings
|
|
23
|
+
#
|
|
24
|
+
# @return [GemHadar::ChangelogConfig] the initialized ChangelogConfig
|
|
25
|
+
# instance
|
|
26
|
+
def initialize(&block)
|
|
27
|
+
instance_eval(&block)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# The filename attribute accessor for configuring the changelog filename.
|
|
31
|
+
#
|
|
32
|
+
# This method sets up a DSL accessor for the filename attribute, which specifies
|
|
33
|
+
# the name of the changelog file to be used when generating or modifying
|
|
34
|
+
# changelog entries. It provides a way to define the location of the changelog
|
|
35
|
+
# file that will be processed during various changelog operations within the
|
|
36
|
+
# gem project.
|
|
37
|
+
#
|
|
38
|
+
# @return [ String, nil ] the name of the changelog file or nil if not set
|
|
39
|
+
dsl_accessor :filename
|
|
40
|
+
|
|
41
|
+
# The commit_message method retrieves or sets the Git commit message used
|
|
42
|
+
# when adding changelog entries.
|
|
43
|
+
#
|
|
44
|
+
# This method serves as an accessor for the commit_message attribute within
|
|
45
|
+
# the ChangelogConfig class. When called without arguments, it returns the
|
|
46
|
+
# configured commit message, which defaults to 'Add to changes'. When called
|
|
47
|
+
# with an argument, it sets the commit message to be used for Git operations
|
|
48
|
+
# related to changelog management.
|
|
49
|
+
#
|
|
50
|
+
# @return [ String ] the default commit message 'Add to changes' when no custom message is set
|
|
51
|
+
dsl_accessor :commit_message, 'Add to changes'
|
|
52
|
+
end
|
|
@@ -146,10 +146,15 @@ class GemHadar
|
|
|
146
146
|
# changelog file, retrieves all subsequent version tags from the Git
|
|
147
147
|
# repository, and generates changelog entries for each consecutive pair of
|
|
148
148
|
# versions. It then inserts these entries into the file after the existing
|
|
149
|
-
# content, maintaining the
|
|
149
|
+
# content, maintaining the
|
|
150
|
+
# chronological order of changes.
|
|
150
151
|
#
|
|
151
|
-
# @param filename [ String ] the path to the changelog file to which
|
|
152
|
-
#
|
|
152
|
+
# @param filename [ String ] the path to the changelog file to which entries will be added
|
|
153
|
+
#
|
|
154
|
+
# @return [ Integer ] the count of changelog entries inserted into the file
|
|
155
|
+
# @return [ nil ] if no entries were added or if the file was empty
|
|
156
|
+
#
|
|
157
|
+
# @raise [ ArgumentError ] if the changelog file does not exist or if no highest version is found
|
|
153
158
|
def add_to_file(filename)
|
|
154
159
|
highest_version = find_highest_version(filename)
|
|
155
160
|
|
|
@@ -269,6 +274,7 @@ class GemHadar
|
|
|
269
274
|
changelog << generate(range_from, range_to)
|
|
270
275
|
+infobar
|
|
271
276
|
end
|
|
277
|
+
infobar.newline
|
|
272
278
|
changelog.reverse
|
|
273
279
|
end
|
|
274
280
|
|
|
@@ -280,12 +286,10 @@ class GemHadar
|
|
|
280
286
|
# the provided changelog entries immediately after the header
|
|
281
287
|
# and before the next empty line.
|
|
282
288
|
#
|
|
283
|
-
# @param filename [ String ] the path to the file into which changelog
|
|
284
|
-
#
|
|
285
|
-
# @param changelog [ Array<String> ] an array of changelog entry strings to
|
|
286
|
-
# be inserted into the file
|
|
289
|
+
# @param filename [ String ] the path to the file into which changelog entries will be injected
|
|
290
|
+
# @param changelog [ Array<String> ] an array of changelog entry strings to be inserted into the file
|
|
287
291
|
#
|
|
288
|
-
# @
|
|
292
|
+
# @return [ Integer ] the count of changelog entries inserted into the file
|
|
289
293
|
def inject_into_filename(filename, changelog)
|
|
290
294
|
File.open(filename) do |input|
|
|
291
295
|
File.secure_write(filename) do |output|
|
|
@@ -308,6 +312,7 @@ class GemHadar
|
|
|
308
312
|
end
|
|
309
313
|
end
|
|
310
314
|
end
|
|
315
|
+
changelog.size
|
|
311
316
|
end
|
|
312
317
|
|
|
313
318
|
# The find_highest_version method extracts version specifications from
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# A module that provides editor integration functionality for GemHadar.
|
|
2
|
+
#
|
|
3
|
+
# This module contains methods for determining the appropriate editor to use
|
|
4
|
+
# for interactive tasks, opening temporary files in editors for user modification,
|
|
5
|
+
# and editing specified files in an editor. It serves as a utility for
|
|
6
|
+
# automating text editing operations within the GemHadar framework.
|
|
7
|
+
#
|
|
8
|
+
# @example Finding and using an editor
|
|
9
|
+
# editor = GemHadar::Editor.find_editor
|
|
10
|
+
#
|
|
11
|
+
# @example Editing a temporary file returning the changed content
|
|
12
|
+
# content = "Initial content"
|
|
13
|
+
# edited_content = GemHadar::Editor.edit_temp_file(content)
|
|
14
|
+
#
|
|
15
|
+
# @example Editing a specific file
|
|
16
|
+
# GemHadar::Editor.edit_file('CHANGELOG.md')
|
|
17
|
+
module GemHadar::Editor
|
|
18
|
+
# The find_editor method determines the appropriate editor to use for
|
|
19
|
+
# interactive tasks.
|
|
20
|
+
#
|
|
21
|
+
# This method first checks the EDITOR environment variable for a custom
|
|
22
|
+
# editor specification. If the environment variable is not set, it falls back
|
|
23
|
+
# to using the vi editor by default. It then verifies that the identified
|
|
24
|
+
# editor exists in the file system before returning it.
|
|
25
|
+
#
|
|
26
|
+
# @return [ String, nil ] the path to the editor command if found, or nil if
|
|
27
|
+
# the editor cannot be located
|
|
28
|
+
# @return [ nil ] if the editor cannot be found in the file system
|
|
29
|
+
def find_editor
|
|
30
|
+
editor = ENV.fetch('EDITOR', `which vi`.chomp)
|
|
31
|
+
unless File.exist?(editor)
|
|
32
|
+
warn "Can't find EDITOR. => Returning."
|
|
33
|
+
return
|
|
34
|
+
end
|
|
35
|
+
editor
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# The edit_temp_file method opens a temporary file in an editor for user
|
|
39
|
+
# modification.
|
|
40
|
+
#
|
|
41
|
+
# This method creates a temporary markdown file with the provided content,
|
|
42
|
+
# opens it in the configured editor, waits for the user to finish editing,
|
|
43
|
+
# and then reads the modified content back from the file.
|
|
44
|
+
#
|
|
45
|
+
# @param content [ String ] the initial content to write to the temporary file
|
|
46
|
+
#
|
|
47
|
+
# @return [ String ] the content of the file after editing, or nil if the editor
|
|
48
|
+
# could not be invoked or the file could not be read
|
|
49
|
+
# @return [ nil ] if the editor could not be found or the operation was aborted
|
|
50
|
+
def edit_temp_file(content)
|
|
51
|
+
temp_file = Tempfile.new(%w[ changelog .md ])
|
|
52
|
+
temp_file.write(content)
|
|
53
|
+
temp_file.close
|
|
54
|
+
|
|
55
|
+
edit_file(temp_file.path) or return
|
|
56
|
+
|
|
57
|
+
File.read(temp_file.path)
|
|
58
|
+
ensure
|
|
59
|
+
temp_file&.close&.unlink
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# The edit_file method opens a specified file in an editor for user
|
|
63
|
+
# modification.
|
|
64
|
+
#
|
|
65
|
+
# This method retrieves the configured editor using find_editor, then invokes
|
|
66
|
+
# the editor command with the provided filename as an argument. It waits for
|
|
67
|
+
# the editor process to complete and returns true if successful, or false if
|
|
68
|
+
# the editor command fails.
|
|
69
|
+
#
|
|
70
|
+
# @param filename [ String ] the path to the file to be opened in the editor
|
|
71
|
+
#
|
|
72
|
+
# @return [ true ] if the editor command executes successfully
|
|
73
|
+
# @return [ false ] if the editor command fails or returns a non-zero exit status
|
|
74
|
+
# @return [ nil ] if the editor cannot be found or the operation is aborted
|
|
75
|
+
def edit_file(filename)
|
|
76
|
+
editor = find_editor or return
|
|
77
|
+
|
|
78
|
+
unless system("#{editor} #{filename}")
|
|
79
|
+
warn "#{editor} returned #{$?.exitstatus} => Returning."
|
|
80
|
+
return false
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
true
|
|
84
|
+
end
|
|
85
|
+
end
|
|
@@ -9,11 +9,23 @@ require 'erb'
|
|
|
9
9
|
# context, and writing the resulting content to specified destination files.
|
|
10
10
|
#
|
|
11
11
|
# @example Compiling a template file
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
12
|
+
# # Set up template compiler
|
|
13
|
+
# compiler = GemHadar::TemplateCompiler.new do
|
|
14
|
+
# name 'my_template'
|
|
15
|
+
# version '1.0.0'
|
|
15
16
|
# end
|
|
17
|
+
# # Template (template.erb): Contains ERB placeholders for name and version.
|
|
18
|
+
# # Name: <%= name %>
|
|
19
|
+
# # Version: <%= version %>
|
|
20
|
+
# # Description: This is a template for <%= name %> v<%= version %>
|
|
21
|
+
#
|
|
22
|
+
# # Compile the template.
|
|
16
23
|
# compiler.compile('template.erb', 'output.txt')
|
|
24
|
+
#
|
|
25
|
+
# # Result (output.txt): The rendered output with interpolated values.
|
|
26
|
+
# # Name: my_template
|
|
27
|
+
# # Version: 1.0.0
|
|
28
|
+
# # Description: This is a template for my_template v1.0.0
|
|
17
29
|
class GemHadar::TemplateCompiler
|
|
18
30
|
include Tins::BlockSelf
|
|
19
31
|
include Tins::MethodMissingDelegator::DelegatorModule
|
data/lib/gem_hadar/version.rb
CHANGED
data/lib/gem_hadar.rb
CHANGED
|
@@ -64,6 +64,8 @@ require 'gem_hadar/version_spec'
|
|
|
64
64
|
require 'gem_hadar/prompt_template'
|
|
65
65
|
require 'gem_hadar/changelog_generator'
|
|
66
66
|
require 'gem_hadar/rvm_config'
|
|
67
|
+
require 'gem_hadar/changelog_config'
|
|
68
|
+
require 'gem_hadar/editor'
|
|
67
69
|
|
|
68
70
|
class GemHadar
|
|
69
71
|
include Term::ANSIColor
|
|
@@ -71,6 +73,7 @@ class GemHadar
|
|
|
71
73
|
include GemHadar::PromptTemplate
|
|
72
74
|
include GemHadar::Warn
|
|
73
75
|
include GemHadar::OllamaSupport
|
|
76
|
+
include GemHadar::Editor
|
|
74
77
|
|
|
75
78
|
if defined?(::RbConfig)
|
|
76
79
|
include ::RbConfig
|
|
@@ -598,16 +601,27 @@ class GemHadar
|
|
|
598
601
|
@rvm
|
|
599
602
|
end
|
|
600
603
|
|
|
601
|
-
# The
|
|
602
|
-
#
|
|
604
|
+
# The changelog method configures or retrieves the changelog settings for the
|
|
605
|
+
# gem project.
|
|
603
606
|
#
|
|
604
|
-
# This method
|
|
605
|
-
#
|
|
606
|
-
#
|
|
607
|
-
#
|
|
607
|
+
# This method serves as an accessor for the changelog configuration, allowing
|
|
608
|
+
# the gem project to define settings related to changelog generation and
|
|
609
|
+
# management. When a block is provided, it initializes a new ChangelogConfig
|
|
610
|
+
# instance with the block's configuration. If no block is provided and no
|
|
611
|
+
# existing changelog configuration exists, it creates a new default
|
|
612
|
+
# ChangelogConfig instance.
|
|
608
613
|
#
|
|
609
|
-
# @
|
|
610
|
-
|
|
614
|
+
# @param block [ Proc ] optional block to configure the changelog settings
|
|
615
|
+
#
|
|
616
|
+
# @return [ GemHadar::ChangelogConfig ] the changelog configuration instance
|
|
617
|
+
def changelog(&block)
|
|
618
|
+
if block
|
|
619
|
+
@changelog = ChangelogConfig.new(&block)
|
|
620
|
+
elsif !@changelog
|
|
621
|
+
@changelog = ChangelogConfig.new {}
|
|
622
|
+
end
|
|
623
|
+
@changelog
|
|
624
|
+
end
|
|
611
625
|
|
|
612
626
|
# The default_task_dependencies method manages the list of dependencies for
|
|
613
627
|
# the default Rake task.
|
|
@@ -1726,18 +1740,47 @@ class GemHadar
|
|
|
1726
1740
|
|
|
1727
1741
|
desc 'Append new entries to existing changelog file'
|
|
1728
1742
|
task :add do
|
|
1729
|
-
filename = ARGV[1] ||
|
|
1730
|
-
filename or
|
|
1731
|
-
GemHadar::ChangelogGenerator.new(self).add_to_file(filename)
|
|
1743
|
+
filename = ARGV[1] || changelog.filename
|
|
1744
|
+
filename or next
|
|
1745
|
+
if count = GemHadar::ChangelogGenerator.new(self).add_to_file(filename)
|
|
1746
|
+
edit_file filename
|
|
1747
|
+
puts "#{count} changes were added to #{filename.inspect}."
|
|
1748
|
+
else
|
|
1749
|
+
puts "No new changes added to #{filename.inspect}."
|
|
1750
|
+
end
|
|
1751
|
+
end
|
|
1752
|
+
|
|
1753
|
+
desc 'Edit the existing changelog file'
|
|
1754
|
+
task :edit do
|
|
1755
|
+
filename = ARGV[1] || changelog.filename
|
|
1756
|
+
filename or raise 'Need changelog file to edit'
|
|
1757
|
+
edit_file filename
|
|
1732
1758
|
end
|
|
1733
1759
|
|
|
1734
1760
|
desc 'Check if current version was added to the changelog'
|
|
1735
1761
|
task :added do
|
|
1736
|
-
|
|
1762
|
+
changelog.filename or next
|
|
1737
1763
|
GemHadar::ChangelogGenerator.new(self).changelog_version_added?(version) and next
|
|
1738
1764
|
abort "Version #{GemHadar::VersionSpec[version].untag} has not been "\
|
|
1739
|
-
"documented in changelog #{
|
|
1765
|
+
"documented in changelog #{changelog.filename.inspect} file."
|
|
1766
|
+
end
|
|
1767
|
+
|
|
1768
|
+
desc 'Commit changes in changelog filename'
|
|
1769
|
+
task :commit do
|
|
1770
|
+
changelog.filename or next
|
|
1771
|
+
`git status --porcelain #{changelog.filename.inspect}`.empty? and next
|
|
1772
|
+
system "git add #{changelog.filename.inspect}"
|
|
1773
|
+
msg = changelog.commit_message || "n/a"
|
|
1774
|
+
system "git commit -m #{msg.inspect} #{changelog.filename.inspect}"
|
|
1775
|
+
if $?.success?
|
|
1776
|
+
puts "Successfully commited changes in changelog filename."
|
|
1777
|
+
else
|
|
1778
|
+
warn "Committing changes in changelog filename has failed!"
|
|
1779
|
+
end
|
|
1740
1780
|
end
|
|
1781
|
+
|
|
1782
|
+
desc 'Update changelog file if necessary'
|
|
1783
|
+
task :update => %i[ add commit ]
|
|
1741
1784
|
end
|
|
1742
1785
|
|
|
1743
1786
|
# Main changes task that shows help when called directly
|
|
@@ -1749,17 +1792,20 @@ class GemHadar
|
|
|
1749
1792
|
rake changes:current Show changes between two latest version tags
|
|
1750
1793
|
rake changes:range <range> Show changes for a specific Git range (e.g., v1.0.0..v1.2.0)
|
|
1751
1794
|
rake changes:full [file] Generate complete changelog from first tag
|
|
1752
|
-
rake changes:add
|
|
1795
|
+
rake changes:add [file] Append new entries to changelog file
|
|
1753
1796
|
rake changes:added Check if current version was added to changelog
|
|
1797
|
+
rake changes:edit [file] Edit changelog file
|
|
1798
|
+
rake changes:commit Commit changes in changelog if any
|
|
1799
|
+
rake changes:update Add and commit changes to changelog
|
|
1754
1800
|
|
|
1755
1801
|
Examples:
|
|
1756
|
-
rake changes:pending
|
|
1757
|
-
rake changes:current
|
|
1758
1802
|
rake changes:range v1.0.0..v1.2.0
|
|
1759
|
-
rake changes:full
|
|
1803
|
+
rake changes:full # or
|
|
1760
1804
|
rake changes:full CHANGES.md
|
|
1805
|
+
rake changes:add # or
|
|
1761
1806
|
rake changes:add CHANGES.md
|
|
1762
|
-
rake changes:
|
|
1807
|
+
rake changes:edit # or
|
|
1808
|
+
rake changes:edit CHANGES.md
|
|
1763
1809
|
EOT
|
|
1764
1810
|
end
|
|
1765
1811
|
end
|
|
@@ -1804,42 +1850,6 @@ class GemHadar
|
|
|
1804
1850
|
self
|
|
1805
1851
|
end
|
|
1806
1852
|
|
|
1807
|
-
# The edit_temp_file method creates a temporary file with the provided
|
|
1808
|
-
# content, opens it in an editor for user modification, and returns the
|
|
1809
|
-
# updated content.
|
|
1810
|
-
#
|
|
1811
|
-
# This method first determines the editor to use from the EDITOR environment
|
|
1812
|
-
# variable or defaults to vi. If the editor cannot be found, it issues a
|
|
1813
|
-
# warning and returns nil. It then creates a temporary file, writes the
|
|
1814
|
-
# initial content to it, and opens the file in the editor. After the user
|
|
1815
|
-
# saves and closes the editor, it reads the modified content from the
|
|
1816
|
-
# temporary file. The temporary file is automatically cleaned up after use.
|
|
1817
|
-
#
|
|
1818
|
-
# @param content [ String ] the initial content to write to the temporary
|
|
1819
|
-
# file
|
|
1820
|
-
#
|
|
1821
|
-
# @return [ String, nil ] the content of the temporary file after editing, or
|
|
1822
|
-
# nil if the editor could not be found or failed
|
|
1823
|
-
def edit_temp_file(content)
|
|
1824
|
-
editor = ENV.fetch('EDITOR', `which vi`.chomp)
|
|
1825
|
-
unless File.exist?(editor)
|
|
1826
|
-
warn "Can't find EDITOR. => Returning."
|
|
1827
|
-
return
|
|
1828
|
-
end
|
|
1829
|
-
temp_file = Tempfile.new(%w[ changelog .md ])
|
|
1830
|
-
temp_file.write(content)
|
|
1831
|
-
temp_file.close
|
|
1832
|
-
|
|
1833
|
-
unless system("#{editor} #{temp_file.path}")
|
|
1834
|
-
warn "#{editor} returned #{$?.exitstatus} => Returning."
|
|
1835
|
-
return
|
|
1836
|
-
end
|
|
1837
|
-
|
|
1838
|
-
File.read(temp_file.path)
|
|
1839
|
-
ensure
|
|
1840
|
-
temp_file&.close&.unlink
|
|
1841
|
-
end
|
|
1842
|
-
|
|
1843
1853
|
# The ollama_model_default method returns the default name of the Ollama AI
|
|
1844
1854
|
# model to be used for generating responses when no custom model is
|
|
1845
1855
|
# specified.
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gem_hadar
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.14.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Florian Frank
|
|
@@ -256,7 +256,9 @@ extensions: []
|
|
|
256
256
|
extra_rdoc_files:
|
|
257
257
|
- README.md
|
|
258
258
|
- lib/gem_hadar.rb
|
|
259
|
+
- lib/gem_hadar/changelog_config.rb
|
|
259
260
|
- lib/gem_hadar/changelog_generator.rb
|
|
261
|
+
- lib/gem_hadar/editor.rb
|
|
260
262
|
- lib/gem_hadar/github.rb
|
|
261
263
|
- lib/gem_hadar/ollama_support.rb
|
|
262
264
|
- lib/gem_hadar/prompt_template.rb
|
|
@@ -278,7 +280,9 @@ files:
|
|
|
278
280
|
- bin/gem_hadar
|
|
279
281
|
- gem_hadar.gemspec
|
|
280
282
|
- lib/gem_hadar.rb
|
|
283
|
+
- lib/gem_hadar/changelog_config.rb
|
|
281
284
|
- lib/gem_hadar/changelog_generator.rb
|
|
285
|
+
- lib/gem_hadar/editor.rb
|
|
282
286
|
- lib/gem_hadar/github.rb
|
|
283
287
|
- lib/gem_hadar/github_workflows/static.yml.erb
|
|
284
288
|
- lib/gem_hadar/ollama_support.rb
|