forked from ruby-git/ruby-git
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
started the ruby-only command line git client
- Loading branch information
scott Chacon
committed
Nov 23, 2007
1 parent
f1366b3
commit 3fddf30
Showing
4 changed files
with
88 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters