schleyfox-grit 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/API.txt ADDED
@@ -0,0 +1,101 @@
1
+ == TODO ==
2
+
3
+ * Add remote branch references (Grit::Remote)
4
+ * Add status - what is modified, staged
5
+
6
+ g.checkout('new_branch')
7
+ g.checkout(g.branch('new_branch'))
8
+
9
+ g.branch(name).merge(branch2)
10
+ g.branch(branch2).merge # merges HEAD with branch2
11
+
12
+ g.branch(name).in_branch(message) { # add files } # auto-commits
13
+ g.merge('new_branch')
14
+ g.merge('origin/remote_branch')
15
+ g.merge(b.branch('master'))
16
+ g.merge([branch1, branch2])
17
+
18
+ r = g.add_remote(name, uri) # Git::Remote
19
+ r = g.add_remote(name, Git::Base) # Git::Remote
20
+
21
+ g.remotes # array of Git::Remotes
22
+ g.remote(name).fetch
23
+ g.remote(name).remove
24
+ g.remote(name).merge
25
+ g.remote(name).merge(branch)
26
+
27
+ g.fetch
28
+ g.fetch(g.remotes.first)
29
+
30
+ g.pull
31
+ g.pull(Git::Repo, Git::Branch) # fetch and a merge
32
+
33
+ g.add_tag('tag_name') # returns Git::Tag
34
+
35
+ g.repack
36
+
37
+ g.push
38
+ g.push(g.remote('name'))
39
+
40
+ g.reset # defaults to HEAD
41
+ g.reset_hard(Git::Commit)
42
+
43
+ g.branch('new_branch') # creates new or fetches existing
44
+ g.branch('new_branch').checkout
45
+ g.branch('new_branch').delete
46
+ g.branch('existing_branch').checkout
47
+
48
+
49
+
50
+
51
+
52
+ require 'mojombo-grit'
53
+
54
+ include Grit
55
+ Grit.debug
56
+ Grit.use_pure_ruby
57
+
58
+ repo = Repo.new("/Users/tom/dev/grit")
59
+
60
+ = Commit Log
61
+
62
+ repo.commits('mybranch')
63
+ repo.commits('40d3057d09a7a4d61059bca9dca5ae698de58cbe')
64
+ repo.commits('v0.1')
65
+
66
+ repo.log('mybranch', 100, 20)
67
+
68
+ head = repo.commits.first
69
+ head.id
70
+ # => "e80bbd2ce67651aa18e57fb0b43618ad4baf7750"
71
+ head.parents
72
+ # => [#<Grit::Commit "91169e1f5fa4de2eaea3f176461f5dc784796769">]
73
+ head.tree
74
+ # => #<Grit::Tree "3536eb9abac69c3e4db583ad38f3d30f8db4771f">
75
+ head.author
76
+ # => #<Grit::Actor "Tom Preston-Werner <tom@mojombo.com>">
77
+ head.authored_date
78
+ # => Wed Oct 24 22:02:31 -0700 2007
79
+ head.committer
80
+ # => #<Grit::Actor "Tom Preston-Werner <tom@mojombo.com>">
81
+ head.committed_date
82
+ # => Wed Oct 24 22:02:31 -0700 2007
83
+ head.message
84
+ # => "add Actor inspect"
85
+ contents = tree.contents
86
+ # => [#<Grit::Blob "4ebc8aea50e0a67e000ba29a30809d0a7b9b2666">,
87
+ #<Grit::Blob "81d2c27608b352814cbe979a6acd678d30219678">,
88
+ #<Grit::Tree "c3d07b0083f01a6e1ac969a0f32b8d06f20c62e5">,
89
+ #<Grit::Tree "4d00fe177a8407dbbc64a24dbfc564762c0922d8">]
90
+ blob.id
91
+ # => "4ebc8aea50e0a67e000ba29a30809d0a7b9b2666"
92
+ blob.name
93
+ # => "README.txt"
94
+ blob.mode
95
+ # => "100644"
96
+ blob.size
97
+ # => 7726
98
+ blob.data
99
+
100
+ repo.blob("4ebc8aea50e0a67e000ba29a30809d0a7b9b2666")
101
+ # => #<Grit::Blob "4ebc8aea50e0a67e000ba29a30809d0a7b9b2666">
data/History.txt ADDED
@@ -0,0 +1,117 @@
1
+ == git
2
+ * Major Enhancements
3
+ * Add support for parsing git notes.
4
+ * Add `git cat-file --batch` support with Grit::Repo#batch.
5
+ * Minor Enhancements
6
+ * Grit::Index#commit supports custom committer/author names and dates.
7
+ * Performance enhancements with internal command output buffering.
8
+ * Bug Fixes
9
+ * Zero-Padding issue in Grit::Index was fixed.
10
+
11
+ == 2.3.0 / 2010-09-29
12
+ * Minor Enhancements
13
+ * Add Grit::Repo.init.
14
+ * Bug Fixes
15
+ * Fix Ruby 1.9 compatibility (#24).
16
+
17
+ == 2.2.1 / 2010-08-23
18
+ * Bug Fixes
19
+ * Fix minor regression due to the changed default values in
20
+ Grit::Index#commit.
21
+
22
+ == 2.2.0 / 2010-08-19
23
+ * Minor Enhancements
24
+ * Add Grit::Index#delete to allow deletions of files from the index.
25
+
26
+ == 2.1.0 / 2010-08-04
27
+ * Major Enhancements
28
+ * Add support for parsing annotated tag objects.
29
+ * Add Grit::Repo#recent_tag_name for getting the latest tag name that is
30
+ reachable in a commit.
31
+ * Grit::Diff tracks renames properly if given the :M option.
32
+ * Grit::Commit#diffs and Grit::Commit.diffs both take a git options hash
33
+ that is passed to `git diff`.
34
+ * Minor Enhancements
35
+ * Allow diff to only take one sha
36
+ * Add merge commit diff support
37
+ * Pass along the options to Real Git on a rev-parse miss
38
+ * Raise NoSuchPath with no tree in ls_tree_path
39
+ * Make pure-ruby `ls-tree -r` work with commits
40
+ * Implement select_existing_objects
41
+ * Switch to RakeGem for build management
42
+ * Bug Fixes
43
+ * Add no_quote option for fixing tag listings.
44
+ * Raise custom exceptions on invalid tree objects.
45
+ * Fix Repo#diff (was throwing an error).
46
+
47
+ == 2.0.0 / 2009-10-27
48
+ * Major Enhancements
49
+ * All filesystem calls have been moved into Grit::Git to allow proxying
50
+ * Non-code changes
51
+ * Removed all trailing whitespace in code files
52
+ * Bug Fixes
53
+ * Repo.archive_tar_gz now passes -n option to gzip to be idempotent
54
+ * Fix RubyGit's diff to detect additions and deletions
55
+ [github.com/defunkt]
56
+
57
+ == 1.1.1 / 2009-03-31
58
+ * Changes
59
+ * Don't include test directory in gem package (it's too big)
60
+
61
+ == 1.1.0 / 2009-03-29
62
+ * Backwards breaking changes
63
+ * Diff#a_commit -> Diff#a_blob, Diff#b_commit -> Diff#b_blob
64
+ * Major Enhancments
65
+ * Ruby 1.9 compatibility [github.com/chapados, github.com/js]
66
+ * Minor Enhancements
67
+ * Convert readme to markdown
68
+ * Added a shortcut for commit_stats as Commit#stats [github.com/js]
69
+ * Add a #basename method to Submodule, Blob and Tree for retrieving the
70
+ name [github.com/js]
71
+ * Make Grit::Submodule grasp the concept of non-unix lineendings
72
+ [github.com/js]
73
+ * Added Repo#commit_deltas_from [github.com/js]
74
+ * do some mild shell escaping when running commands [github.com/js]
75
+ * Added two shortcut methods to Tree, for picking trees/blobs only
76
+ [github.com/Voker57]
77
+ * Added <=> method to Blob, needed for sorting tree [github.com/Voker57]
78
+ * Make the number of bytes to be read from git's stdout configurable
79
+ [github.com/josb]
80
+ * Repo.archive_to_file accepts extra parameters making plain zipping
81
+ possible [github.com/darwin]
82
+ * Handle commit stats that summarize commits with binary changes
83
+ [github.com/therealadam]
84
+ * Add a DiffStat class for easy access to diff stats
85
+ [github.com/therealadam]
86
+ * Don't split git logs that contain blank lines into two CommitStats
87
+ [github.com/therealadam]
88
+ * Add DiffStat#net for total change count [github.com/therealadam]
89
+
90
+ == 1.0.3 / 2009-02-13
91
+ * Minor Enhancements
92
+ * Added Grit::Commit#to_patch for plaintext formatted patches.
93
+ * Fixed Grit::Tag to work with annotated tags.
94
+
95
+ == 1.0.2 / 2009-02-10
96
+ * Minor Enhancements
97
+ * Implement Grit.version to use VERSION.yml file
98
+
99
+ == 1.0.1 / 2009-02-10
100
+ * Bug Fixes
101
+ * Add diff-lcs as a dependency
102
+
103
+ == 1.0.0 / 2009-01-27
104
+ * Tons of awesome in here. Also, we suck at updating the history.
105
+ * Let's do better at that from now on.
106
+
107
+ == 0.8.3 / 2008-07-07
108
+ * Capture stderr and log if debug is true (rsanheim)
109
+
110
+ == 0.8.2 / 2008-06-27
111
+ * Allow user provided logger (rsanheim)
112
+
113
+ == 0.8.0 / 2008-04-24
114
+ * Lots of fixes and additions
115
+
116
+ == 0.7.0 / 2008-01-07
117
+ * First public release!
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2007-2009 Tom Preston-Werner
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/PURE_TODO ADDED
@@ -0,0 +1,35 @@
1
+ This is a listing of all the places I can find that Grit actually does a
2
+ 'git' system call. My goal is to add native Ruby versions of all of them.
3
+
4
+ Completed
5
+ ===========================
6
+ ** lib/grit/blob.rb:36: @size ||= @repo.git.cat_file({:s => true}, id).chomp.to_i
7
+ ** lib/grit/blob.rb:43: @data ||= @repo.git.cat_file({:p => true}, id)
8
+ ** lib/grit/tree.rb:16: output = repo.git.ls_tree({}, treeish, *paths)
9
+
10
+
11
+
12
+ lib/grit/commit.rb:74: repo.git.rev_list({}, ref).strip.split("\n").size
13
+ lib/grit/commit.rb:92: output = repo.git.rev_list(actual_options, ref)
14
+ lib/grit/commit.rb:94: output = repo.git.rev_list(actual_options.merge(:all => true))
15
+
16
+
17
+ Next to do
18
+ ===========================
19
+ lib/grit/tag.rb:28: output = repo.git.for_each_ref(actual_options, "refs/tags")
20
+ lib/grit/head.rb:37: output = repo.git.for_each_ref(actual_options, HEAD_PREFIX)
21
+ lib/grit/head.rb:50: self.new($1, repo.git.rev_parse(options, 'HEAD'))
22
+ lib/grit/config.rb:9: @repo.git.config({}, key, value)
23
+ lib/grit/config.rb:40: @repo.git.config(:list => true).split(/\n/)
24
+
25
+
26
+ May not be fast enough
27
+ =============================
28
+ lib/grit/blob.rb:58: data = repo.git.blame({:p => true}, commit, '--', file)
29
+
30
+
31
+ More Difficult
32
+ ===========================
33
+ lib/grit/commit.rb:39: @id_abbrev ||= @repo.git.rev_parse({:short => true}, self.id).chomp
34
+ lib/grit/commit.rb:150: text = repo.git.diff({:full_index => true}, *paths)
35
+ lib/grit/commit.rb:156: diff = @repo.git.show({:full_index => true, :pretty => 'raw'}, @id)
data/README.md ADDED
@@ -0,0 +1,242 @@
1
+ Grit
2
+ ====
3
+
4
+ Grit gives you object oriented read/write access to Git repositories via Ruby.
5
+ The main goals are stability and performance. To this end, some of the
6
+ interactions with Git repositories are done by shelling out to the system's
7
+ `git` command, and other interactions are done with pure Ruby
8
+ reimplementations of core Git functionality. This choice, however, is
9
+ transparent to end users, and you need not know which method is being used.
10
+
11
+ This software was developed to power GitHub, and should be considered
12
+ production ready. An extensive test suite is provided to verify its
13
+ correctness.
14
+
15
+ Grit is maintained by Tom Preston-Werner, Scott Chacon, Chris Wanstrath, and
16
+ PJ Hyett.
17
+
18
+ This documentation is accurate as of Grit 2.3.
19
+
20
+
21
+ ## Requirements
22
+
23
+ * git (http://git-scm.com) tested with 1.7.2.1
24
+
25
+
26
+ ## Install
27
+
28
+ Easiest install is via RubyGems:
29
+
30
+ $ gem install grit
31
+
32
+
33
+ ## Source
34
+
35
+ Grit's Git repo is available on GitHub, which can be browsed at:
36
+
37
+ http://github.com/mojombo/grit
38
+
39
+ and cloned with:
40
+
41
+ git clone git://github.com/mojombo/grit.git
42
+
43
+
44
+ ### Development
45
+
46
+ You will need these gems to get tests to pass:
47
+
48
+ * mocha
49
+
50
+
51
+ ### Contributing
52
+
53
+ If you'd like to hack on Grit, follow these instructions. To get all of the dependencies, install the gem first.
54
+
55
+ 1. Fork the project to your own account
56
+ 1. Clone down your fork
57
+ 1. Create a thoughtfully named topic branch to contain your change
58
+ 1. Hack away
59
+ 1. Add tests and make sure everything still passes by running `rake`
60
+ 1. If you are adding new functionality, document it in README.md
61
+ 1. Do not change the version number, I will do that on my end
62
+ 1. If necessary, rebase your commits into logical chunks, without errors
63
+ 1. Push the branch up to GitHub
64
+ 1. Send a pull request for your branch
65
+
66
+
67
+ ## Usage
68
+
69
+ Grit gives you object model access to your Git repositories. Once you have
70
+ created a `Repo` object, you can traverse it to find parent commits,
71
+ trees, blobs, etc.
72
+
73
+
74
+ ### Initialize a Repo object
75
+
76
+ The first step is to create a `Grit::Repo` object to represent your repo. In
77
+ this documentation I include the `Grit` module to reduce typing.
78
+
79
+ require 'grit'
80
+ repo = Grit::Repo.new("/Users/tom/dev/grit")
81
+
82
+ In the above example, the directory `/Users/tom/dev/grit` is my working
83
+ directory and contains the `.git` directory. You can also initialize Grit with
84
+ a bare repo.
85
+
86
+ repo = Repo.new("/var/git/grit.git")
87
+
88
+
89
+ ### Getting a list of commits
90
+
91
+ From the `Repo` object, you can get a list of commits as an array of `Commit`
92
+ objects.
93
+
94
+ repo.commits
95
+ # => [#<Grit::Commit "e80bbd2ce67651aa18e57fb0b43618ad4baf7750">,
96
+ #<Grit::Commit "91169e1f5fa4de2eaea3f176461f5dc784796769">,
97
+ #<Grit::Commit "038af8c329ef7c1bae4568b98bd5c58510465493">,
98
+ #<Grit::Commit "40d3057d09a7a4d61059bca9dca5ae698de58cbe">,
99
+ #<Grit::Commit "4ea50f4754937bf19461af58ce3b3d24c77311d9">]
100
+
101
+ Called without arguments, `Repo#commits` returns a list of up to ten commits
102
+ reachable by the **master** branch (starting at the latest commit). You can
103
+ ask for commits beginning at a different branch, commit, tag, etc.
104
+
105
+ repo.commits('mybranch')
106
+ repo.commits('40d3057d09a7a4d61059bca9dca5ae698de58cbe')
107
+ repo.commits('v0.1')
108
+
109
+ You can specify the maximum number of commits to return.
110
+
111
+ repo.commits('master', 100)
112
+
113
+ If you need paging, you can specify a number of commits to skip.
114
+
115
+ repo.commits('master', 10, 20)
116
+
117
+ The above will return commits 21-30 from the commit list.
118
+
119
+
120
+ ### The Commit object
121
+
122
+ `Commit` objects contain information about that commit.
123
+
124
+ head = repo.commits.first
125
+
126
+ head.id
127
+ # => "e80bbd2ce67651aa18e57fb0b43618ad4baf7750"
128
+
129
+ head.parents
130
+ # => [#<Grit::Commit "91169e1f5fa4de2eaea3f176461f5dc784796769">]
131
+
132
+ head.tree
133
+ # => #<Grit::Tree "3536eb9abac69c3e4db583ad38f3d30f8db4771f">
134
+
135
+ head.author
136
+ # => #<Grit::Actor "Tom Preston-Werner <tom@mojombo.com>">
137
+
138
+ head.authored_date
139
+ # => Wed Oct 24 22:02:31 -0700 2007
140
+
141
+ head.committer
142
+ # => #<Grit::Actor "Tom Preston-Werner <tom@mojombo.com>">
143
+
144
+ head.committed_date
145
+ # => Wed Oct 24 22:02:31 -0700 2007
146
+
147
+ head.message
148
+ # => "add Actor inspect"
149
+
150
+ You can traverse a commit's ancestry by chaining calls to `#parents`.
151
+
152
+ repo.commits.first.parents[0].parents[0].parents[0]
153
+
154
+ The above corresponds to **master^^^** or **master~3** in Git parlance.
155
+
156
+
157
+ ### The Tree object
158
+
159
+ A tree records pointers to the contents of a directory. Let's say you want
160
+ the root tree of the latest commit on the **master** branch.
161
+
162
+ tree = repo.commits.first.tree
163
+ # => #<Grit::Tree "3536eb9abac69c3e4db583ad38f3d30f8db4771f">
164
+
165
+ tree.id
166
+ # => "3536eb9abac69c3e4db583ad38f3d30f8db4771f"
167
+
168
+ Once you have a tree, you can get the contents.
169
+
170
+ contents = tree.contents
171
+ # => [#<Grit::Blob "4ebc8aea50e0a67e000ba29a30809d0a7b9b2666">,
172
+ #<Grit::Blob "81d2c27608b352814cbe979a6acd678d30219678">,
173
+ #<Grit::Tree "c3d07b0083f01a6e1ac969a0f32b8d06f20c62e5">,
174
+ #<Grit::Tree "4d00fe177a8407dbbc64a24dbfc564762c0922d8">]
175
+
176
+ This tree contains two `Blob` objects and two `Tree` objects. The trees are
177
+ subdirectories and the blobs are files. Trees below the root have additional
178
+ attributes.
179
+
180
+ contents.last.name
181
+ # => "lib"
182
+
183
+ contents.last.mode
184
+ # => "040000"
185
+
186
+ There is a convenience method that allows you to get a named sub-object
187
+ from a tree.
188
+
189
+ tree / "lib"
190
+ # => #<Grit::Tree "e74893a3d8a25cbb1367cf241cc741bfd503c4b2">
191
+
192
+ You can also get a tree directly from the repo if you know its name.
193
+
194
+ repo.tree
195
+ # => #<Grit::Tree "master">
196
+
197
+ repo.tree("91169e1f5fa4de2eaea3f176461f5dc784796769")
198
+ # => #<Grit::Tree "91169e1f5fa4de2eaea3f176461f5dc784796769">
199
+
200
+
201
+ ### The Blob object
202
+
203
+ A blob represents a file. Trees often contain blobs.
204
+
205
+ blob = tree.contents.first
206
+ # => #<Grit::Blob "4ebc8aea50e0a67e000ba29a30809d0a7b9b2666">
207
+
208
+ A blob has certain attributes.
209
+
210
+ blob.id
211
+ # => "4ebc8aea50e0a67e000ba29a30809d0a7b9b2666"
212
+
213
+ blob.name
214
+ # => "README.txt"
215
+
216
+ blob.mode
217
+ # => "100644"
218
+
219
+ blob.size
220
+ # => 7726
221
+
222
+ You can get the data of a blob as a string.
223
+
224
+ blob.data
225
+ # => "Grit is a library to ..."
226
+
227
+ You can also get a blob directly from the repo if you know its name.
228
+
229
+ repo.blob("4ebc8aea50e0a67e000ba29a30809d0a7b9b2666")
230
+ # => #<Grit::Blob "4ebc8aea50e0a67e000ba29a30809d0a7b9b2666">
231
+
232
+
233
+ ### Other
234
+
235
+ There are many more API methods available that are not documented here. Please
236
+ reference the code for more functionality.
237
+
238
+
239
+ Copyright
240
+ ---------
241
+
242
+ Copyright (c) 2010 Tom Preston-Werner. See LICENSE for details.