summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorscott Chacon <schacon@agadorsparticus.(none)>2007-11-23 11:50:02 -0800
committerscott Chacon <schacon@agadorsparticus.(none)>2007-11-23 11:50:02 -0800
commit3fddf300bd33b356540bee50ae17590ea9b61341 (patch)
tree8b17ce067dd67dc418ed06d023505523f243cb90 /bin
parentf1366b39891402b0db9de661ad181089bfd79053 (diff)
downloadthird_party-ruby-git-3fddf300bd33b356540bee50ae17590ea9b61341.zip
third_party-ruby-git-3fddf300bd33b356540bee50ae17590ea9b61341.tar.gz
third_party-ruby-git-3fddf300bd33b356540bee50ae17590ea9b61341.tar.xz
started the ruby-only command line git client
Diffstat (limited to 'bin')
-rwxr-xr-xbin/gitr69
1 files changed, 69 insertions, 0 deletions
diff --git a/bin/gitr b/bin/gitr
new file mode 100755
index 0000000..53c8055
--- /dev/null
+++ b/bin/gitr
@@ -0,0 +1,69 @@
+#!/usr/bin/env ruby
+
+# This is a command line client that can do a number of read operations
+# on a git repository in pure ruby. This may be helpful if you have access
+# to a computer that has no C compiler but you want to do some git stuff
+# on it. It's also helpful for me to test Git stuff with.
+#
+# author : Scott Chacon (schacon@gmail.com)
+#
+# todo:
+# add --git-dir
+# add --log-file
+# add --help
+
+#require 'lib/git'
+require 'rubygems'
+require 'git'
+require 'logger'
+
+command = ARGV[0]
+
+if !command
+ puts 'You have to provide a command'
+ puts 'usage: gitr (command) [args]'
+ puts
+ puts 'commands: log'
+ puts ' log-shas'
+ puts ' cat-file'
+ puts ' rev-parse'
+ puts ' branches'
+ puts ' config'
+ exit
+end
+
+git_dir = ENV['GIT_DIR'] || '.git'
+@git = Git.bare(git_dir, :log => Logger.new(STDOUT))
+
+case command
+when 'log'
+ # gitr log
+ @git.log.each do |l|
+ puts 'commit ' + l.sha
+ puts l.contents
+ puts
+ end
+when 'log-shas'
+ # gitr log-shas
+ puts @git.log
+when 'cat-file'
+ # gitr cat-file
+ puts @git.cat_file(ARGV[1])
+when 'rev-parse'
+ # gitr rev-parse
+ puts @git.revparse(ARGV[1])
+when 'branches'
+ # gitr branches
+ puts @git.branches
+when 'config'
+ # gitr config
+ @git.config.sort.each do |k,v|
+ puts "#{k} : #{v}"
+ end
+end
+
+# gitr ls-tree
+# gitr pack-browse
+
+# gitr diff / stats ?
+# output in yaml? \ No newline at end of file