changelog_merger 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 17ff77f84acef90485063fb0863318e6a52fe1b6
4
+ data.tar.gz: a2e50440ca95b346cbfc9781d36348306ebc5969
5
+ SHA512:
6
+ metadata.gz: 24b938c984fd17cec6d807fdae91c239688cdda6db6ad99d08446366d53a97f8015336b9850225328a3de0330f45490ee7fe0a2fd3c0c5986e0393605f6389db
7
+ data.tar.gz: 978a512b59d395a6fee94ec6fe25e449b5e7b29383b62494846aecd270209ddf31dba831661bc215a6886526f8e1670774fa2f911725a68aa648fe39ffac0de9
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in changelog_merger.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Petr Korolev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # ChangelogMerger
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ChangelogMerger`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'ChangelogMerger'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install ChangelogMerger
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ 1. Fork it ( https://github.com/[my-github-username]/ChangelogMerger/fork )
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,4 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ require 'changelog_merger'
4
+ ChangelogMerger::Merger.new.run_generator
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'changelog_merger/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'changelog_merger'
8
+ spec.default_executable = 'changelog_merger'
9
+ spec.version = ChangelogMerger::VERSION
10
+ spec.authors = ['Petr Korolev']
11
+ spec.email = ['sky4winder@gmail.com']
12
+
13
+ spec.summary = %q{Script to merge change logs to github repo}
14
+ spec.description = %q{Script to merge change logs to github repo}
15
+ spec.homepage = 'https://github.com/skywinder/ChangelogMerger'
16
+ spec.license = 'MIT'
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.8"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+
25
+ spec.add_runtime_dependency(%q<github_api>, ["~> 0.12"])
26
+ spec.add_runtime_dependency(%q<colorize>, ["~> 0.7"])
27
+ spec.add_runtime_dependency "github_changelog_generator", "~> 1.3.6"
28
+ spec.add_runtime_dependency "hub", "~> 1.12.4"
29
+ end
@@ -0,0 +1,79 @@
1
+ require "changelog_merger/version"
2
+
3
+ require_relative "changelog_merger/parser"
4
+
5
+ module ChangelogMerger
6
+ # Your code goes here...
7
+ class Merger
8
+ def initialize
9
+ @options = Parser.parse_options
10
+
11
+ end
12
+
13
+ def run_generator
14
+ go_to_work_dir
15
+ clone_repo_and_cd
16
+ generate_change_log
17
+ add_commit_push
18
+ end
19
+
20
+ def add_commit_push
21
+ execute_line('hub fork')
22
+ execute_line('git checkout -b add-change-log-file')
23
+ execute_line('git add CHANGELOG.md')
24
+ execute_line("git commit -v -m '#{@options[:message]}'")
25
+ execute_line('git push skywinder')
26
+ # execute_line('git push')
27
+ execute_line("hub pull-request -m '#{@options[:pr_message]}' -o")
28
+ end
29
+
30
+ def generate_change_log
31
+ execute_line("github_changelog_generator #{@options[:repo]}")
32
+ end
33
+
34
+ def clone_repo_and_cd
35
+ if Dir.exist?(@options[:project])
36
+ execute_line("rm -rf #{@options[:project]}")
37
+ end
38
+ execute_line("hub clone #{@options[:repo]}")
39
+ Dir.chdir("./#{@options[:project]}")
40
+ puts "Go to #{Dir.pwd}"
41
+ end
42
+
43
+ def execute_line(line)
44
+ if @options[:dry_run]
45
+ puts "Dry run: #{line}"
46
+ return nil
47
+ end
48
+ puts line
49
+ value = %x[#{line}]
50
+ puts value
51
+ check_exit_status(value)
52
+ value
53
+ end
54
+
55
+ def check_exit_status(output)
56
+ if $?.exitstatus != 0
57
+ puts "Output:\n#{output}\nExit status = #{$?.exitstatus} ->Terminate script."
58
+ exit
59
+ end
60
+ end
61
+
62
+ def go_to_work_dir
63
+ Dir.chdir(@options[:path])
64
+
65
+ merger_folder = 'changelog_merger_dir'
66
+ unless Dir.exist?(merger_folder)
67
+ puts "Creating directory #{merger_folder}"
68
+ Dir.mkdir(merger_folder)
69
+ end
70
+ Dir.chdir("./#{merger_folder}")
71
+
72
+ puts "Go to #{Dir.pwd}"
73
+ end
74
+ end
75
+ end
76
+
77
+ if __FILE__ == $0
78
+ ChangelogMerger::Merger.new.run_generator
79
+ end
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/env ruby
2
+ require 'optparse'
3
+ require 'pp'
4
+ require_relative 'version'
5
+
6
+ module ChangelogMerger
7
+ class Parser
8
+ def self.parse_options
9
+ # :include_labels => %w(bug enhancement),
10
+
11
+ options = {:message => 'Added automatically generated change log file',
12
+ # :dry_run => true
13
+ }
14
+
15
+ parser = OptionParser.new { |opts|
16
+ opts.banner = 'Usage: changelog_merger [options]'
17
+ opts.on('-r', '--repo REPO', 'destination repo in format user/repo') do |last|
18
+ options[:repo] = last
19
+ end
20
+ opts.on('-t', '--token [TOKEN]', 'To make more than 50 requests per hour your GitHub token required. You can generate it here: https://github.com/settings/tokens/new') do |last|
21
+ options[:token] = last
22
+ end
23
+ opts.on('-m', '--message [MESSAGE]', 'Message for pull request') do |last|
24
+ options[:message] = last
25
+ end
26
+ options[:verbose] = true
27
+ opts.on('--[no-]verbose', 'Run verbosely. Default is true') do |v|
28
+ options[:verbose] = v
29
+ end
30
+ opts.on('-v', '--version', 'Print version number') do |v|
31
+ puts "Version: #{ChangelogMerger::VERSION}"
32
+ exit
33
+ end
34
+ options[:path] = `echo ~`.strip!
35
+ opts.on('-p', '--path', 'Path to save projects') do |v|
36
+ options[:path] = v
37
+ end
38
+ opts.on('-h', '--help', 'Displays Help') do
39
+ puts opts
40
+ exit
41
+ end
42
+ }
43
+
44
+ begin
45
+ parser.parse!
46
+
47
+ mandatory = [:repo] # Enforce the presence of
48
+ missing = mandatory.select { |param| options[param].nil? } # the -t and -f switches
49
+ unless missing.empty?
50
+ puts "Missing options: #{missing.join(', ')}"
51
+ puts parser
52
+ exit
53
+ end
54
+
55
+ if options[:repo]
56
+ options[:user], options[:project] = options[:repo].split('/')
57
+ end
58
+
59
+ if !options[:user] || !options[:project]
60
+ puts parser.banner
61
+ exit
62
+ end
63
+
64
+ rescue OptionParser::InvalidOption, OptionParser::MissingArgument
65
+ puts $!.to_s # Friendly output when parsing fails
66
+ puts parser
67
+ exit
68
+ end
69
+
70
+ options[:pr_message] = "Add automatically generated change log file.
71
+
72
+ Hi, as I can see, you are carefully fill tags and labels for issues in your repo.
73
+ I created a [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator), that generate change log file based on tags, issues and merged pull requests (and split them to separate lists according labels) from GitHub issue tracker.
74
+ [This Change Log](https://github.com/skywinder/#{options[:project]}/blob/add-change-log-file/CHANGELOG.md) was automatically generated by this script.
75
+ It helps to easily found what and when was fixed and implemented.
76
+ You can easily update this file in future by running script: `github_changelog_generator` in your repo folder.
77
+ Hope you find this commit as useful."
78
+
79
+ if options[:verbose]
80
+ puts 'Performing task with options:'
81
+ pp options
82
+ puts ''
83
+ end
84
+
85
+ options
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,3 @@
1
+ module ChangelogMerger
2
+ VERSION = "0.1.2"
3
+ end
metadata ADDED
@@ -0,0 +1,141 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: changelog_merger
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Petr Korolev
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.8'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: github_api
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.12'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.12'
55
+ - !ruby/object:Gem::Dependency
56
+ name: colorize
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.7'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.7'
69
+ - !ruby/object:Gem::Dependency
70
+ name: github_changelog_generator
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 1.3.6
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 1.3.6
83
+ - !ruby/object:Gem::Dependency
84
+ name: hub
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 1.12.4
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 1.12.4
97
+ description: Script to merge change logs to github repo
98
+ email:
99
+ - sky4winder@gmail.com
100
+ executables:
101
+ - changelog_merger
102
+ - setup
103
+ extensions: []
104
+ extra_rdoc_files: []
105
+ files:
106
+ - ".gitignore"
107
+ - Gemfile
108
+ - LICENSE.txt
109
+ - README.md
110
+ - Rakefile
111
+ - bin/changelog_merger
112
+ - bin/setup
113
+ - changelog_merger.gemspec
114
+ - lib/changelog_merger.rb
115
+ - lib/changelog_merger/parser.rb
116
+ - lib/changelog_merger/version.rb
117
+ homepage: https://github.com/skywinder/ChangelogMerger
118
+ licenses:
119
+ - MIT
120
+ metadata: {}
121
+ post_install_message:
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ requirements: []
136
+ rubyforge_project:
137
+ rubygems_version: 2.4.4
138
+ signing_key:
139
+ specification_version: 4
140
+ summary: Script to merge change logs to github repo
141
+ test_files: []