git-trip 0.0.3

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 (92) hide show
  1. data.tar.gz.sig +0 -0
  2. data/History.txt +21 -0
  3. data/Manifest.txt +89 -0
  4. data/README.txt +60 -0
  5. data/Rakefile +31 -0
  6. data/bin/git-trip +0 -0
  7. data/doc/USAGE.txt +54 -0
  8. data/lib/core_ext/hash.rb +15 -0
  9. data/lib/git-trip.rb +23 -0
  10. data/lib/git-trip/errors.rb +22 -0
  11. data/lib/git-trip/gitter.rb +10 -0
  12. data/lib/git-trip/gitter/base.rb +18 -0
  13. data/lib/git-trip/gitter/dir.rb +32 -0
  14. data/lib/git-trip/gitter/uri.rb +40 -0
  15. data/lib/git-trip/paint_mode.rb +52 -0
  16. data/lib/git-trip/painter.rb +167 -0
  17. data/spec/core_ext/hash_spec.rb +25 -0
  18. data/spec/git-trip/errors_spec.rb +43 -0
  19. data/spec/git-trip/gitter/base_spec.rb +15 -0
  20. data/spec/git-trip/gitter/dir_spec.rb +37 -0
  21. data/spec/git-trip/gitter/uri_spec.rb +25 -0
  22. data/spec/git-trip/gitter_spec.rb +11 -0
  23. data/spec/git-trip/paint_mode_spec.rb +56 -0
  24. data/spec/git-trip/painter_spec.rb +173 -0
  25. data/spec/git_trip_spec.rb +23 -0
  26. data/spec/rcov.opts +1 -0
  27. data/spec/spec.opts +4 -0
  28. data/spec/spec_helper.rb +15 -0
  29. data/tasks/ditz.rake +42 -0
  30. data/tasks/docs.rake +68 -0
  31. data/tasks/gittrip.rake +63 -0
  32. data/tasks/rspec.rake +22 -0
  33. data/tasks/site.rake +48 -0
  34. data/tasks/util.rake +44 -0
  35. data/vendor/grit/History.txt +6 -0
  36. data/vendor/grit/Manifest.txt +53 -0
  37. data/vendor/grit/README.txt +213 -0
  38. data/vendor/grit/Rakefile +29 -0
  39. data/vendor/grit/grit.gemspec +16 -0
  40. data/vendor/grit/lib/grit.rb +37 -0
  41. data/vendor/grit/lib/grit/actor.rb +36 -0
  42. data/vendor/grit/lib/grit/blob.rb +117 -0
  43. data/vendor/grit/lib/grit/commit.rb +208 -0
  44. data/vendor/grit/lib/grit/config.rb +44 -0
  45. data/vendor/grit/lib/grit/diff.rb +70 -0
  46. data/vendor/grit/lib/grit/errors.rb +7 -0
  47. data/vendor/grit/lib/grit/git.rb +116 -0
  48. data/vendor/grit/lib/grit/index.rb +77 -0
  49. data/vendor/grit/lib/grit/lazy.rb +31 -0
  50. data/vendor/grit/lib/grit/ref.rb +110 -0
  51. data/vendor/grit/lib/grit/repo.rb +318 -0
  52. data/vendor/grit/lib/grit/tree.rb +99 -0
  53. data/vendor/grit/test/fixtures/blame +131 -0
  54. data/vendor/grit/test/fixtures/cat_file_blob +1 -0
  55. data/vendor/grit/test/fixtures/cat_file_blob_size +1 -0
  56. data/vendor/grit/test/fixtures/diff_2 +54 -0
  57. data/vendor/grit/test/fixtures/diff_2f +19 -0
  58. data/vendor/grit/test/fixtures/diff_f +15 -0
  59. data/vendor/grit/test/fixtures/diff_i +201 -0
  60. data/vendor/grit/test/fixtures/diff_mode_only +1152 -0
  61. data/vendor/grit/test/fixtures/diff_new_mode +17 -0
  62. data/vendor/grit/test/fixtures/diff_p +610 -0
  63. data/vendor/grit/test/fixtures/for_each_ref +0 -0
  64. data/vendor/grit/test/fixtures/for_each_ref_remotes +0 -0
  65. data/vendor/grit/test/fixtures/for_each_ref_tags +0 -0
  66. data/vendor/grit/test/fixtures/ls_tree_a +7 -0
  67. data/vendor/grit/test/fixtures/ls_tree_b +2 -0
  68. data/vendor/grit/test/fixtures/ls_tree_commit +3 -0
  69. data/vendor/grit/test/fixtures/rev_list +26 -0
  70. data/vendor/grit/test/fixtures/rev_list_count +655 -0
  71. data/vendor/grit/test/fixtures/rev_list_single +7 -0
  72. data/vendor/grit/test/fixtures/rev_parse +1 -0
  73. data/vendor/grit/test/fixtures/show_empty_commit +6 -0
  74. data/vendor/grit/test/fixtures/simple_config +2 -0
  75. data/vendor/grit/test/helper.rb +17 -0
  76. data/vendor/grit/test/profile.rb +21 -0
  77. data/vendor/grit/test/suite.rb +6 -0
  78. data/vendor/grit/test/test_actor.rb +35 -0
  79. data/vendor/grit/test/test_blob.rb +74 -0
  80. data/vendor/grit/test/test_commit.rb +182 -0
  81. data/vendor/grit/test/test_config.rb +58 -0
  82. data/vendor/grit/test/test_diff.rb +18 -0
  83. data/vendor/grit/test/test_git.rb +52 -0
  84. data/vendor/grit/test/test_head.rb +22 -0
  85. data/vendor/grit/test/test_real.rb +19 -0
  86. data/vendor/grit/test/test_reality.rb +17 -0
  87. data/vendor/grit/test/test_remote.rb +15 -0
  88. data/vendor/grit/test/test_repo.rb +278 -0
  89. data/vendor/grit/test/test_tag.rb +29 -0
  90. data/vendor/grit/test/test_tree.rb +91 -0
  91. metadata +179 -0
  92. metadata.gz.sig +0 -0
@@ -0,0 +1,23 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe GitTrip do
4
+ it "should return version string" do
5
+ GitTrip::VERSION.should be_a_kind_of(String)
6
+ end
7
+
8
+ it "should include Grit" do
9
+ Grit.should be_a_kind_of(Module)
10
+ end
11
+
12
+ it "should include Magick" do
13
+ Magick.should be_a_kind_of(Module)
14
+ end
15
+
16
+ it "should include Errors" do
17
+ GitTrip::Errors.should be_a_kind_of(Module)
18
+ end
19
+
20
+ it "should include Gitter" do
21
+ GitTrip::Gitter.should be_a_kind_of(Module)
22
+ end
23
+ end
@@ -0,0 +1 @@
1
+ --exclude "spec/*,gems/*"
@@ -0,0 +1,4 @@
1
+ --colour
2
+ --format progress
3
+ --loadby mtime
4
+ --reverse
@@ -0,0 +1,15 @@
1
+ require 'spec'
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/git-trip')
4
+ include GitTrip
5
+
6
+ Spec::Runner.configure do |config|
7
+ # == Mock Framework
8
+ #
9
+ # RSpec uses it's own mocking framework by default. If you prefer to
10
+ # use mocha, flexmock or RR, uncomment the appropriate line:
11
+ #
12
+ # config.mock_with :mocha
13
+ # config.mock_with :flexmock
14
+ # config.mock_with :rr
15
+ end
@@ -0,0 +1,42 @@
1
+ # Tasks that make it easier to deal with ditz.
2
+
3
+ DOC_ROOT = File.join(APP_ROOT, 'doc') unless defined? DOC_ROOT
4
+ ISSUE_DIR = "#{DOC_ROOT}/issues"
5
+
6
+ # 'rake issues' will just list them.
7
+ desc 'List current issues'
8
+ task :issues do
9
+ Rake::Task['issues:list'].invoke
10
+ end
11
+
12
+ namespace :issues do
13
+ desc 'Add an issue'
14
+ task :add do
15
+ sh 'ditz add'
16
+ end
17
+
18
+ task :list do
19
+ # Use back-tick execution to prevent output of command being run.
20
+ # Returns a string of the command output.
21
+ puts `ditz todo`
22
+ end
23
+
24
+ # 'rake issues:report' will just generate the report.
25
+ desc 'Generate issue report'
26
+ task :report do
27
+ Rake::Task['issues:report:generate'].invoke
28
+ end
29
+
30
+ namespace :report do
31
+ task :generate => [ 'issues:report:clear' ] do
32
+ header "Generating issue report in #{ISSUE_DIR}"
33
+ sh "ditz html #{ISSUE_DIR}"
34
+ end
35
+
36
+ desc 'Clear the issue report'
37
+ task :clear do
38
+ header "Removing issue report from #{ISSUE_DIR}"
39
+ sh "rm -rf #{ISSUE_DIR}"
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,68 @@
1
+ # Tasks to handle application docs.
2
+ DOC_TITLE = "GitTrip v#{GitTrip::VERSION} Documentation"
3
+ DOC_ROOT = File.join(APP_ROOT, 'doc') unless defined? DOC_ROOT
4
+ API_DOCS = File.join(DOC_ROOT, 'api')
5
+
6
+ # Remove the default Hoe documentation tasks.
7
+ remove_task 'clobber_docs'
8
+ remove_task 'docs'
9
+ remove_task 'docs/index.html'
10
+ remove_task 'publish_docs'
11
+ remove_task 'redocs'
12
+ remove_task 'ridocs'
13
+
14
+ # Override the default clobber_docs task.
15
+ task :clobber_docs do
16
+ Rake::Task['docs:clear'].invoke
17
+ end
18
+
19
+ desc 'Generate the GitTrip API docs'
20
+ task :docs do
21
+ Rake::Task['docs:api'].invoke
22
+ end
23
+
24
+ namespace :docs do
25
+ task :setup_rdoc do
26
+ @file_list = FileList[ "#{APP_ROOT}/README.txt",
27
+ "#{APP_ROOT}/doc/USAGE.txt",
28
+ "#{APP_ROOT}/lib/**/*.rb" ]
29
+ # Substitute APP_ROOT with a dot. Makes for a better index in the generated docs.
30
+ @files = @file_list.collect {|f| f.gsub(/#{APP_ROOT}/, '.')}
31
+ @options = %W[
32
+ --all
33
+ --inline-source
34
+ --line-numbers
35
+ --main README.txt
36
+ --op #{API_DOCS}
37
+ --title '#{DOC_TITLE}'
38
+ ]
39
+ # Generate a diagram, yes/no?
40
+ @options << '-d' if RUBY_PLATFORM !~ /win32/ && `which dot` =~ /\/dot/ && !ENV['NODOT']
41
+ end
42
+
43
+ task :api => [ :setup_rdoc ] do
44
+ run_rdoc(@options, @files)
45
+ end
46
+
47
+ desc 'Remove the GitTrip API docs'
48
+ task :clear do
49
+ header("Removing documentation from #{API_DOCS}")
50
+ system("rm -rf #{API_DOCS}")
51
+ end
52
+
53
+ desc 'Remove and rebuild the GitTrip API docs'
54
+ task :rebuild do
55
+ Rake::Task['docs:clear'].invoke
56
+ Rake::Task['docs:api'].invoke
57
+ end
58
+ end
59
+
60
+ private
61
+
62
+ # Runs rdoc with the given +options+ and +files+.
63
+ # Both arguments should be an Array, which is joined with a space.
64
+ def run_rdoc(options, files)
65
+ options = options.join(' ') if options.is_a? Array
66
+ files = files.join(' ') if files.is_a? Array
67
+ system("rdoc #{options} #{files}")
68
+ end
@@ -0,0 +1,63 @@
1
+ # Comma seperated list of image formats.
2
+ FORMATS = ENV['FORMATS'] ? ENV['FORMATS'].split(',') : %w{ gif jpg png }
3
+ # Output directory.
4
+ IMG_DIR = ENV['IMG_DIR'] || File.join(APP_ROOT, 'sandbox/git-trip')
5
+ # Repository to use in image generation.
6
+ IMG_REPO = ENV['IMG_REPO'] || APP_ROOT
7
+
8
+ namespace :gittrip do
9
+ desc 'Clean up dynamically generated files'
10
+ task :cleanup do
11
+ %w{
12
+ docs:clear
13
+ gittrip:site:clear_local
14
+ gittrip:test:images:clear
15
+ issues:report:clear
16
+ }.each do |cleaner|
17
+ Rake::Task[cleaner].invoke
18
+ end
19
+ end
20
+
21
+ namespace :test do
22
+ desc 'Generate test images in sandbox/git-trip'
23
+ task :images => 'gittrip:test:images:generate'
24
+
25
+ namespace :images do
26
+ task :generate do
27
+ gen_test_images(IMG_DIR, IMG_REPO)
28
+ end
29
+
30
+ desc 'Remove the generated test images'
31
+ task :clear do
32
+ FORMATS.each do |format|
33
+ dir = File.join(IMG_DIR, format)
34
+ header("Removing images in #{dir}")
35
+ sh "rm -rf #{dir}/*" if File.exists?(dir)
36
+ end
37
+ end
38
+
39
+ desc 'Regenerate the test images'
40
+ task :rebuild do
41
+ Rake::Task['gittrip:test:images:clear'].invoke
42
+ Rake::Task['gittrip:test:images:generate'].invoke
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ # Generate test images in the given directory.
49
+ def gen_test_images(dir, repo_dir)
50
+ repo = GitTrip::Gitter::Dir.new(repo_dir)
51
+ FORMATS.each do |format|
52
+ base_dir = "#{dir}/#{format}"
53
+ FileUtils.mkpath(base_dir) unless File.exists?(base_dir)
54
+ repo.commits.each_with_index do |commit, index|
55
+ painter = GitTrip::Painter.new(commit)
56
+ painter.paint!
57
+ painter.picture.write("#{base_dir}/#{index}.#{format}")
58
+ cool_pic = GitTrip::PaintMode.new(painter.picture, :radial).picture
59
+ cool_pic.write("#{base_dir}/#{index}-pretty.#{format}")
60
+ end
61
+ header("Images written to #{base_dir}")
62
+ end
63
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec/rake/spectask'
2
+
3
+ desc 'Run all specs in spec directory with RCov'
4
+ task :rcov => 'spec:rcov'
5
+
6
+ desc 'Run all specs in spec directory'
7
+ Spec::Rake::SpecTask.new(:spec) do |t|
8
+ t.spec_opts = ['--options', 'spec/spec.opts']
9
+ t.spec_files = FileList['spec/**/*_spec.rb']
10
+ end
11
+
12
+ namespace :spec do
13
+ desc 'Run all specs in spec directory with RCov'
14
+ Spec::Rake::SpecTask.new(:rcov) do |t|
15
+ t.spec_opts = ['--options', 'spec/spec.opts']
16
+ t.spec_files = FileList['spec/**/*_spec.rb']
17
+ t.rcov = true
18
+ t.rcov_opts = lambda do
19
+ IO.readlines('spec/rcov.opts').map {|l| l.chomp.split ' '}.flatten
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,48 @@
1
+ # Tasks for dealing with the RubyForge site.
2
+
3
+ # The local directories to store the website files.
4
+ DOC_ROOT = File.join(APP_ROOT, 'doc') unless defined? DOC_ROOT
5
+ LOCAL_SITE = File.join(DOC_ROOT, 'rubyforge.site')
6
+ SITE_API = File.join(LOCAL_SITE, 'api')
7
+ SITE_ISSUES = File.join(LOCAL_SITE, 'issues')
8
+
9
+ # The remote directory the files will be scp'ed to.
10
+ REMOTE_SITE = 'git-trip.rubyforge.org:/var/www/gforge-projects/git-trip'
11
+
12
+ # A list of static pages to upload.
13
+ PAGES = %w{
14
+ index.html
15
+ robots.txt
16
+ }
17
+
18
+ namespace :gittrip do
19
+ namespace :site do
20
+ desc 'Clear the local site directory of dynamic files'
21
+ task :clear_local do
22
+ header("Clearing local site directory: #{LOCAL_SITE}")
23
+ sh "rm -rf #{SITE_API}" if File.exists? SITE_API
24
+ sh "rm -rf #{SITE_ISSUES}" if File.exists? SITE_ISSUES
25
+ end
26
+
27
+ # Copies the issue and docs to the site directory.
28
+ task :setup_dir => [ :clear_local, :run_external_tasks ] do
29
+ header('Copying issues and API docs to the site directory.')
30
+ FileUtils.cp_r(API_DOCS, LOCAL_SITE)
31
+ FileUtils.cp_r(ISSUE_DIR, LOCAL_SITE)
32
+ end
33
+
34
+ desc 'Upload the issues and docs to the website'
35
+ task :upload => :setup_dir do
36
+ header('Uploading local site to remote site.')
37
+ sh "cd #{LOCAL_SITE} && scp -r ./* #{REMOTE_SITE}"
38
+ end
39
+
40
+ private
41
+
42
+ # Used to shorten the setup_site_dir task definition.
43
+ task :run_external_tasks do
44
+ Rake::Task['docs:rebuild'].invoke
45
+ Rake::Task['issues:report'].invoke
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,44 @@
1
+ # OverrideRakeTask - http://tools.assembla.com/svn/rails_plugins/override_rake_task/
2
+ Rake::TaskManager.class_eval do
3
+ def remove_task(task_name)
4
+ @tasks.delete(task_name.to_s)
5
+ end
6
+ end
7
+
8
+ def remove_task(task_name)
9
+ Rake.application.remove_task(task_name)
10
+ end
11
+
12
+ def override_task(args, &block)
13
+ name, deps = Rake.application.resolve_args(args)
14
+ remove_task Rake.application[name].name
15
+ task(args, &block)
16
+ end
17
+
18
+
19
+ #
20
+ # Utility methods.
21
+ #
22
+ # Ask for confirmation. Returns true/false
23
+ def confirm(message, options = {})
24
+ confirm_message = options[:confirm_message] || 'Are you sure?'
25
+ banner = options[:banner] || false
26
+ banner ? header(message) : puts("\n#{message}")
27
+ print "#{confirm_message} (yes/no) "
28
+ choice = STDIN.gets.chomp
29
+
30
+ case choice
31
+ when 'yes'
32
+ return true
33
+ else
34
+ puts 'Aborted'
35
+ end
36
+ end
37
+
38
+ # Displays +message+ inside a formatted header.
39
+ def header(message)
40
+ puts "\n"
41
+ puts '+---'
42
+ puts "| #{message}"
43
+ puts '+---'
44
+ end
@@ -0,0 +1,6 @@
1
+ == 0.8.0 / 2008-04-24
2
+ * Lots of fixes and additions
3
+
4
+ == 0.7.0 / 2008-01-07
5
+ * First public release!
6
+
@@ -0,0 +1,53 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ grit.gemspec
6
+ lib/grit.rb
7
+ lib/grit/actor.rb
8
+ lib/grit/blob.rb
9
+ lib/grit/commit.rb
10
+ lib/grit/config.rb
11
+ lib/grit/diff.rb
12
+ lib/grit/errors.rb
13
+ lib/grit/git.rb
14
+ lib/grit/lazy.rb
15
+ lib/grit/ref.rb
16
+ lib/grit/repo.rb
17
+ lib/grit/tree.rb
18
+ test/fixtures/blame
19
+ test/fixtures/cat_file_blob
20
+ test/fixtures/cat_file_blob_size
21
+ test/fixtures/diff_2
22
+ test/fixtures/diff_2f
23
+ test/fixtures/diff_f
24
+ test/fixtures/diff_i
25
+ test/fixtures/diff_mode_only
26
+ test/fixtures/diff_new_mode
27
+ test/fixtures/diff_p
28
+ test/fixtures/for_each_ref
29
+ test/fixtures/for_each_ref_remotes
30
+ test/fixtures/for_each_ref_tags
31
+ test/fixtures/ls_tree_a
32
+ test/fixtures/ls_tree_b
33
+ test/fixtures/ls_tree_commit
34
+ test/fixtures/rev_list
35
+ test/fixtures/rev_list_count
36
+ test/fixtures/rev_list_single
37
+ test/fixtures/rev_parse
38
+ test/fixtures/show_empty_commit
39
+ test/fixtures/simple_config
40
+ test/helper.rb
41
+ test/profile.rb
42
+ test/suite.rb
43
+ test/test_actor.rb
44
+ test/test_blob.rb
45
+ test/test_commit.rb
46
+ test/test_config.rb
47
+ test/test_diff.rb
48
+ test/test_git.rb
49
+ test/test_head.rb
50
+ test/test_reality.rb
51
+ test/test_repo.rb
52
+ test/test_tag.rb
53
+ test/test_tree.rb
@@ -0,0 +1,213 @@
1
+ grit
2
+ by Tom Preston-Werner, Chris Wanstrath
3
+ http://github.com/mojombo/grit
4
+
5
+ == DESCRIPTION:
6
+
7
+ Grit is a Ruby library for extracting information from a git repository in and
8
+ object oriented manner.
9
+
10
+ == REQUIREMENTS:
11
+
12
+ * git (http://git.or.cz) tested with 1.5.3.4
13
+
14
+ == INSTALL:
15
+
16
+ $ gem sources -a http://gems.github.com/ (you only need to do this once)
17
+ $ gem install mojombo-grit
18
+
19
+ == SOURCE:
20
+
21
+ Grit's git repo is available on GitHub, which can be browsed at:
22
+
23
+ http://github.com/mojombo/grit
24
+
25
+ and cloned from:
26
+
27
+ git://github.com/mojombo/grit.git
28
+
29
+ == USAGE:
30
+
31
+ Grit gives you object model access to your git repository. Once you have
32
+ created a repository object, you can traverse it to find parent commit(s),
33
+ trees, blobs, etc.
34
+
35
+ = Initialize a Repo object
36
+
37
+ The first step is to create a Grit::Repo object to represent your repo. I
38
+ include the Grit module so reduce typing.
39
+
40
+ require 'mojombo-grit'
41
+ include Grit
42
+ repo = Repo.new("/Users/tom/dev/grit")
43
+
44
+ In the above example, the directory /Users/tom/dev/grit is my working
45
+ repo and contains the .git directory. You can also initialize Grit with a
46
+ bare repo.
47
+
48
+ repo = Repo.new("/var/git/grit.git")
49
+
50
+ = Getting a list of commits
51
+
52
+ From the Repo object, you can get a list of commits as an array of Commit
53
+ objects.
54
+
55
+ repo.commits
56
+ # => [#<Grit::Commit "e80bbd2ce67651aa18e57fb0b43618ad4baf7750">,
57
+ #<Grit::Commit "91169e1f5fa4de2eaea3f176461f5dc784796769">,
58
+ #<Grit::Commit "038af8c329ef7c1bae4568b98bd5c58510465493">,
59
+ #<Grit::Commit "40d3057d09a7a4d61059bca9dca5ae698de58cbe">,
60
+ #<Grit::Commit "4ea50f4754937bf19461af58ce3b3d24c77311d9">]
61
+
62
+ Called without arguments, Repo#commits returns a list of up to ten commits
63
+ reachable by the master branch (starting at the latest commit). You can ask
64
+ for commits beginning at a different branch, commit, tag, etc.
65
+
66
+ repo.commits('mybranch')
67
+ repo.commits('40d3057d09a7a4d61059bca9dca5ae698de58cbe')
68
+ repo.commits('v0.1')
69
+
70
+ You can specify the maximum number of commits to return.
71
+
72
+ repo.commits('master', 100)
73
+
74
+ If you need paging, you can specify a number of commits to skip.
75
+
76
+ repo.commits('master', 10, 20)
77
+
78
+ The above will return commits 21-30 from the commit list.
79
+
80
+ = The Commit object
81
+
82
+ Commit objects contain information about that commit.
83
+
84
+ head = repo.commits.first
85
+
86
+ head.id
87
+ # => "e80bbd2ce67651aa18e57fb0b43618ad4baf7750"
88
+
89
+ head.parents
90
+ # => [#<Grit::Commit "91169e1f5fa4de2eaea3f176461f5dc784796769">]
91
+
92
+ head.tree
93
+ # => #<Grit::Tree "3536eb9abac69c3e4db583ad38f3d30f8db4771f">
94
+
95
+ head.author
96
+ # => #<Grit::Actor "Tom Preston-Werner <tom@mojombo.com>">
97
+
98
+ head.authored_date
99
+ # => Wed Oct 24 22:02:31 -0700 2007
100
+
101
+ head.committer
102
+ # => #<Grit::Actor "Tom Preston-Werner <tom@mojombo.com>">
103
+
104
+ head.committed_date
105
+ # => Wed Oct 24 22:02:31 -0700 2007
106
+
107
+ head.message
108
+ # => "add Actor inspect"
109
+
110
+ You can traverse a commit's ancestry by chaining calls to #parents.
111
+
112
+ repo.commits.first.parents[0].parents[0].parents[0]
113
+
114
+ The above corresponds to master^^^ or master~3 in git parlance.
115
+
116
+ = The Tree object
117
+
118
+ A tree records pointers to the contents of a directory. Let's say you want
119
+ the root tree of the latest commit on the master branch.
120
+
121
+ tree = repo.commits.first.tree
122
+ # => #<Grit::Tree "3536eb9abac69c3e4db583ad38f3d30f8db4771f">
123
+
124
+ tree.id
125
+ # => "3536eb9abac69c3e4db583ad38f3d30f8db4771f"
126
+
127
+ Once you have a tree, you can get the contents.
128
+
129
+ contents = tree.contents
130
+ # => [#<Grit::Blob "4ebc8aea50e0a67e000ba29a30809d0a7b9b2666">,
131
+ #<Grit::Blob "81d2c27608b352814cbe979a6acd678d30219678">,
132
+ #<Grit::Tree "c3d07b0083f01a6e1ac969a0f32b8d06f20c62e5">,
133
+ #<Grit::Tree "4d00fe177a8407dbbc64a24dbfc564762c0922d8">]
134
+
135
+ This tree contains two Blob objects and two Tree objects. The trees are
136
+ subdirectories and the blobs are files. Trees below the root have additional
137
+ attributes.
138
+
139
+ contents.last.name
140
+ # => "lib"
141
+
142
+ contents.last.mode
143
+ # => "040000"
144
+
145
+ There is a convenience method that allows you to get a named sub-object
146
+ from a tree.
147
+
148
+ tree/"lib"
149
+ # => #<Grit::Tree "e74893a3d8a25cbb1367cf241cc741bfd503c4b2">
150
+
151
+ You can also get a tree directly from the repo if you know its name.
152
+
153
+ repo.tree
154
+ # => #<Grit::Tree "master">
155
+
156
+ repo.tree("91169e1f5fa4de2eaea3f176461f5dc784796769")
157
+ # => #<Grit::Tree "91169e1f5fa4de2eaea3f176461f5dc784796769">
158
+
159
+ = The Blob object
160
+
161
+ A blob represents a file. Trees often contain blobs.
162
+
163
+ blob = tree.contents.first
164
+ # => #<Grit::Blob "4ebc8aea50e0a67e000ba29a30809d0a7b9b2666">
165
+
166
+ A blob has certain attributes.
167
+
168
+ blob.id
169
+ # => "4ebc8aea50e0a67e000ba29a30809d0a7b9b2666"
170
+
171
+ blob.name
172
+ # => "README.txt"
173
+
174
+ blob.mode
175
+ # => "100644"
176
+
177
+ blob.size
178
+ # => 7726
179
+
180
+ You can get the data of a blob as a string.
181
+
182
+ blob.data
183
+ # => "Grit is a library to ..."
184
+
185
+ You can also get a blob directly from the repo if you know its name.
186
+
187
+ repo.blob("4ebc8aea50e0a67e000ba29a30809d0a7b9b2666")
188
+ # => #<Grit::Blob "4ebc8aea50e0a67e000ba29a30809d0a7b9b2666">
189
+
190
+ == LICENSE:
191
+
192
+ (The MIT License)
193
+
194
+ Copyright (c) 2007 Tom Preston-Werner
195
+
196
+ Permission is hereby granted, free of charge, to any person obtaining
197
+ a copy of this software and associated documentation files (the
198
+ 'Software'), to deal in the Software without restriction, including
199
+ without limitation the rights to use, copy, modify, merge, publish,
200
+ distribute, sublicense, and/or sell copies of the Software, and to
201
+ permit persons to whom the Software is furnished to do so, subject to
202
+ the following conditions:
203
+
204
+ The above copyright notice and this permission notice shall be
205
+ included in all copies or substantial portions of the Software.
206
+
207
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
208
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
209
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
210
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
211
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
212
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
213
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.