changelog-builder 1.0.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 +7 -0
- data/.gitignore +23 -0
- data/.rspec +3 -0
- data/.rubocop.yml +13 -0
- data/.ruby-version +1 -0
- data/.yardopts +3 -0
- data/CHANGELOG.md +122 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +70 -0
- data/LICENSE.txt +21 -0
- data/README.md +204 -0
- data/Rakefile +21 -0
- data/bin/console +15 -0
- data/bin/setup +21 -0
- data/changelogger.gemspec +37 -0
- data/docs/demo.gif +0 -0
- data/exe/changelogger +5 -0
- data/lib/changelogger/branches_window.rb +704 -0
- data/lib/changelogger/changelog_generator.rb +70 -0
- data/lib/changelogger/cli.rb +247 -0
- data/lib/changelogger/git.rb +45 -0
- data/lib/changelogger/header.rb +45 -0
- data/lib/changelogger/main.rb +29 -0
- data/lib/changelogger/preview_window.rb +130 -0
- data/lib/changelogger/repo_info.rb +78 -0
- data/lib/changelogger/tui.rb +39 -0
- data/lib/changelogger/version.rb +5 -0
- data/lib/changelogger/versioner.rb +68 -0
- data/lib/changelogger.rb +9 -0
- metadata +77 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Changelogger
|
|
4
|
+
# +Changelogger::Versioner+ calculates version numbers for anchor and in-between commits.
|
|
5
|
+
class Versioner
|
|
6
|
+
class << self
|
|
7
|
+
# +Changelogger::Versioner.distribute_patches+ -> Array<Integer>
|
|
8
|
+
#
|
|
9
|
+
# Evenly distributes patch numbers in the range 1..base across +k+ in-between commits.
|
|
10
|
+
# Ensures strictly increasing sequence even when rounding collides.
|
|
11
|
+
#
|
|
12
|
+
# @param [Integer] k number of in-between items
|
|
13
|
+
# @param [Integer] base upper bound for distribution (default: 10)
|
|
14
|
+
# @return [Array<Integer>] strictly increasing patch numbers
|
|
15
|
+
def distribute_patches(k, base: 10) # rubocop:disable Naming/MethodParameterName
|
|
16
|
+
patches = []
|
|
17
|
+
prev = 0
|
|
18
|
+
1.upto(k) do |i|
|
|
19
|
+
x = (i * base.to_f / (k + 1)).round
|
|
20
|
+
x = prev + 1 if x <= prev
|
|
21
|
+
patches << x
|
|
22
|
+
prev = x
|
|
23
|
+
end
|
|
24
|
+
patches
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# +Changelogger::Versioner.assign+ -> Array<[Integer, Changelogger::Commit, String]>
|
|
28
|
+
#
|
|
29
|
+
# Assigns versions for anchor commits (minor increments) and patch versions for in-between commits.
|
|
30
|
+
#
|
|
31
|
+
# @param [Array<Changelogger::Commit>] commits all commits (chronological)
|
|
32
|
+
# @param [Array<Integer>] anchor_indices indices into +commits+ marking anchors
|
|
33
|
+
# @param [Integer] major major version (default: 0)
|
|
34
|
+
# @param [Integer] minor_start starting minor number (default: 1)
|
|
35
|
+
# @param [Integer] base_patch distribution base for patches (default: 10)
|
|
36
|
+
# @return [Array<(Integer, Changelogger::Commit, String)>] each element is [index, commit, "x.y.z"]
|
|
37
|
+
# @raise [ArgumentError] if fewer than 2 anchors are provided
|
|
38
|
+
def assign(commits, anchor_indices, major: 0, minor_start: 1, base_patch: 10)
|
|
39
|
+
raise ArgumentError, "Need at least 2 anchors" if anchor_indices.size < 2
|
|
40
|
+
|
|
41
|
+
anchor_indices = anchor_indices.sort.uniq
|
|
42
|
+
version_map = {}
|
|
43
|
+
|
|
44
|
+
anchor_indices.each_with_index do |idx, j|
|
|
45
|
+
version_map[idx] = [major, minor_start + j, 0]
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
anchor_indices.each_with_index do |start_idx, j|
|
|
49
|
+
break if j >= anchor_indices.size - 1
|
|
50
|
+
|
|
51
|
+
end_idx = anchor_indices[j + 1]
|
|
52
|
+
k = [end_idx - start_idx - 1, 0].max
|
|
53
|
+
patches = distribute_patches(k, base: base_patch)
|
|
54
|
+
|
|
55
|
+
(start_idx + 1).upto(end_idx - 1) do |i|
|
|
56
|
+
pnum = patches[i - start_idx - 1]
|
|
57
|
+
version_map[i] = [major, minor_start + j, pnum]
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
version_map.keys.sort.map do |i|
|
|
62
|
+
v = version_map[i]
|
|
63
|
+
[i, commits[i], "#{v[0]}.#{v[1]}.#{v[2]}"]
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
data/lib/changelogger.rb
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# +Changelogger+ is the root namespace for the gem. It exposes the version and error class.
|
|
4
|
+
module Changelogger
|
|
5
|
+
# +Changelogger::Error+ is a generic error raised by this library.
|
|
6
|
+
class Error < StandardError; end
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
require_relative "changelogger/version"
|
metadata
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: changelog-builder
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- unurgunite
|
|
8
|
+
- SY573M404
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: A pretty simple gem to easily create changelogs according to your git
|
|
14
|
+
commit history.
|
|
15
|
+
email:
|
|
16
|
+
- senpaiguru1488@gmail.com
|
|
17
|
+
- admin@trolltom.xyz
|
|
18
|
+
executables:
|
|
19
|
+
- changelogger
|
|
20
|
+
extensions: []
|
|
21
|
+
extra_rdoc_files: []
|
|
22
|
+
files:
|
|
23
|
+
- ".gitignore"
|
|
24
|
+
- ".rspec"
|
|
25
|
+
- ".rubocop.yml"
|
|
26
|
+
- ".ruby-version"
|
|
27
|
+
- ".yardopts"
|
|
28
|
+
- CHANGELOG.md
|
|
29
|
+
- CODE_OF_CONDUCT.md
|
|
30
|
+
- Gemfile
|
|
31
|
+
- Gemfile.lock
|
|
32
|
+
- LICENSE.txt
|
|
33
|
+
- README.md
|
|
34
|
+
- Rakefile
|
|
35
|
+
- bin/console
|
|
36
|
+
- bin/setup
|
|
37
|
+
- changelogger.gemspec
|
|
38
|
+
- docs/demo.gif
|
|
39
|
+
- exe/changelogger
|
|
40
|
+
- lib/changelogger.rb
|
|
41
|
+
- lib/changelogger/branches_window.rb
|
|
42
|
+
- lib/changelogger/changelog_generator.rb
|
|
43
|
+
- lib/changelogger/cli.rb
|
|
44
|
+
- lib/changelogger/git.rb
|
|
45
|
+
- lib/changelogger/header.rb
|
|
46
|
+
- lib/changelogger/main.rb
|
|
47
|
+
- lib/changelogger/preview_window.rb
|
|
48
|
+
- lib/changelogger/repo_info.rb
|
|
49
|
+
- lib/changelogger/tui.rb
|
|
50
|
+
- lib/changelogger/version.rb
|
|
51
|
+
- lib/changelogger/versioner.rb
|
|
52
|
+
homepage: https://github.com/unurgunite/changelogger
|
|
53
|
+
licenses:
|
|
54
|
+
- MIT
|
|
55
|
+
metadata:
|
|
56
|
+
allowed_push_host: https://rubygems.org
|
|
57
|
+
homepage_uri: https://github.com/unurgunite/changelogger
|
|
58
|
+
source_code_uri: https://github.com/unurgunite/changelogger
|
|
59
|
+
changelog_uri: https://github.com/unurgunite/changelogger/CHANGELOG.md
|
|
60
|
+
rdoc_options: []
|
|
61
|
+
require_paths:
|
|
62
|
+
- lib
|
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - ">="
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: 2.7.0
|
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
|
+
requirements:
|
|
70
|
+
- - ">="
|
|
71
|
+
- !ruby/object:Gem::Version
|
|
72
|
+
version: '0'
|
|
73
|
+
requirements: []
|
|
74
|
+
rubygems_version: 3.7.2
|
|
75
|
+
specification_version: 4
|
|
76
|
+
summary: Gem to generate CHANGELOG.md
|
|
77
|
+
test_files: []
|