changelog-rb 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ecd9d8c4e85819fb068506d521cd999dc594fd53
4
- data.tar.gz: cecbce157503abefa78614c264a442264b1af602
3
+ metadata.gz: 9b400fbd98a3ba8c72eacd7efaa886728678bc47
4
+ data.tar.gz: 645481df358ac35c6135a89415883c6cfa45c767
5
5
  SHA512:
6
- metadata.gz: 1a9eddceb9237dbef895e487b82ed66b6d9b433a3f23cab0f9471728f34f62e0a2f68bf1186969ef6897a748a61572ecf4a1f6087adc6fa29a8848bbfb0e364d
7
- data.tar.gz: d4de52444aa15509f42c236798b6c912860fa97cb2724c787c0fac7c1b55a967097f9285fd8219ea181d2a8c17cb36e18d84333b130c06855738eff3adee5b5b
6
+ metadata.gz: 2937bad47ffa7d384246a65d4c9506ef29f6de49a891a4eb9466dbd1dd3e5c5567dd74e5365622367a8564e78ed7b0cb825ebbd27742dbe6569104cfccfcb3bf
7
+ data.tar.gz: 56489e36a716f871fad52e780b4d8dfd99d49d79d279324c0c1b058ef639bbe3c0f12cb2b75a381cea5f8bcb9f632018755919a60993ee78cbec29818ff93052
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.2.0] - 2017-09-19
6
+ ### Added
7
+ - ✨ Include compare url at the bottom if it is github (@pinglamb)
8
+
5
9
  ## [0.1.3] - 2017-09-18
6
10
  ### Changed
7
11
  - ✨ Make add script more smart on guessing nature from title (@pinglamb)
@@ -28,3 +32,9 @@
28
32
  ### Changed
29
33
  - ✨ Make print supports version folders (@pinglamb)
30
34
  - ✨ Support getting title from git commit (@pinglamb)
35
+
36
+ [Unreleased]: https://github.com/pinglamb/changelog-rb/compare/0.2.0...HEAD
37
+ [0.2.0]: https://github.com/pinglamb/changelog-rb/compare/v0.1.3...0.2.0
38
+ [0.1.3]: https://github.com/pinglamb/changelog-rb/compare/v0.1.2...v0.1.3
39
+ [0.1.2]: https://github.com/pinglamb/changelog-rb/compare/v0.1.1...v0.1.2
40
+ [0.1.1]: https://github.com/pinglamb/changelog-rb/compare/v0.1.0...v0.1.1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- changelog-rb (0.1.2)
4
+ changelog-rb (0.2.0)
5
5
  activesupport
6
6
  semantic
7
7
  thor
data/README.md CHANGED
@@ -121,7 +121,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
121
121
 
122
122
  ## Contributing
123
123
 
124
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/changelog-rb.
124
+ Bug reports and pull requests are welcome on GitHub at https://github.com/pinglamb/changelog-rb.
125
125
 
126
126
  ## License
127
127
 
@@ -0,0 +1,4 @@
1
+ type: Added
2
+ title: >
3
+ ✨ Include compare url at the bottom if it is github
4
+ author: pinglamb
@@ -0,0 +1 @@
1
+ date: 2017-09-19
@@ -1,15 +1,32 @@
1
1
  require 'yaml'
2
+ require 'changelog/helpers/git'
2
3
 
3
4
  module Changelog
4
5
  module Helpers
5
6
  module Changes
6
7
  def version_header(folder)
7
8
  if folder == "unreleased"
8
- "## [Unreleased]\n"
9
+ "## [#{version_text(folder)}]\n"
9
10
  else
10
11
  meta = YAML.load_file(File.join(destination_root, "changelog/#{folder}/tag.yml"))
11
12
  date = meta['date'].to_s
12
- "## [#{folder}] - #{date}\n"
13
+ "## [#{version_text(folder)}] - #{date}\n"
14
+ end
15
+ end
16
+
17
+ def version_text(folder)
18
+ if folder == 'unreleased'
19
+ 'Unreleased'
20
+ else
21
+ folder
22
+ end
23
+ end
24
+
25
+ def version_sha(folder)
26
+ if folder == 'unreleased'
27
+ 'HEAD'
28
+ else
29
+ Changelog::Helpers::Git.tag(folder) || folder
13
30
  end
14
31
  end
15
32
 
@@ -4,6 +4,30 @@ module Changelog
4
4
  def self.comment(sha)
5
5
  `git show #{sha} -s --format=%B`.strip
6
6
  end
7
+
8
+ def self.origin_url
9
+ `git config --get remote.origin.url`.strip.presence
10
+ end
11
+
12
+ def self.tag(version)
13
+ `git tag | grep "#{version}$"`.split("\n").first
14
+ end
15
+
16
+ def self.github_url
17
+ if origin = origin_url
18
+ if origin =~ /github\.com/
19
+ if origin =~ /^https/
20
+ origin
21
+ else
22
+ "https://github.com/#{origin.gsub(/git@.+:/, '').gsub(/\.git/, '')}"
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ def self.compare_url(sha1, sha2)
29
+ (base_url = github_url) && "#{base_url}/compare/#{sha1}...#{sha2}"
30
+ end
7
31
  end
8
32
  end
9
33
  end
@@ -1,6 +1,7 @@
1
1
  require 'thor'
2
2
  require 'yaml'
3
3
  require 'semantic'
4
+ require 'changelog/helpers/git'
4
5
  require 'changelog/helpers/changes'
5
6
 
6
7
  module Changelog
@@ -16,11 +17,20 @@ module Changelog
16
17
 
17
18
  append_to_file 'CHANGELOG.md', "# Changelog\n", verbose: false
18
19
 
19
- %w[unreleased].concat(version_folders).each do |version|
20
+ versions = %w[unreleased].concat(version_folders)
21
+
22
+ versions.each do |version|
20
23
  shell.say_status :append, "changes in changelog/#{version}", :green unless shell.mute?
21
24
  print_version_header version
22
25
  print_changes version
23
26
  end
27
+
28
+ if Changelog::Helpers::Git.github_url.present?
29
+ append_to_file 'CHANGELOG.md', "\n", verbose: false, force: true
30
+ versions.each_cons(2) do |v1, v2|
31
+ append_to_file 'CHANGELOG.md', "[#{version_text(v1)}]: #{Changelog::Helpers::Git.compare_url(version_sha(v2), version_sha(v1))}\n", verbose: false
32
+ end
33
+ end
24
34
  end
25
35
 
26
36
  def print_version_header(folder)
@@ -1,3 +1,3 @@
1
1
  module Changelog
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: changelog-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - pinglamb
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-09-18 00:00:00.000000000 Z
11
+ date: 2017-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -143,6 +143,8 @@ files:
143
143
  - changelog/0.1.2/tag.yml
144
144
  - changelog/0.1.3/make_add_script_more_smart_on_guessing_nature_from_title.yml
145
145
  - changelog/0.1.3/tag.yml
146
+ - changelog/0.2.0/include_compare_url_at_the_bottom_if_it_is_github.yml
147
+ - changelog/0.2.0/tag.yml
146
148
  - changelog/unreleased/.gitkeep
147
149
  - exe/changelog
148
150
  - lib/changelog-rb.rb