gitlab-grit 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,163 @@
1
+ == 2.5.0 / 2012-04-22
2
+ * Minor Enhancements
3
+ * 100% Git-compliant actor creation.
4
+ * Handle newlines in author/committer.
5
+ * Grit::Git check_applies/patch related methods take command hash.
6
+ * Tags api now resty.
7
+ * Remove all the grit jruby hacks in favor of updated posix-spawn.
8
+ * Add Grit::Commit#patch_id.
9
+ * Support large packfiles with index v2.
10
+ * Bug Fixes
11
+ * Fix Loose Objects with non-ASCII content in Ruby 1.9
12
+ * Fix bugs in Grit::Repo #objects, #commit_objects, and #diff_objects
13
+ due to passing multiple arguments in a single argv element.
14
+ * ruby rev_list passes --verify to native rev_parse in fallback.
15
+ * Git ls-tree raises on non-zero exit.
16
+
17
+ == 2.4.1 / 2011-01-13
18
+ * Minor Enhancements
19
+ * Grit::Process is used to implement Grit::Git#check_applies,
20
+ Grit::Git#get_patch, and Grit::Git#apply_patch.
21
+
22
+ == 2.4.0 / 2011-01-06
23
+ * Major Enhancements
24
+ * Add support for parsing git notes.
25
+ * Add `git cat-file --batch` support with Grit::Repo#batch.
26
+ * Grit::Process is a custom written external command invocation heavily
27
+ optimized for running git commands quickly and efficiently.
28
+ * Grit::Git#native takes an :input option for piping data into git
29
+ commands
30
+ * Grit::Git#native takes an :env option for setting the git child
31
+ process's
32
+ environment without futsing with the parent's environment.
33
+ * Grit::Git#native takes an :chdir option for setting the current working
34
+ directory (PWD) of the git child process.
35
+ * Grit::Git#native takes an :raise => true option that causes an exception
36
+ to be raised when the git child process exits non-zero.
37
+ * Minor Enhancements
38
+ * Grit::Index#commit supports custom committer/author names and dates.
39
+ * Performance enhancements with internal command output buffering.
40
+ * Reduce fork/execs needed to execute a smoke command from between 3-4
41
+ to 1.
42
+ * Git child processes are now properly parented under the grit Ruby
43
+ process instead of being dropped under init.
44
+ * Bug Fixes
45
+ * Zero-Padding issue in Grit::Index was fixed.
46
+ * Fix issue where Repo#diff skips the first diff (#42)
47
+ * Fix Repo.init_bare for repo names not ending in .git (#40)
48
+ * Fix a variety of process hangs when git stderr output or data written
49
+ to stdin exceeded PIPE_BUF bytes.
50
+
51
+ == 2.3.2 / 2011-01-06
52
+ * Erroneously released. SemVer violation and misc release screwups.
53
+
54
+ == 2.3.1
55
+ * Skipped for unknown reasons.
56
+
57
+ == 2.3.0 / 2010-09-29
58
+ * Minor Enhancements
59
+ * Add Grit::Repo.init.
60
+ * Bug Fixes
61
+ * Fix Ruby 1.9 compatibility (#24).
62
+
63
+ == 2.2.1 / 2010-08-23
64
+ * Bug Fixes
65
+ * Fix minor regression due to the changed default values in
66
+ Grit::Index#commit.
67
+
68
+ == 2.2.0 / 2010-08-19
69
+ * Minor Enhancements
70
+ * Add Grit::Index#delete to allow deletions of files from the index.
71
+
72
+ == 2.1.0 / 2010-08-04
73
+ * Major Enhancements
74
+ * Add support for parsing annotated tag objects.
75
+ * Add Grit::Repo#recent_tag_name for getting the latest tag name that is
76
+ reachable in a commit.
77
+ * Grit::Diff tracks renames properly if given the :M option.
78
+ * Grit::Commit#diffs and Grit::Commit.diffs both take a git options hash
79
+ that is passed to `git diff`.
80
+ * Minor Enhancements
81
+ * Allow diff to only take one sha
82
+ * Add merge commit diff support
83
+ * Pass along the options to Real Git on a rev-parse miss
84
+ * Raise NoSuchPath with no tree in ls_tree_path
85
+ * Make pure-ruby `ls-tree -r` work with commits
86
+ * Implement select_existing_objects
87
+ * Switch to RakeGem for build management
88
+ * Bug Fixes
89
+ * Add no_quote option for fixing tag listings.
90
+ * Raise custom exceptions on invalid tree objects.
91
+ * Fix Repo#diff (was throwing an error).
92
+
93
+ == 2.0.0 / 2009-10-27
94
+ * Major Enhancements
95
+ * All filesystem calls have been moved into Grit::Git to allow proxying
96
+ * Non-code changes
97
+ * Removed all trailing whitespace in code files
98
+ * Bug Fixes
99
+ * Repo.archive_tar_gz now passes -n option to gzip to be idempotent
100
+ * Fix RubyGit's diff to detect additions and deletions
101
+ [github.com/defunkt]
102
+
103
+ == 1.1.1 / 2009-03-31
104
+ * Changes
105
+ * Don't include test directory in gem package (it's too big)
106
+
107
+ == 1.1.0 / 2009-03-29
108
+ * Backwards breaking changes
109
+ * Diff#a_commit -> Diff#a_blob, Diff#b_commit -> Diff#b_blob
110
+ * Major Enhancments
111
+ * Ruby 1.9 compatibility [github.com/chapados, github.com/js]
112
+ * Minor Enhancements
113
+ * Convert readme to markdown
114
+ * Added a shortcut for commit_stats as Commit#stats [github.com/js]
115
+ * Add a #basename method to Submodule, Blob and Tree for retrieving the
116
+ name [github.com/js]
117
+ * Make Grit::Submodule grasp the concept of non-unix lineendings
118
+ [github.com/js]
119
+ * Added Repo#commit_deltas_from [github.com/js]
120
+ * do some mild shell escaping when running commands [github.com/js]
121
+ * Added two shortcut methods to Tree, for picking trees/blobs only
122
+ [github.com/Voker57]
123
+ * Added <=> method to Blob, needed for sorting tree [github.com/Voker57]
124
+ * Make the number of bytes to be read from git's stdout configurable
125
+ [github.com/josb]
126
+ * Repo.archive_to_file accepts extra parameters making plain zipping
127
+ possible [github.com/darwin]
128
+ * Handle commit stats that summarize commits with binary changes
129
+ [github.com/therealadam]
130
+ * Add a DiffStat class for easy access to diff stats
131
+ [github.com/therealadam]
132
+ * Don't split git logs that contain blank lines into two CommitStats
133
+ [github.com/therealadam]
134
+ * Add DiffStat#net for total change count [github.com/therealadam]
135
+
136
+ == 1.0.3 / 2009-02-13
137
+ * Minor Enhancements
138
+ * Added Grit::Commit#to_patch for plaintext formatted patches.
139
+ * Fixed Grit::Tag to work with annotated tags.
140
+
141
+ == 1.0.2 / 2009-02-10
142
+ * Minor Enhancements
143
+ * Implement Grit.version to use VERSION.yml file
144
+
145
+ == 1.0.1 / 2009-02-10
146
+ * Bug Fixes
147
+ * Add diff-lcs as a dependency
148
+
149
+ == 1.0.0 / 2009-01-27
150
+ * Tons of awesome in here. Also, we suck at updating the history.
151
+ * Let's do better at that from now on.
152
+
153
+ == 0.8.3 / 2008-07-07
154
+ * Capture stderr and log if debug is true (rsanheim)
155
+
156
+ == 0.8.2 / 2008-06-27
157
+ * Allow user provided logger (rsanheim)
158
+
159
+ == 0.8.0 / 2008-04-24
160
+ * Lots of fixes and additions
161
+
162
+ == 0.7.0 / 2008-01-07
163
+ * 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,244 @@
1
+ Grit [![build status](https://secure.travis-ci.org/gitlabhq/grit.png)](https://secure.travis-ci.org/gitlabhq/grit)
2
+ ====
3
+
4
+
5
+
6
+ Grit gives you object oriented read/write access to Git repositories via Ruby.
7
+ The main goals are stability and performance. To this end, some of the
8
+ interactions with Git repositories are done by shelling out to the system's
9
+ `git` command, and other interactions are done with pure Ruby
10
+ reimplementations of core Git functionality. This choice, however, is
11
+ transparent to end users, and you need not know which method is being used.
12
+
13
+ This software was developed to power GitHub, and should be considered
14
+ production ready. An extensive test suite is provided to verify its
15
+ correctness.
16
+
17
+ Grit is maintained by Tom Preston-Werner, Scott Chacon, Chris Wanstrath, and
18
+ PJ Hyett.
19
+
20
+ This documentation is accurate as of Grit 2.3.
21
+
22
+
23
+ ## Requirements
24
+
25
+ * git (http://git-scm.com) tested with 1.7.2.1
26
+
27
+
28
+ ## Install
29
+
30
+ Easiest install is via RubyGems:
31
+
32
+ $ gem install grit
33
+
34
+
35
+ ## Source
36
+
37
+ Grit's Git repo is available on GitHub, which can be browsed at:
38
+
39
+ http://github.com/mojombo/grit
40
+
41
+ and cloned with:
42
+
43
+ git clone git://github.com/mojombo/grit.git
44
+
45
+
46
+ ### Development
47
+
48
+ You will need these gems to get tests to pass:
49
+
50
+ * mocha
51
+
52
+
53
+ ### Contributing
54
+
55
+ If you'd like to hack on Grit, follow these instructions. To get all of the dependencies, install the gem first.
56
+
57
+ 1. Fork the project to your own account
58
+ 1. Clone down your fork
59
+ 1. Create a thoughtfully named topic branch to contain your change
60
+ 1. Hack away
61
+ 1. Add tests and make sure everything still passes by running `rake`
62
+ 1. If you are adding new functionality, document it in README.md
63
+ 1. Do not change the version number, I will do that on my end
64
+ 1. If necessary, rebase your commits into logical chunks, without errors
65
+ 1. Push the branch up to GitHub
66
+ 1. Send a pull request for your branch
67
+
68
+
69
+ ## Usage
70
+
71
+ Grit gives you object model access to your Git repositories. Once you have
72
+ created a `Repo` object, you can traverse it to find parent commits,
73
+ trees, blobs, etc.
74
+
75
+
76
+ ### Initialize a Repo object
77
+
78
+ The first step is to create a `Grit::Repo` object to represent your repo. In
79
+ this documentation I include the `Grit` module to reduce typing.
80
+
81
+ require 'grit'
82
+ repo = Grit::Repo.new("/Users/tom/dev/grit")
83
+
84
+ In the above example, the directory `/Users/tom/dev/grit` is my working
85
+ directory and contains the `.git` directory. You can also initialize Grit with
86
+ a bare repo.
87
+
88
+ repo = Repo.new("/var/git/grit.git")
89
+
90
+
91
+ ### Getting a list of commits
92
+
93
+ From the `Repo` object, you can get a list of commits as an array of `Commit`
94
+ objects.
95
+
96
+ repo.commits
97
+ # => [#<Grit::Commit "e80bbd2ce67651aa18e57fb0b43618ad4baf7750">,
98
+ #<Grit::Commit "91169e1f5fa4de2eaea3f176461f5dc784796769">,
99
+ #<Grit::Commit "038af8c329ef7c1bae4568b98bd5c58510465493">,
100
+ #<Grit::Commit "40d3057d09a7a4d61059bca9dca5ae698de58cbe">,
101
+ #<Grit::Commit "4ea50f4754937bf19461af58ce3b3d24c77311d9">]
102
+
103
+ Called without arguments, `Repo#commits` returns a list of up to ten commits
104
+ reachable by the **master** branch (starting at the latest commit). You can
105
+ ask for commits beginning at a different branch, commit, tag, etc.
106
+
107
+ repo.commits('mybranch')
108
+ repo.commits('40d3057d09a7a4d61059bca9dca5ae698de58cbe')
109
+ repo.commits('v0.1')
110
+
111
+ You can specify the maximum number of commits to return.
112
+
113
+ repo.commits('master', 100)
114
+
115
+ If you need paging, you can specify a number of commits to skip.
116
+
117
+ repo.commits('master', 10, 20)
118
+
119
+ The above will return commits 21-30 from the commit list.
120
+
121
+
122
+ ### The Commit object
123
+
124
+ `Commit` objects contain information about that commit.
125
+
126
+ head = repo.commits.first
127
+
128
+ head.id
129
+ # => "e80bbd2ce67651aa18e57fb0b43618ad4baf7750"
130
+
131
+ head.parents
132
+ # => [#<Grit::Commit "91169e1f5fa4de2eaea3f176461f5dc784796769">]
133
+
134
+ head.tree
135
+ # => #<Grit::Tree "3536eb9abac69c3e4db583ad38f3d30f8db4771f">
136
+
137
+ head.author
138
+ # => #<Grit::Actor "Tom Preston-Werner <tom@mojombo.com>">
139
+
140
+ head.authored_date
141
+ # => Wed Oct 24 22:02:31 -0700 2007
142
+
143
+ head.committer
144
+ # => #<Grit::Actor "Tom Preston-Werner <tom@mojombo.com>">
145
+
146
+ head.committed_date
147
+ # => Wed Oct 24 22:02:31 -0700 2007
148
+
149
+ head.message
150
+ # => "add Actor inspect"
151
+
152
+ You can traverse a commit's ancestry by chaining calls to `#parents`.
153
+
154
+ repo.commits.first.parents[0].parents[0].parents[0]
155
+
156
+ The above corresponds to **master^^^** or **master~3** in Git parlance.
157
+
158
+
159
+ ### The Tree object
160
+
161
+ A tree records pointers to the contents of a directory. Let's say you want
162
+ the root tree of the latest commit on the **master** branch.
163
+
164
+ tree = repo.commits.first.tree
165
+ # => #<Grit::Tree "3536eb9abac69c3e4db583ad38f3d30f8db4771f">
166
+
167
+ tree.id
168
+ # => "3536eb9abac69c3e4db583ad38f3d30f8db4771f"
169
+
170
+ Once you have a tree, you can get the contents.
171
+
172
+ contents = tree.contents
173
+ # => [#<Grit::Blob "4ebc8aea50e0a67e000ba29a30809d0a7b9b2666">,
174
+ #<Grit::Blob "81d2c27608b352814cbe979a6acd678d30219678">,
175
+ #<Grit::Tree "c3d07b0083f01a6e1ac969a0f32b8d06f20c62e5">,
176
+ #<Grit::Tree "4d00fe177a8407dbbc64a24dbfc564762c0922d8">]
177
+
178
+ This tree contains two `Blob` objects and two `Tree` objects. The trees are
179
+ subdirectories and the blobs are files. Trees below the root have additional
180
+ attributes.
181
+
182
+ contents.last.name
183
+ # => "lib"
184
+
185
+ contents.last.mode
186
+ # => "040000"
187
+
188
+ There is a convenience method that allows you to get a named sub-object
189
+ from a tree.
190
+
191
+ tree / "lib"
192
+ # => #<Grit::Tree "e74893a3d8a25cbb1367cf241cc741bfd503c4b2">
193
+
194
+ You can also get a tree directly from the repo if you know its name.
195
+
196
+ repo.tree
197
+ # => #<Grit::Tree "master">
198
+
199
+ repo.tree("91169e1f5fa4de2eaea3f176461f5dc784796769")
200
+ # => #<Grit::Tree "91169e1f5fa4de2eaea3f176461f5dc784796769">
201
+
202
+
203
+ ### The Blob object
204
+
205
+ A blob represents a file. Trees often contain blobs.
206
+
207
+ blob = tree.contents.first
208
+ # => #<Grit::Blob "4ebc8aea50e0a67e000ba29a30809d0a7b9b2666">
209
+
210
+ A blob has certain attributes.
211
+
212
+ blob.id
213
+ # => "4ebc8aea50e0a67e000ba29a30809d0a7b9b2666"
214
+
215
+ blob.name
216
+ # => "README.txt"
217
+
218
+ blob.mode
219
+ # => "100644"
220
+
221
+ blob.size
222
+ # => 7726
223
+
224
+ You can get the data of a blob as a string.
225
+
226
+ blob.data
227
+ # => "Grit is a library to ..."
228
+
229
+ You can also get a blob directly from the repo if you know its name.
230
+
231
+ repo.blob("4ebc8aea50e0a67e000ba29a30809d0a7b9b2666")
232
+ # => #<Grit::Blob "4ebc8aea50e0a67e000ba29a30809d0a7b9b2666">
233
+
234
+
235
+ ### Other
236
+
237
+ There are many more API methods available that are not documented here. Please
238
+ reference the code for more functionality.
239
+
240
+
241
+ Copyright
242
+ ---------
243
+
244
+ Copyright (c) 2010 Tom Preston-Werner. See LICENSE for details.