git-changelog 0.9.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.
Files changed (5) hide show
  1. data/LICENSE +20 -0
  2. data/README +9 -0
  3. data/Rakefile +39 -0
  4. data/bin/git-changelog +93 -0
  5. metadata +77 -0
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 PRIMEDIA
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,9 @@
1
+ Git Changelog - Show a list of changes by version.
2
+
3
+ -l, --limit [LIMIT] Maximum commits for each version, default is 20
4
+ --no-limit Show all commits for each version
5
+ -a, --all Show all versions
6
+ --from [VERSION] Start changelog at this version. Defaults to most recent version.
7
+ --to [VERSION] End changelog at this version. Defaults to second most recent version.
8
+ -h, --help Displays this help message
9
+ --version Show version
@@ -0,0 +1,39 @@
1
+ require 'rubygems'
2
+ require 'rake/gempackagetask'
3
+ require 'rubygems/specification'
4
+ require 'date'
5
+
6
+ GEM = "git-changelog"
7
+ GEM_VERSION = "0.9.2"
8
+ AUTHORS = "Jason Noble", "Rein Henrichs"
9
+ SUMMARY = "A gem that provides the git-checkout git command"
10
+
11
+ spec = Gem::Specification.new do |s|
12
+ s.name = GEM
13
+ s.version = GEM_VERSION
14
+ s.platform = Gem::Platform::RUBY
15
+ s.has_rdoc = false
16
+ s.summary = SUMMARY
17
+ s.description = s.summary
18
+ s.authors = AUTHORS
19
+ s.executables = ['git-changelog']
20
+ s.add_dependency('versionomy')
21
+ s.autorequire = GEM
22
+ s.files = %w(LICENSE README Rakefile bin/git-changelog)
23
+ end
24
+
25
+ Rake::GemPackageTask.new(spec) do |pkg|
26
+ pkg.gem_spec = spec
27
+ end
28
+
29
+ desc "install the gem locally"
30
+ task :install => [:package] do
31
+ sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION}}
32
+ end
33
+
34
+ desc "create a gemspec file"
35
+ task :make_spec do
36
+ File.open("#{GEM}.gemspec", "w") do |file|
37
+ file.puts spec.to_ruby
38
+ end
39
+ end
@@ -0,0 +1,93 @@
1
+ #!/usr/bin/env ruby -wKU
2
+ require 'optparse'
3
+ require 'versionomy'
4
+
5
+ def error(msg)
6
+ STDERR.puts "[E]\t#{msg}"
7
+ exit 1
8
+ end
9
+
10
+ def assert_is_git_repo
11
+ error "Not a git repository" unless is_git_repo?
12
+ end
13
+
14
+ def is_git_repo?
15
+ File.directory?('.git')
16
+ end
17
+
18
+ # e.g. v1.4.3
19
+ def valid_version_regexp
20
+ /^v?\d+\.\d+/
21
+ end
22
+
23
+ def git(*args)
24
+ out = `git #{args.join(' ')}`
25
+ raise "Failed git command" unless $?.success?
26
+ out
27
+ end
28
+
29
+ # Find all version tags
30
+ def get_tags
31
+ %x{git tag}.split.grep(valid_version_regexp).map{|tag| Versionomy.parse(tag)}.sort.reverse.map{|t| t.to_s}
32
+ end
33
+
34
+ def annotate!(options)
35
+ limit = options[:limit]
36
+ assert_is_git_repo
37
+ tags = get_tags
38
+
39
+ error "No version tags available." if tags.empty?
40
+
41
+ first = tags.index(options[:to]) || 0
42
+ last = tags.index(options[:from]) || tags.size
43
+
44
+ tags[first..last].each_with_index do |start, i|
45
+ finish = tags[i+1]
46
+ range = ''
47
+ range << "refs/tags/#{finish}.." if finish # log until end tag if there is an end tag
48
+ range << "refs/tags/#{start}"
49
+ log = git(%{log --no-merges --pretty=format:"%h %s" #{range}}).strip.split("\n")
50
+ next if log.empty?
51
+
52
+ puts "#{start}", "=" * start.length, limit ? log[0,limit] : log
53
+ puts " ... and #{log.size - limit} more." if limit && log.size > limit
54
+ puts
55
+ end
56
+ end
57
+
58
+ options = {}
59
+ OptionParser.new do |opts|
60
+ opts.banner = "git changelog - Show a list of changes by version."
61
+
62
+ opts.separator ''
63
+
64
+ opts.on_tail('-h', '--help', 'Displays this help message') do
65
+ puts opts
66
+ exit
67
+ end
68
+
69
+ opts.on_tail("--version", "Show version") do
70
+ puts 'git changelog version ' + QaReleaseTasks.version
71
+ exit
72
+ end
73
+
74
+ opts.on('-l', '--limit [LIMIT]', Integer, 'Maximum commits for each version, default is 20') do |limit|
75
+ options[:limit] = limit || 20
76
+ end
77
+
78
+ opts.on('--no-limit', 'Show all commits for each version') do
79
+ options[:limit] = false
80
+ end
81
+
82
+ opts.on('--from [VERSION]',
83
+ 'Start changelog at this version. Defaults to first version.') do |from|
84
+ options[:from] = from
85
+ end
86
+
87
+ opts.on('--to [VERSION]',
88
+ 'End changelog at this version. Defaults to most recent version.') do |to|
89
+ options[:to] = to
90
+ end
91
+ end.parse!
92
+
93
+ annotate!(options)
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: git-changelog
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 9
8
+ - 2
9
+ version: 0.9.2
10
+ platform: ruby
11
+ authors:
12
+ - Jason Noble
13
+ - Rein Henrichs
14
+ autorequire: git-changelog
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-04-20 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: versionomy
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :runtime
32
+ version_requirements: *id001
33
+ description: A gem that provides the git-checkout git command
34
+ email:
35
+ executables:
36
+ - git-changelog
37
+ extensions: []
38
+
39
+ extra_rdoc_files: []
40
+
41
+ files:
42
+ - LICENSE
43
+ - README
44
+ - Rakefile
45
+ - bin/git-changelog
46
+ has_rdoc: true
47
+ homepage:
48
+ licenses: []
49
+
50
+ post_install_message:
51
+ rdoc_options: []
52
+
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ segments:
67
+ - 0
68
+ version: "0"
69
+ requirements: []
70
+
71
+ rubyforge_project:
72
+ rubygems_version: 1.3.6
73
+ signing_key:
74
+ specification_version: 3
75
+ summary: A gem that provides the git-checkout git command
76
+ test_files: []
77
+