gfsm 0.4.1 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +1 -1
- data/.version +1 -1
- data/Dockerfile +4 -2
- data/bin/gfsm +0 -0
- data/lib/commands/changelog.rb +68 -2
- data/lib/commands/help.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c272fe1a10ec5d572c5730e7fae0c2576443887f970c38f1c1923d8195cf276a
|
4
|
+
data.tar.gz: 6c62f1a5cb113a2b0cfcbcf7415498a64311fb91354f76ce5402a0d267b112d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac25726a4d7adb447f53ab68519de68ebc3b1691cb58ae6c5e216b6f81888806e27718ce46e8d209e3a874fd7b98a748c5cbc5162dd082299d4c20f4e2b5eb86
|
7
|
+
data.tar.gz: b304347cd26aa23411353499da1477e28c732b41f4164da0f1b20c9d6a224b8ce6bcc635691b041a3d9949254b175c10ac5ead6dfcfcef97b9d93176cbe9536d
|
data/.gitlab-ci.yml
CHANGED
@@ -72,7 +72,7 @@ Upload docker image:
|
|
72
72
|
- docker:20.10.16-dind
|
73
73
|
script:
|
74
74
|
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
75
|
-
- docker build -t $CI_REGISTRY_IMAGE:latest -t $CI_REGISTRY_IMAGE:v$RELEASE_VERSION .
|
75
|
+
- docker build --build-arg="GFSM_VERSION=${RELEASE_VERSION}" -t $CI_REGISTRY_IMAGE:latest -t $CI_REGISTRY_IMAGE:v$RELEASE_VERSION .
|
76
76
|
- docker push --all-tags $CI_REGISTRY_IMAGE
|
77
77
|
rules:
|
78
78
|
- if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
|
data/.version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.1
|
data/Dockerfile
CHANGED
data/bin/gfsm
CHANGED
File without changes
|
data/lib/commands/changelog.rb
CHANGED
@@ -11,22 +11,27 @@ module GFSM
|
|
11
11
|
|
12
12
|
<<~HELP
|
13
13
|
Usage:
|
14
|
-
gfsm changelog [help|generate] [--output-file <path>] [--no-incremental] #{cli_info[:usage]}
|
14
|
+
gfsm changelog [help|generate|extract] [--output-file <path>] [--input-file <path>] [--no-incremental] [--only-new-entries] [--extract-version <version>] #{cli_info[:usage]}
|
15
15
|
|
16
16
|
Commands:
|
17
17
|
help # Prints this help
|
18
18
|
generate # Generate the changelog for the current version
|
19
|
+
extract # Extract the changelog for the latest or specified version
|
19
20
|
|
20
21
|
Options:
|
21
22
|
--output-file <path> # Path to the output changelog file. Defaults to 'CHANGELOG.md'. If not specified, the generate changelog content will be written to stdout
|
22
23
|
--no-incremental # When provided, the generated changelog won't look for an existing changelog file. When outputting to stdout the changelog will never be incremental
|
23
24
|
--only-new-entries # When provided, the generated changelog won't look for an existing changelog file and will contain only the new entries for the current version, without the Changelog or version headings
|
25
|
+
--input-file <path> # Path to the input changelog file. Defaults to 'CHANGELOG.md'
|
26
|
+
--extract-version <version> # Version from which to extract the changelog. Defaults to the latest one on the changelog file
|
24
27
|
#{cli_info[:options]}
|
25
28
|
|
26
29
|
Environment variables:
|
27
30
|
OUTPUT_FILE # Equivalent to --output-file
|
28
31
|
NO_INCREMENTAL # Equivalent to --no-incremental
|
29
32
|
ONLY_NEW_ENTRIES # Equivalent to --only-new-entries
|
33
|
+
INPUT_FILE # Equivalent to --input-file
|
34
|
+
EXTRACT_VERSION # Equivalent to --extract-version
|
30
35
|
#{cli_info[:environment_variables]}
|
31
36
|
HELP
|
32
37
|
end
|
@@ -64,8 +69,23 @@ module GFSM
|
|
64
69
|
end
|
65
70
|
end
|
66
71
|
end
|
72
|
+
when 'extract'
|
73
|
+
input_file_path = get_input_file_path(args)
|
74
|
+
version_to_extract = get_version_to_extract(args)
|
75
|
+
|
76
|
+
unless File.file?(input_file_path)
|
77
|
+
GFSM::Output.error "No changelog file found at #{input_file_path}"
|
78
|
+
else
|
79
|
+
section = extract_version_section(input_file_path, version_to_extract)
|
80
|
+
|
81
|
+
if section.nil?
|
82
|
+
GFSM::Output.error "No changelog section found for version #{version_to_extract}"
|
83
|
+
else
|
84
|
+
GFSM::Output.puts section
|
85
|
+
end
|
86
|
+
end
|
67
87
|
else
|
68
|
-
GFSM::Output.warn
|
88
|
+
GFSM::Output.warn GFSM::Commands::Changelog.help
|
69
89
|
end
|
70
90
|
|
71
91
|
true
|
@@ -106,6 +126,44 @@ module GFSM
|
|
106
126
|
"#{section}\n\n#{changelog_entries}"
|
107
127
|
end
|
108
128
|
|
129
|
+
def extract_version_section(input_file_path, version_to_extract)
|
130
|
+
file_content = File.read(input_file_path)
|
131
|
+
|
132
|
+
# Parse the file contect to subdivide the changelog sections based on the version
|
133
|
+
version_sections = file_content.split(/^## /)
|
134
|
+
|
135
|
+
# Remove the initial empty section
|
136
|
+
version_sections.shift
|
137
|
+
|
138
|
+
version_to_extract_index = if version_to_extract.nil? || version_to_extract == "latest"
|
139
|
+
0
|
140
|
+
else
|
141
|
+
version_sections.find_index { |section| section.start_with?("#{version_to_extract}\n") }
|
142
|
+
end
|
143
|
+
return nil if version_to_extract_index.nil? || version_to_extract_index > version_sections.length
|
144
|
+
|
145
|
+
version_section = version_sections[version_to_extract_index]
|
146
|
+
|
147
|
+
# Remove the first line that contains version heading
|
148
|
+
version_section = version_section[version_section.index("\n")..-1]
|
149
|
+
|
150
|
+
# Remove the empty lines at the start and at the end of version_section
|
151
|
+
version_section = version_section.strip
|
152
|
+
|
153
|
+
return version_section
|
154
|
+
end
|
155
|
+
|
156
|
+
def extract_switch_value(args, switch, default_value, env_name = nil)
|
157
|
+
return ENV.fetch(env_name) if ENV.has_key?(env_name)
|
158
|
+
|
159
|
+
switch_index = args.find_index(switch)
|
160
|
+
|
161
|
+
return default_value unless switch_index &&
|
162
|
+
(switch_index + 1) < args.length
|
163
|
+
|
164
|
+
args[switch_index + 1]
|
165
|
+
end
|
166
|
+
|
109
167
|
def extract_switch_value_if_present(args, switch, default_value, env_name)
|
110
168
|
return ENV.fetch(env_name) if ENV.has_key?(env_name)
|
111
169
|
|
@@ -120,6 +178,14 @@ module GFSM
|
|
120
178
|
def get_output_file_path(args)
|
121
179
|
extract_switch_value_if_present(args, "--output-file", "./CHANGELOG.md", "OUTPUT_FILE")
|
122
180
|
end
|
181
|
+
|
182
|
+
def get_input_file_path(args)
|
183
|
+
extract_switch_value(args, "--input-file", "./CHANGELOG.md", "INPUT_FILE")
|
184
|
+
end
|
185
|
+
|
186
|
+
def get_version_to_extract(args)
|
187
|
+
extract_switch_value(args, "--extract-version", nil, "EXTRACT_VERSION")
|
188
|
+
end
|
123
189
|
end
|
124
190
|
end
|
125
191
|
end
|
data/lib/commands/help.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gfsm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zille Marco
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-06-
|
11
|
+
date: 2024-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yaml
|