timeline 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Matt Duncan
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.
@@ -0,0 +1,50 @@
1
+ Timeline
2
+ ========
3
+
4
+ Timeline is a command line tool for generating timeline data from git
5
+ repositories. It is still very much a work in progress - I'd love to hear your
6
+ thoughts on how it could be better.
7
+
8
+ Timeline is inspired by Jacob Kristhammar and Rickard Böttcher's work on
9
+ [Tornado][0]
10
+
11
+ Usage
12
+ -----
13
+
14
+ Usage: timeline [options] command
15
+ -o, --output FILE Specify the output file name
16
+ -f, --filter FILTER Specify the regular expression to filter the output with
17
+ -r, --revisions REVISIONS The git revisions to use (<since>..<until>)
18
+ -n, --number NUMBER Limit the number of revisions to show
19
+ -b, --branch BRANCH The git branch
20
+ -v, --version Print the version number
21
+ -h, --help Display this help message
22
+
23
+ Examples
24
+ --------
25
+ How have line counts changed over time?
26
+
27
+ timeline -f "\d+" "wc -l index.html"
28
+
29
+ Contributing
30
+ ------------
31
+
32
+ 1. Fork Timeline
33
+ 2. Create a topic branch - `git checkout -b my_branch`
34
+ 3. Push to your branch - `git push origin my_branch`
35
+ 4. Send a pull request
36
+
37
+ Meta
38
+ ----
39
+
40
+ * Code: `git clone git://github.com/mrduncan/timeline.git`
41
+ * Home: <http://github.com/mrduncan/timeline>
42
+ * Bugs: <http://github.com/mrduncan/timeline/issues>
43
+ * Gems: <http://gemcutter.org/gems/timeline>
44
+
45
+ Author
46
+ ------
47
+
48
+ Matt Duncan - matt@mattduncan.org
49
+
50
+ [0]: http://groups.google.com/group/python-tornado/browse_thread/thread/94b45e815ac992ac
@@ -0,0 +1,15 @@
1
+ require 'rake/testtask'
2
+
3
+ $LOAD_PATH.unshift 'lib'
4
+
5
+ desc "Push a new gem version"
6
+ task :publish do
7
+ require 'timeline/version'
8
+
9
+ sh "gem build timeline.gemspec"
10
+ sh "gem push timeline-{Timeline::Version}.gem"
11
+ sh "git tag v#{Timeline::Version}"
12
+ sh "git push origin v#{Timeline::Version}"
13
+ sh "git push origin master"
14
+ sh "git clean -fd"
15
+ end
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+
5
+ # Borrowed from mojombo/ronn
6
+ begin
7
+ require 'timeline'
8
+ rescue LoadError => boom
9
+ if boom.to_s =~ /timeline/
10
+ libdir = File.expand_path("../../lib", __FILE__).sub(%r|^#{Dir.pwd}/|, './')
11
+ if File.directory?(libdir) && !$:.include?(libdir)
12
+ # warn "warn: #{boom}. adding #{libdir} to RUBYLIB ..."
13
+ $:.unshift libdir
14
+ retry
15
+ end
16
+ elsif !defined?(Gem)
17
+ # warn "warn: #{boom}. loading rubygems ..."
18
+ require 'rubygems'
19
+ retry
20
+ end
21
+ abort boom.to_s
22
+ end
23
+
24
+ options = {}
25
+ ARGV.options do |opts|
26
+ opts.banner = "Usage: timeline [options] command"
27
+
28
+ opts.on("-o", "--output FILE", "Specify the output file name") do |file|
29
+ options[:output] = file
30
+ end
31
+ opts.on("-f", "--filter FILTER", "Specify the regular expression to filter the output with") do |filter|
32
+ options[:filter] = filter
33
+ end
34
+ opts.on("-r", "--revisions REVISIONS", "The git revisions to use (<since>..<until>)") do |revisions|
35
+ options[:revisions] = revisions
36
+ end
37
+ opts.on("-n", "--number NUMBER", "Limit the number of revisions to show") do |limit|
38
+ options[:limit] = limit
39
+ end
40
+ opts.on("-b", "--branch BRANCH", "The git branch") do |branch|
41
+ options[:branch] = branch
42
+ end
43
+ opts.on("-v", "--version", "Print the version number") do
44
+ puts Timeline::VERSION
45
+ exit
46
+ end
47
+ opts.on("-h", "--help", "Display this help message") do
48
+ puts opts
49
+ exit
50
+ end
51
+
52
+ opts.parse!
53
+ end
54
+
55
+ options[:command] = ARGV.shift
56
+ if options[:command]
57
+ Timeline::Runner.new(options).execute
58
+ else
59
+ puts ARGV.options
60
+ end
@@ -0,0 +1,2 @@
1
+ require 'timeline/runner'
2
+ require 'timeline/version'
@@ -0,0 +1,41 @@
1
+ module Timeline
2
+ class Runner
3
+ def initialize(options)
4
+ @options = options
5
+ end
6
+
7
+ def execute
8
+ results = []
9
+ `git checkout -q #{@options[:branch] || "master"}`
10
+
11
+ log_options = []
12
+ log_options << "-n #{@options[:limit]}" if @options[:limit]
13
+ log_options << @options[:revisions] if @options[:revisions]
14
+ commits = `git log --format="%H" #{log_options.join}`.split
15
+ commits.each do |commit|
16
+ `git checkout -q #{commit}`
17
+ result = `#{@options[:command]}`.strip
18
+ if @options[:filter]
19
+ match = result.match(/(#{@options[:filter]})/)
20
+ result = ""
21
+ result = match[1] if match && match.length > 0
22
+ end
23
+
24
+ subject = "\"#{`git show -s --format="%s"`.strip}\""
25
+ timestamp = `git show -s --format="%ct"`.to_i
26
+ time = Time.at(timestamp).utc.strftime("%Y-%m-%d %H:%M:%S")
27
+ results << [time, result, subject, commit]
28
+ end
29
+
30
+ # Return to the branch
31
+ `git checkout -q #{@options[:branch] || "master"}`
32
+
33
+ lines = results.map { |line| line.join(",") }.join("\n")
34
+ if @options[:output]
35
+ File.open(@options[:output], "w") { |f| f.write(lines) }
36
+ else
37
+ puts lines
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,3 @@
1
+ module Timeline
2
+ Version = VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: timeline
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Matt Duncan
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-12-19 00:00:00 -05:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: " Timeline is a command line tool for generating timeline data off of git\n repositories. It is inspired by Jacob Kristhammar and Rickard B\xC3\xB6ttcher's\n work on Tornado -\n http://groups.google.com/group/python-tornado/browse_thread/thread/94b45e815ac992ac\n"
23
+ email: matt@mattduncan.org
24
+ executables:
25
+ - timeline
26
+ extensions: []
27
+
28
+ extra_rdoc_files:
29
+ - LICENSE
30
+ - README.markdown
31
+ files:
32
+ - README.markdown
33
+ - Rakefile
34
+ - LICENSE
35
+ - lib/timeline/runner.rb
36
+ - lib/timeline/version.rb
37
+ - lib/timeline.rb
38
+ - bin/timeline
39
+ has_rdoc: true
40
+ homepage: http://github.com/mrduncan/timeline
41
+ licenses: []
42
+
43
+ post_install_message:
44
+ rdoc_options:
45
+ - --charset=UTF-8
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ hash: 3
54
+ segments:
55
+ - 0
56
+ version: "0"
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ hash: 3
63
+ segments:
64
+ - 0
65
+ version: "0"
66
+ requirements: []
67
+
68
+ rubyforge_project:
69
+ rubygems_version: 1.3.7
70
+ signing_key:
71
+ specification_version: 3
72
+ summary: Timeline is a tool for generating timelines off of git repositories.
73
+ test_files: []
74
+