summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README176
-rw-r--r--Rakefile27
-rw-r--r--lib/git.rb7
3 files changed, 210 insertions, 0 deletions
diff --git a/README b/README
new file mode 100644
index 0000000..fa18dc1
--- /dev/null
+++ b/README
@@ -0,0 +1,176 @@
+Git Library for Ruby
+-----------------------------
+
+Git
+Git::Repository
+Git::Index
+Git::WorkingDirectory << Dir
+
+Git::Object
+
+Git::Commit << Git::Object
+Git::Blob
+Git::Tree
+Git::Tag
+
+Git::Author
+Git::Ref
+Git::File (in working dir)
+Git::Log
+Git::Sha
+Git::Diff
+Git::Branch
+Git::Remote << Git::Repository
+
+require 'git'
+
+
+
+# needs read permission only
+
+g = Git.new (working_dir = '.')
+ (git_dir, index_file)
+
+g.index
+g.index.readable?
+g.index.writable?
+g.repo
+g.dir
+
+g.log # returns array of Git::Commit objects
+g.log.stat
+g.log.stat.summary
+g.log.since('2 weeks ago')
+g.log.between('v2.5', 'v2.6')
+g.log('Makefile').since('v2.5')
+
+g.status
+
+g.diff
+g.diff_cached
+g.diff(commit1, commit2)
+g.diff("commit1..commit2")
+
+g.file('flim/ChangeLog').tags.each {|tag,rev| p [tag,rev.to_s]}
+g.file('flim/ChangeLog').logs.each { |log| log.sha }
+
+g.branches # returns Git::Branch objects
+g.branches.local
+g.branches.remote
+
+g.show(Git::Sha)
+g.show('HEAD^')
+g.show('HEAD^', Git::File)
+g.show(Git::Object)
+
+g.rev_parse('HEAD^')
+g.rev_parse('v2.5:Makefile') # returns Git::Object
+
+g.grep('hello')
+g.grep('hello', Git::Tag)
+
+g.ls_files
+g.ls_files(:stage => true)
+
+g.diff_tree(Git::Tree, Git::Tree)
+
+g.tag # returns array of Git::Tag objects
+
+c = Git::Commit.new("HEAD^^")
+c = Git::Commit.new("394839")
+
+
+# needs write permission
+
+g = Git.clone(URI, 'name', working_dir = GIT_DIR, {options})
+ (username, password, ssl_key, git_dir, index_file)
+
+g = Git.init
+ Git.init('project')
+ Git.init('/home/schacon/proj',
+ { :git_dir => '/opt/git/proj.git',
+ :index_file => '/tmp/index'} )
+
+
+
+g.config('user.name', 'Scott Chacon')
+g.config('user.email', 'email@email.com')
+g.config('user.name') # returns 'Scott Chacon'
+g.config # returns whole config hash
+
+g.add('.')
+g.add([file1, file2])
+
+g.remove('file.txt').and_file
+
+g.commit('message')
+g.commit_a('message')
+
+g.reset # defaults to HEAD
+g.reset_hard(Git::Commit)
+
+g.branch('new_branch')
+g.branch('new_branch').delete
+
+g.checkout('new_branch')
+g.checkout('new_branch', :create_branch => true)
+g.checkout_b('new_branch')
+
+g.merge('new_branch')
+g.merge(Git::Branch)
+g.merge(Git::Branch, Git::Branch)
+
+g.fetch
+g.fetch(Git::Repo)
+
+g.pull
+g.pull(Git::Repo, Git::Branch) # fetch and a merge
+
+g.tag('tag_name') # returns Git::Tag
+
+g.pack
+
+
+
+Git::Object
+ - sha
+ - type
+ - cat_file
+ - raw
+
+Git::Commit
+ - tree
+ - parent
+ - author # git author
+ - author_date
+ - committer # git author
+ - committer_date / date
+ - message
+
+Git::Tree
+ - children
+ - blobs/files
+ - subtrees/subdirs
+
+Git::Blob << File
+ - size
+ - permissions
+
+Git::Tag
+
+Git::Hash
+ - abbrev/short
+
+Git::Repository
+ - heads
+ - refs
+ - branches
+
+Git::WorkingDirectory
+ - foreach
+ - glob # returns Git::Files
+
+Git::File << File
+ - log
+ - tags
+
diff --git a/Rakefile b/Rakefile
new file mode 100644
index 0000000..24ff322
--- /dev/null
+++ b/Rakefile
@@ -0,0 +1,27 @@
+require 'rubygems'
+Gem::manage_gems
+require 'rake/gempackagetask'
+
+spec = Gem::Specification.new do |s|
+ s.platform = Gem::Platform::RUBY
+ s.name = "git"
+ s.version = "0.1.1"
+ s.author = "Scott Chacon"
+ s.email = "schacon@gmail.com"
+ s.summary = "A package for using Git in Ruby code."
+ s.files = FileList['lib/*.rb', 'test/*'].to_a
+ s.require_path = "lib"
+ s.autorequire = "git"
+ s.test_files = Dir.glob('tests/*.rb')
+ s.has_rdoc = true
+ s.extra_rdoc_files = ["README"]
+end
+
+Rake::GemPackageTask.new(spec) do |pkg|
+ pkg.need_tar = true
+end
+
+task :default => "pkg/#{spec.name}-#{spec.version}.gem" do
+ puts "generated latest version"
+end
+
diff --git a/lib/git.rb b/lib/git.rb
new file mode 100644
index 0000000..8d5c79f
--- /dev/null
+++ b/lib/git.rb
@@ -0,0 +1,7 @@
+
+# Add the directory containing this file to the start of the load path if it
+# isn't there already.
+$:.unshift(File.dirname(__FILE__)) unless
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
+
+