logchange 0.0.1 → 0.0.2
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 +41 -24
- data/changelog/2017.yaml +15 -0
- data/lib/logchange.rb +1 -0
- data/lib/logchange/dispatch.rb +1 -1
- data/lib/logchange/initialize.rb +1 -1
- data/lib/logchange/logger.rb +3 -5
- data/lib/logchange/release.rb +56 -3
- data/lib/logchange/version.rb +1 -1
- data/logchange.gemspec +2 -2
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbb503711f7f99daa59a349a06ab5cff1181d8b0
|
4
|
+
data.tar.gz: cd98aaf7e2dec7877bcb0319f44f3012faebe9aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cbf29f028730e470c8cca827ab6c0b06230e0670e200fda7943f6f42b4014d22339d69d8ec0a52d81c949e9c466af3b0434441b9cff13b8a33636acc3956b17
|
7
|
+
data.tar.gz: 1e2df6b2c579cd13e7972e74b4009cb4c24eab6c530e4a2af2f96bac808fedf23ffd168c18279b07163a82199f55d02978cc4755bc80a93a503221101cf5670e
|
data/README.md
CHANGED
@@ -1,20 +1,24 @@
|
|
1
1
|
# Logchange
|
2
2
|
|
3
|
+
[](https://travis-ci.org/harigopal/logchange)
|
4
|
+
|
3
5
|
Logchange is an alternative approach to managing a _changelog_. Instead of writing to a flat `CHANGELOG(.md)`, it logs
|
4
|
-
changes to `.yaml` files containing a `timestamp
|
6
|
+
changes to `.yaml` files containing a `timestamp` and a `title`. You can extend this format by adding any number of
|
7
|
+
additional fields by specifying a template - allowing customization of the changelog to suit your needs.
|
5
8
|
|
6
|
-
Logchange allows
|
7
|
-
|
8
|
-
|
9
|
+
Logchange allows you to _release_ changes; this allows you to group changes into versioned releases, or
|
10
|
+
timed releases, depending on what your project needs. New entries are kept in `changelog/unreleased` until the `release`
|
11
|
+
command is used to append it to `changelog/YEAR.yaml` file.
|
9
12
|
|
10
|
-
This repository's _changelog_ is maintained using _logchange_.
|
11
|
-
|
13
|
+
This repository's _changelog_ is maintained using _logchange_. See the automatically generated `changelog/2017.yaml`.
|
14
|
+
Unreleased changes go to `changelog/unreleased`.
|
12
15
|
|
13
16
|
## Why?
|
14
17
|
|
15
|
-
It's good to let your users know what you're up to, and it's good to keep track of what changed over time.
|
16
|
-
|
17
|
-
|
18
|
+
It's good to let your users know what you're up to, and it's good to keep track of what changed over time. If your
|
19
|
+
project's code isn't public, it might make sense to include a `private` flag in your template and use that to show only
|
20
|
+
a select list of changes to your users and the public. The _YAML_ format allows the changelog to be extended to fit your
|
21
|
+
specific requirements. It also makes it easy to parse and _present_ the data on the front-end.
|
18
22
|
|
19
23
|
## Installation
|
20
24
|
|
@@ -37,29 +41,42 @@ If you've just completed work on a feature, log it with:
|
|
37
41
|
$ logchange new "A cool new feature has been added"
|
38
42
|
Created [..]/changelog/unreleased/20170521-a-cool-new-feature-has-been-added.yml`
|
39
43
|
|
40
|
-
This will create a new timestamped `.yaml` file in the `changelog` folder.
|
41
|
-
|
44
|
+
This will create a new timestamped `.yaml` file in the `changelog/unreleased` folder.
|
45
|
+
|
46
|
+
```yaml
|
47
|
+
timestamp: 2017-05-21T06:45:08Z
|
48
|
+
title: The title for your change goes here.
|
49
|
+
```
|
42
50
|
|
43
|
-
To
|
51
|
+
To extend the default template used, create a `changelog/template.yaml` file. See customization instructions below.
|
44
52
|
|
45
|
-
|
53
|
+
To _release_ all new _public_ changes to the flat file, run:
|
46
54
|
|
47
|
-
|
48
|
-
github_issue: Add a link to related Github issue, or delete this key.
|
55
|
+
$ logchange release [TAG]
|
49
56
|
|
50
|
-
|
57
|
+
This will add all _unreleased_ changes to `changelog/YEAR.yaml`. The current set of changes will be grouped together,
|
58
|
+
and the time of release will be recorded. You can optionally specify a _tag_ such as a version number. For example:
|
51
59
|
|
52
|
-
|
60
|
+
$ logchange release v0.1.1
|
61
|
+
|
62
|
+
This will group current set of changes and add a `tag` key along with the release `timestamp`.
|
63
|
+
|
64
|
+
## Customize the template
|
65
|
+
|
66
|
+
Create a `changelog/template.yaml` file to add additional keys for information that you'd like to track in your project.
|
53
67
|
|
54
|
-
|
68
|
+
```yaml
|
69
|
+
# There will two keys by default - timestamp and title.
|
70
|
+
# You can add any number of additional keys - this depends on your workflow.
|
71
|
+
# A few examples are below.
|
55
72
|
|
56
|
-
|
73
|
+
description: >
|
74
|
+
Add more detailed information
|
75
|
+
that spans multiple lines.
|
57
76
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
public: Defaults to 'true'. This means that the release command will add this change to CHANGELOG.md. Set to 'false' to prevent that.
|
62
|
-
additional_key_1: You can add any number of additional keys. Logchange will ignore these when writing CHANGELOG.md. Parsing / using these is up to you.
|
77
|
+
github_issue_link: Add link to related Github issue.
|
78
|
+
private: Hide this change from the public?
|
79
|
+
```
|
63
80
|
|
64
81
|
## Development
|
65
82
|
|
data/changelog/2017.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
changelog:
|
3
|
+
- timestamp: '2017-05-22T17:26:09Z'
|
4
|
+
tag: v0.0.2
|
5
|
+
changes:
|
6
|
+
- timestamp: '2017-05-22T17:26:00Z'
|
7
|
+
title: Make the release command functional.
|
8
|
+
- timestamp: '2017-05-22T14:51:26Z'
|
9
|
+
title: Remove the public flag from default set of keys.
|
10
|
+
- timestamp: '2017-05-22T14:46:57Z'
|
11
|
+
title: Alpha release of logchange.
|
12
|
+
public: true
|
13
|
+
- timestamp: '2017-05-22T14:46:09Z'
|
14
|
+
title: Added logchange to project.
|
15
|
+
public: false
|
data/lib/logchange.rb
CHANGED
data/lib/logchange/dispatch.rb
CHANGED
data/lib/logchange/initialize.rb
CHANGED
@@ -10,7 +10,7 @@ module Logchange
|
|
10
10
|
puts 'The changelog directory already exists. Cancelling.'
|
11
11
|
else
|
12
12
|
FileUtils.mkdir_p(path)
|
13
|
-
Logchange::Logger.new('Added logchange to project.'
|
13
|
+
Logchange::Logger.new('Added logchange to project.').execute
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
data/lib/logchange/logger.rb
CHANGED
@@ -4,9 +4,8 @@ require 'time'
|
|
4
4
|
module Logchange
|
5
5
|
# Logs a new change.
|
6
6
|
class Logger
|
7
|
-
def initialize(title
|
7
|
+
def initialize(title)
|
8
8
|
@title = title
|
9
|
-
@public = public
|
10
9
|
end
|
11
10
|
|
12
11
|
def execute
|
@@ -20,14 +19,13 @@ module Logchange
|
|
20
19
|
def log_contents
|
21
20
|
YAML.dump({
|
22
21
|
'timestamp' => Time.now.utc.iso8601,
|
23
|
-
'title' => @title
|
24
|
-
'public' => @public
|
22
|
+
'title' => @title
|
25
23
|
}.merge(template))
|
26
24
|
end
|
27
25
|
|
28
26
|
def template
|
29
27
|
template_path = File.join(Logchange.configuration.changelog_directory_path, 'template.yaml')
|
30
|
-
return {} unless File.
|
28
|
+
return {} unless File.exist?(template_path)
|
31
29
|
YAML.load(File.read(template_path))
|
32
30
|
end
|
33
31
|
|
data/lib/logchange/release.rb
CHANGED
@@ -1,12 +1,65 @@
|
|
1
|
-
require 'fileutils'
|
2
1
|
require 'yaml'
|
3
|
-
require '
|
2
|
+
require 'fileutils'
|
4
3
|
|
5
4
|
module Logchange
|
6
5
|
# Releases new changes to a markdown log.
|
7
6
|
class Release
|
7
|
+
def initialize(tag)
|
8
|
+
@tag = tag
|
9
|
+
end
|
10
|
+
|
8
11
|
def execute
|
9
|
-
|
12
|
+
return if no_unreleased_changes?
|
13
|
+
|
14
|
+
release_list = { 'timestamp' => Time.now.utc.iso8601 }
|
15
|
+
release_list['tag'] = @tag unless @tag.nil?
|
16
|
+
|
17
|
+
release_list['changes'] = unreleased_changelogs.map do |changelog_path|
|
18
|
+
YAML.safe_load(File.read(changelog_path))
|
19
|
+
end
|
20
|
+
|
21
|
+
# Sort the list of changes by timestamp, in reverse.
|
22
|
+
release_list['changes'] = release_list['changes'].sort_by do |changelog|
|
23
|
+
Time.parse(changelog['timestamp'])
|
24
|
+
end.reverse
|
25
|
+
|
26
|
+
update_release_file(release_list)
|
27
|
+
|
28
|
+
# Delete changelogs from unreleased directory.
|
29
|
+
unreleased_changelogs.each { |changelog_path| FileUtils.rm(changelog_path) }
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def update_release_file(release)
|
35
|
+
existing_release = if File.exist?(release_path)
|
36
|
+
YAML.safe_load(File.read(release_path))
|
37
|
+
else
|
38
|
+
{ 'changelog' => [] }
|
39
|
+
end
|
40
|
+
|
41
|
+
# Add latest release to the top of existing release's changelog.
|
42
|
+
existing_release['changelog'] = [release] + existing_release['changelog']
|
43
|
+
|
44
|
+
# Now write updated release back.
|
45
|
+
File.write(release_path, YAML.dump(existing_release))
|
46
|
+
|
47
|
+
puts "Released changes to #{release_path}."
|
48
|
+
end
|
49
|
+
|
50
|
+
def release_path
|
51
|
+
filename = "#{Time.now.utc.year}.yaml"
|
52
|
+
File.join(Logchange.configuration.changelog_directory_path, filename)
|
53
|
+
end
|
54
|
+
|
55
|
+
def no_unreleased_changes?
|
56
|
+
return false if unreleased_changelogs.any?
|
57
|
+
puts 'There are no unreleased changes.'
|
58
|
+
true
|
59
|
+
end
|
60
|
+
|
61
|
+
def unreleased_changelogs
|
62
|
+
@unreleased_changelogs ||= Dir[File.join(Logchange.configuration.changelog_directory_path, 'unreleased', '*.yaml')]
|
10
63
|
end
|
11
64
|
end
|
12
65
|
end
|
data/lib/logchange/version.rb
CHANGED
data/logchange.gemspec
CHANGED
@@ -19,10 +19,10 @@ Gem::Specification.new do |spec|
|
|
19
19
|
end
|
20
20
|
|
21
21
|
spec.required_ruby_version = '>= 2.2.0'
|
22
|
-
spec.bindir = 'exe'
|
23
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
22
|
spec.require_paths = ['lib']
|
25
23
|
|
24
|
+
spec.executables << 'logchange'
|
25
|
+
|
26
26
|
spec.add_development_dependency 'bundler', '~> 1.14'
|
27
27
|
spec.add_development_dependency 'rake', '~> 10.0'
|
28
28
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logchange
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hari Gopal
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -69,7 +69,8 @@ dependencies:
|
|
69
69
|
description: Logs changes to individual YAML files and offers a release mechanism.
|
70
70
|
email:
|
71
71
|
- mail@harigopal.in
|
72
|
-
executables:
|
72
|
+
executables:
|
73
|
+
- logchange
|
73
74
|
extensions: []
|
74
75
|
extra_rdoc_files: []
|
75
76
|
files:
|
@@ -82,6 +83,7 @@ files:
|
|
82
83
|
- Rakefile
|
83
84
|
- bin/console
|
84
85
|
- bin/logchange
|
86
|
+
- changelog/2017.yaml
|
85
87
|
- lib/logchange.rb
|
86
88
|
- lib/logchange/configuration.rb
|
87
89
|
- lib/logchange/dispatch.rb
|