Skip to content

Commit 646304a

Browse files
author
scott Chacon
committed
added documentation and a license file
1 parent 31b4f2b commit 646304a

File tree

201 files changed

+12707
-179
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

201 files changed

+12707
-179
lines changed

EXAMPLES

Lines changed: 131 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -1,131 +1,131 @@
1-
require 'git'
2-
3-
# needs read permission only
4-
5-
g = Git.open (working_dir = '.')
6-
(git_dir, index_file)
7-
8-
g.index
9-
g.index.readable?
10-
g.index.writable?
11-
g.repo
12-
g.dir
13-
14-
g.log # returns array of Git::Commit objects
15-
g.log.since('2 weeks ago')
16-
g.log.between('v2.5', 'v2.6')
17-
g.log.each {|l| puts l.sha }
18-
g.gblob('v2.5:Makefile').log.since('2 weeks ago')
19-
20-
g.object('HEAD^').to_s # git show / git rev-parse
21-
g.object('HEAD^').contents
22-
g.object('v2.5:Makefile').size
23-
g.object('v2.5:Makefile').sha
24-
25-
g.gtree(treeish)
26-
g.gblob(treeish)
27-
g.gcommit(treeish)
28-
29-
g.revparse('v2.5:Makefile')
30-
31-
g.branches # returns Git::Branch objects
32-
g.branches.local
33-
g.branches.remote
34-
g.branches[:master].gcommit
35-
g.branches['origin/master'].gcommit
36-
37-
g.grep('hello') # implies HEAD
38-
g.blob('v2.5:Makefile').grep('hello')
39-
g.tag('v2.5').grep('hello', 'docs/')
40-
41-
g.diff(commit1, commit2).size
42-
g.diff(commit1, commit2).stats
43-
g.gtree('v2.5').diff('v2.6').insertions
44-
g.diff('gitsearch1', 'v2.5').path('lib/')
45-
g.diff('gitsearch1', @git.gtree('v2.5'))
46-
g.diff('gitsearch1', 'v2.5').path('docs/').patch
47-
g.gtree('v2.5').diff('v2.6').patch
48-
49-
g.gtree('v2.5').diff('v2.6').each do |file_diff|
50-
puts file_diff.path
51-
puts file_diff.patch
52-
puts file_diff.blob(:src).contents
53-
end
54-
55-
g.config('user.name') # returns 'Scott Chacon'
56-
g.config # returns whole config hash
57-
58-
g.tag # returns array of Git::Tag objects
59-
60-
61-
62-
# needs write permission
63-
64-
65-
g = Git.init
66-
Git.init('project')
67-
Git.init('/home/schacon/proj',
68-
{ :git_dir => '/opt/git/proj.git',
69-
:index_file => '/tmp/index'} )
70-
71-
g = Git.clone(URI, :name => 'name', :path => '/tmp/checkout'
72-
(git_dir, index_file)
73-
74-
g.config('user.name', 'Scott Chacon')
75-
g.config('user.email', 'email@email.com')
76-
77-
g.add('.')
78-
g.add([file1, file2])
79-
80-
g.remove('file.txt')
81-
g.remove(['file.txt', 'file2.txt'])
82-
83-
g.commit('message')
84-
g.commit_all('message')
85-
86-
g = Git.clone(repo, 'myrepo')
87-
Dir.chdir('myrepo') do
88-
new_file('test-file', 'blahblahblah')
89-
g.status.untracked.each do |file|
90-
puts file.blob(:index).contents
91-
end
92-
end
93-
94-
g.reset # defaults to HEAD
95-
g.reset_hard(Git::Commit)
96-
97-
g.branch('new_branch') # creates new or fetches existing
98-
g.branch('new_branch').checkout
99-
g.branch('new_branch').delete
100-
g.branch('existing_branch').checkout
101-
102-
g.checkout('new_branch')
103-
g.checkout(g.branch('new_branch'))
104-
105-
g.branch(name).merge(branch2)
106-
g.branch(branch2).merge # merges HEAD with branch2
107-
108-
g.branch(name).in_branch(message) { # add files } # auto-commits
109-
g.merge('new_branch')
110-
g.merge('origin/remote_branch')
111-
g.merge(b.branch('master'))
112-
g.merge([branch1, branch2])
113-
114-
r = g.add_remote(name, uri) # Git::Remote
115-
r = g.add_remote(name, Git::Base) # Git::Remote
116-
117-
g.remotes # array of Git::Remotes
118-
g.remote(name).fetch
119-
g.remote(name).remove
120-
g.remote(name).merge
121-
g.remote(name).merge(branch)
122-
123-
g.fetch
124-
g.fetch(g.remotes.first)
125-
126-
g.pull
127-
g.pull(Git::Repo, Git::Branch) # fetch and a merge
128-
129-
g.add_tag('tag_name') # returns Git::Tag
130-
131-
g.repack
1+
require 'git'
2+
3+
# needs read permission only
4+
5+
g = Git.open (working_dir = '.')
6+
(git_dir, index_file)
7+
8+
g.index
9+
g.index.readable?
10+
g.index.writable?
11+
g.repo
12+
g.dir
13+
14+
g.log # returns array of Git::Commit objects
15+
g.log.since('2 weeks ago')
16+
g.log.between('v2.5', 'v2.6')
17+
g.log.each {|l| puts l.sha }
18+
g.gblob('v2.5:Makefile').log.since('2 weeks ago')
19+
20+
g.object('HEAD^').to_s # git show / git rev-parse
21+
g.object('HEAD^').contents
22+
g.object('v2.5:Makefile').size
23+
g.object('v2.5:Makefile').sha
24+
25+
g.gtree(treeish)
26+
g.gblob(treeish)
27+
g.gcommit(treeish)
28+
29+
g.revparse('v2.5:Makefile')
30+
31+
g.branches # returns Git::Branch objects
32+
g.branches.local
33+
g.branches.remote
34+
g.branches[:master].gcommit
35+
g.branches['origin/master'].gcommit
36+
37+
g.grep('hello') # implies HEAD
38+
g.blob('v2.5:Makefile').grep('hello')
39+
g.tag('v2.5').grep('hello', 'docs/')
40+
41+
g.diff(commit1, commit2).size
42+
g.diff(commit1, commit2).stats
43+
g.gtree('v2.5').diff('v2.6').insertions
44+
g.diff('gitsearch1', 'v2.5').path('lib/')
45+
g.diff('gitsearch1', @git.gtree('v2.5'))
46+
g.diff('gitsearch1', 'v2.5').path('docs/').patch
47+
g.gtree('v2.5').diff('v2.6').patch
48+
49+
g.gtree('v2.5').diff('v2.6').each do |file_diff|
50+
puts file_diff.path
51+
puts file_diff.patch
52+
puts file_diff.blob(:src).contents
53+
end
54+
55+
g.config('user.name') # returns 'Scott Chacon'
56+
g.config # returns whole config hash
57+
58+
g.tag # returns array of Git::Tag objects
59+
60+
61+
62+
# needs write permission
63+
64+
65+
g = Git.init
66+
Git.init('project')
67+
Git.init('/home/schacon/proj',
68+
{ :git_dir => '/opt/git/proj.git',
69+
:index_file => '/tmp/index'} )
70+
71+
g = Git.clone(URI, :name => 'name', :path => '/tmp/checkout'
72+
(git_dir, index_file)
73+
74+
g.config('user.name', 'Scott Chacon')
75+
g.config('user.email', 'email@email.com')
76+
77+
g.add('.')
78+
g.add([file1, file2])
79+
80+
g.remove('file.txt')
81+
g.remove(['file.txt', 'file2.txt'])
82+
83+
g.commit('message')
84+
g.commit_all('message')
85+
86+
g = Git.clone(repo, 'myrepo')
87+
Dir.chdir('myrepo') do
88+
new_file('test-file', 'blahblahblah')
89+
g.status.untracked.each do |file|
90+
puts file.blob(:index).contents
91+
end
92+
end
93+
94+
g.reset # defaults to HEAD
95+
g.reset_hard(Git::Commit)
96+
97+
g.branch('new_branch') # creates new or fetches existing
98+
g.branch('new_branch').checkout
99+
g.branch('new_branch').delete
100+
g.branch('existing_branch').checkout
101+
102+
g.checkout('new_branch')
103+
g.checkout(g.branch('new_branch'))
104+
105+
g.branch(name).merge(branch2)
106+
g.branch(branch2).merge # merges HEAD with branch2
107+
108+
g.branch(name).in_branch(message) { # add files } # auto-commits
109+
g.merge('new_branch')
110+
g.merge('origin/remote_branch')
111+
g.merge(b.branch('master'))
112+
g.merge([branch1, branch2])
113+
114+
r = g.add_remote(name, uri) # Git::Remote
115+
r = g.add_remote(name, Git::Base) # Git::Remote
116+
117+
g.remotes # array of Git::Remotes
118+
g.remote(name).fetch
119+
g.remote(name).remove
120+
g.remote(name).merge
121+
g.remote(name).merge(branch)
122+
123+
g.fetch
124+
g.fetch(g.remotes.first)
125+
126+
g.pull
127+
g.pull(Git::Repo, Git::Branch) # fetch and a merge
128+
129+
g.add_tag('tag_name') # returns Git::Tag
130+
131+
g.repack

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License
2+
3+
Copyright (c) <year> <copyright holders>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
Git Library for Ruby
2-
-----------------------------
1+
== Git Library for Ruby
2+
3+
= What it is
34

45
Library for using Git in Ruby.
56

7+
= Roadmap
8+
69
Right now I'm forking calls to the 'git' binary,
710
but eventually I'll replace that with either C bindings
811
to libgit or libgit-thin, or I'll write pure ruby
@@ -11,46 +14,3 @@ handlers for at least some of the Git stuff.
1114
See EXAMPLES file for, well, examples.
1215

1316

14-
15-
Git::Object
16-
- sha
17-
- type
18-
- cat_file
19-
- raw
20-
21-
Git::Commit
22-
- tree
23-
- parent
24-
- author # git author
25-
- author_date
26-
- committer # git author
27-
- committer_date / date
28-
- message
29-
30-
Git::Tree
31-
- children
32-
- blobs/files
33-
- subtrees/subdirs
34-
35-
Git::Blob << File
36-
- size
37-
- permissions
38-
39-
Git::Tag
40-
41-
Git::Hash
42-
- abbrev/short
43-
44-
Git::Repository
45-
- heads
46-
- refs
47-
- branches
48-
49-
Git::WorkingDirectory
50-
- foreach
51-
- glob # returns Git::Files
52-
53-
Git::File << File
54-
- log
55-
- tags
56-

Rakefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ require 'rake/gempackagetask'
55
spec = Gem::Specification.new do |s|
66
s.platform = Gem::Platform::RUBY
77
s.name = "git"
8-
s.version = "0.1.1"
8+
s.version = "1.0.0"
99
s.author = "Scott Chacon"
1010
s.email = "schacon@gmail.com"
1111
s.summary = "A package for using Git in Ruby code."
@@ -25,6 +25,11 @@ task :default => "pkg/#{spec.name}-#{spec.version}.gem" do
2525
puts "generated latest version"
2626
end
2727

28+
desc "Regenerate Documentation"
29+
task :doc do |t|
30+
system('rdoc lib/ README EXAMPLES --main README --inline-source')
31+
end
32+
2833
desc "Run Unit Tests"
2934
task :test do |t|
3035
require File.dirname(__FILE__) + '/tests/all_tests.rb'

0 commit comments

Comments
 (0)