p-mongo-git 1.8.1

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/README.md ADDED
@@ -0,0 +1,344 @@
1
+ <!--
2
+ # @markup markdown
3
+ # @title README
4
+ -->
5
+
6
+ # The Git Gem
7
+
8
+ The Git Gem provides an API that can be used to create, read, and manipulate
9
+ Git repositories by wrapping system calls to the `git` binary. The API can be
10
+ used for working with Git in complex interactions including branching and
11
+ merging, object inspection and manipulation, history, patch generation and
12
+ more.
13
+
14
+ ## Homepage
15
+
16
+ The project source code is at:
17
+
18
+ http://github.com/ruby-git/ruby-git
19
+
20
+ ## Documentation
21
+
22
+ Detailed documentation can be found at:
23
+
24
+ https://rubydoc.info/gems/git/Git.html
25
+
26
+ Get started by obtaining a repository object by:
27
+
28
+ * opening an existing working copy with [Git.open](https://rubydoc.info/gems/git/Git#open-class_method)
29
+ * initializing a new repository with [Git.init](https://rubydoc.info/gems/git/Git#init-class_method)
30
+ * cloning a repository with [Git.clone](https://rubydoc.info/gems/git/Git#clone-class_method)
31
+
32
+ Methods that can be called on a repository object are documented in [Git::Base](https://rubydoc.info/gems/git/Git/Base)
33
+
34
+ ## Install
35
+
36
+ You can install Ruby/Git like this:
37
+
38
+ ```
39
+ sudo gem install git
40
+ ```
41
+
42
+ ## Code Status
43
+
44
+ * [![Build Status](https://github.com/ruby-git/ruby-git/workflows/CI/badge.svg?branch=master)](https://github.com/ruby-git/ruby-git/actions?query=workflow%3ACI)
45
+ * [![Code Climate](https://codeclimate.com/github/ruby-git/ruby-git.png)](https://codeclimate.com/github/ruby-git/ruby-git)
46
+ * [![Gem Version](https://badge.fury.io/rb/git.svg)](https://badge.fury.io/rb/git)
47
+
48
+ ## Major Objects
49
+
50
+ **Git::Base** - The object returned from a `Git.open` or `Git.clone`. Most major actions are called from this object.
51
+
52
+ **Git::Object** - The base object for your tree, blob and commit objects, returned from `@git.gtree` or `@git.object` calls. the `Git::AbstractObject` will have most of the calls in common for all those objects.
53
+
54
+ **Git::Diff** - returns from a `@git.diff` command. It is an Enumerable that returns `Git::Diff:DiffFile` objects from which you can get per file patches and insertion/deletion statistics. You can also get total statistics from the Git::Diff object directly.
55
+
56
+ **Git::Status** - returns from a `@git.status` command. It is an Enumerable that returns
57
+ `Git:Status::StatusFile` objects for each object in git, which includes files in the working
58
+ directory, in the index and in the repository. Similar to running 'git status' on the command line to determine untracked and changed files.
59
+
60
+ **Git::Branches** - Enumerable object that holds `Git::Branch objects`. You can call .local or .remote on it to filter to just your local or remote branches.
61
+
62
+ **Git::Remote**- A reference to a remote repository that is tracked by this repository.
63
+
64
+ **Git::Log** - An Enumerable object that references all the `Git::Object::Commit` objects that encompass your log query, which can be constructed through methods on the `Git::Log object`,
65
+ like:
66
+
67
+ `@git.log(20).object("some_file").since("2 weeks ago").between('v2.6', 'v2.7').each { |commit| [block] }`
68
+
69
+ **Git::Worktrees** - Enumerable object that holds `Git::Worktree objects`.
70
+
71
+ ## Examples
72
+
73
+ Here are a bunch of examples of how to use the Ruby/Git package.
74
+
75
+ Ruby < 1.9 will require rubygems to be loaded.
76
+
77
+ ```ruby
78
+ require 'rubygems'
79
+ ```
80
+
81
+ Require the 'git' gem.
82
+ ```ruby
83
+ require 'git'
84
+ ```
85
+
86
+ Git env config
87
+
88
+ ```ruby
89
+ Git.configure do |config|
90
+ # If you want to use a custom git binary
91
+ config.binary_path = '/git/bin/path'
92
+
93
+ # If you need to use a custom SSH script
94
+ config.git_ssh = '/path/to/ssh/script'
95
+ end
96
+ ```
97
+
98
+ _NOTE: Another way to specify where is the `git` binary is through the environment variable `GIT_PATH`_
99
+
100
+ Here are the operations that need read permission only.
101
+
102
+ ```ruby
103
+ g = Git.open(working_dir, :log => Logger.new(STDOUT))
104
+
105
+ g.index
106
+ g.index.readable?
107
+ g.index.writable?
108
+ g.repo
109
+ g.dir
110
+
111
+ g.log # returns array of Git::Commit objects
112
+ g.log.since('2 weeks ago')
113
+ g.log.between('v2.5', 'v2.6')
114
+ g.log.each {|l| puts l.sha }
115
+ g.gblob('v2.5:Makefile').log.since('2 weeks ago')
116
+
117
+ g.object('HEAD^').to_s # git show / git rev-parse
118
+ g.object('HEAD^').contents
119
+ g.object('v2.5:Makefile').size
120
+ g.object('v2.5:Makefile').sha
121
+
122
+ g.gtree(treeish)
123
+ g.gblob(treeish)
124
+ g.gcommit(treeish)
125
+
126
+
127
+ commit = g.gcommit('1cc8667014381')
128
+
129
+ commit.gtree
130
+ commit.parent.sha
131
+ commit.parents.size
132
+ commit.author.name
133
+ commit.author.email
134
+ commit.author.date.strftime("%m-%d-%y")
135
+ commit.committer.name
136
+ commit.date.strftime("%m-%d-%y")
137
+ commit.message
138
+
139
+ tree = g.gtree("HEAD^{tree}")
140
+
141
+ tree.blobs
142
+ tree.subtrees
143
+ tree.children # blobs and subtrees
144
+
145
+ g.revparse('v2.5:Makefile')
146
+
147
+ g.branches # returns Git::Branch objects
148
+ g.branches.local
149
+ g.branches.remote
150
+ g.branches[:master].gcommit
151
+ g.branches['origin/master'].gcommit
152
+
153
+ g.grep('hello') # implies HEAD
154
+ g.blob('v2.5:Makefile').grep('hello')
155
+ g.tag('v2.5').grep('hello', 'docs/')
156
+ g.describe()
157
+ g.describe('0djf2aa')
158
+ g.describe('HEAD', {:all => true, :tags => true})
159
+
160
+ g.diff(commit1, commit2).size
161
+ g.diff(commit1, commit2).stats
162
+ g.diff(commit1, commit2).name_status
163
+ g.gtree('v2.5').diff('v2.6').insertions
164
+ g.diff('gitsearch1', 'v2.5').path('lib/')
165
+ g.diff('gitsearch1', @git.gtree('v2.5'))
166
+ g.diff('gitsearch1', 'v2.5').path('docs/').patch
167
+ g.gtree('v2.5').diff('v2.6').patch
168
+
169
+ g.gtree('v2.5').diff('v2.6').each do |file_diff|
170
+ puts file_diff.path
171
+ puts file_diff.patch
172
+ puts file_diff.blob(:src).contents
173
+ end
174
+
175
+ g.worktrees # returns Git::Worktree objects
176
+ g.worktrees.count
177
+ g.worktrees.each do |worktree|
178
+ worktree.dir
179
+ worktree.gcommit
180
+ worktree.to_s
181
+ end
182
+
183
+ g.config('user.name') # returns 'Scott Chacon'
184
+ g.config # returns whole config hash
185
+
186
+ g.tags # returns array of Git::Tag objects
187
+
188
+ g.show()
189
+ g.show('HEAD')
190
+ g.show('v2.8', 'README.md')
191
+
192
+ Git.ls_remote('https://github.com/ruby-git/ruby-git.git') # returns a hash containing the available references of the repo.
193
+ Git.ls_remote('/path/to/local/repo')
194
+ Git.ls_remote() # same as Git.ls_remote('.')
195
+ ```
196
+
197
+ And here are the operations that will need to write to your git repository.
198
+
199
+ ```ruby
200
+ g = Git.init
201
+ Git.init('project')
202
+ Git.init('/home/schacon/proj',
203
+ { :repository => '/opt/git/proj.git',
204
+ :index => '/tmp/index'} )
205
+
206
+ g = Git.clone(URI, NAME, :path => '/tmp/checkout')
207
+ g.config('user.name', 'Scott Chacon')
208
+ g.config('user.email', 'email@email.com')
209
+
210
+ # Clone can take an optional logger
211
+ logger = Logger.new
212
+ g = Git.clone(URI, NAME, :log => logger)
213
+
214
+ g.add # git add -- "."
215
+ g.add(:all=>true) # git add --all -- "."
216
+ g.add('file_path') # git add -- "file_path"
217
+ g.add(['file_path_1', 'file_path_2']) # git add -- "file_path_1" "file_path_2"
218
+
219
+ g.remove() # git rm -f -- "."
220
+ g.remove('file.txt') # git rm -f -- "file.txt"
221
+ g.remove(['file.txt', 'file2.txt']) # git rm -f -- "file.txt" "file2.txt"
222
+ g.remove('file.txt', :recursive => true) # git rm -f -r -- "file.txt"
223
+ g.remove('file.txt', :cached => true) # git rm -f --cached -- "file.txt"
224
+
225
+ g.commit('message')
226
+ g.commit_all('message')
227
+
228
+ g = Git.clone(repo, 'myrepo')
229
+ g.chdir do
230
+ new_file('test-file', 'blahblahblah')
231
+ g.status.changed.each do |file|
232
+ puts file.blob(:index).contents
233
+ end
234
+ end
235
+
236
+ g.reset # defaults to HEAD
237
+ g.reset_hard(Git::Commit)
238
+
239
+ g.branch('new_branch') # creates new or fetches existing
240
+ g.branch('new_branch').checkout
241
+ g.branch('new_branch').delete
242
+ g.branch('existing_branch').checkout
243
+ g.branch('master').contains?('existing_branch')
244
+
245
+ g.checkout('new_branch')
246
+ g.checkout(g.branch('new_branch'))
247
+
248
+ g.branch(name).merge(branch2)
249
+ g.branch(branch2).merge # merges HEAD with branch2
250
+
251
+ g.branch(name).in_branch(message) { # add files } # auto-commits
252
+ g.merge('new_branch')
253
+ g.merge('new_branch', 'merge commit message', no_ff: true)
254
+ g.merge('origin/remote_branch')
255
+ g.merge(g.branch('master'))
256
+ g.merge([branch1, branch2])
257
+
258
+ g.merge_base('branch1', 'branch2')
259
+
260
+ r = g.add_remote(name, uri) # Git::Remote
261
+ r = g.add_remote(name, Git::Base) # Git::Remote
262
+
263
+ g.remotes # array of Git::Remotes
264
+ g.remote(name).fetch
265
+ g.remote(name).remove
266
+ g.remote(name).merge
267
+ g.remote(name).merge(branch)
268
+
269
+ g.fetch
270
+ g.fetch(g.remotes.first)
271
+ g.fetch('origin', {:ref => 'some/ref/head'} )
272
+
273
+ g.pull
274
+ g.pull(Git::Repo, Git::Branch) # fetch and a merge
275
+
276
+ g.add_tag('tag_name') # returns Git::Tag
277
+ g.add_tag('tag_name', 'object_reference')
278
+ g.add_tag('tag_name', 'object_reference', {:options => 'here'})
279
+ g.add_tag('tag_name', {:options => 'here'})
280
+
281
+ Options:
282
+ :a | :annotate
283
+ :d
284
+ :f
285
+ :m | :message
286
+ :s
287
+
288
+ g.delete_tag('tag_name')
289
+
290
+ g.repack
291
+
292
+ g.push
293
+ g.push(g.remote('name'))
294
+
295
+ g.worktree('/tmp/new_worktree').add
296
+ g.worktree('/tmp/new_worktree', 'branch1').add
297
+ g.worktree('/tmp/new_worktree').remove
298
+ g.worktrees.prune
299
+ ```
300
+
301
+ Some examples of more low-level index and tree operations
302
+
303
+ ```ruby
304
+ g.with_temp_index do
305
+
306
+ g.read_tree(tree3) # calls self.index.read_tree
307
+ g.read_tree(tree1, :prefix => 'hi/')
308
+
309
+ c = g.commit_tree('message')
310
+ # or #
311
+ t = g.write_tree
312
+ c = g.commit_tree(t, :message => 'message', :parents => [sha1, sha2])
313
+
314
+ g.branch('branch_name').update_ref(c)
315
+ g.update_ref(branch, c)
316
+
317
+ g.with_temp_working do # new blank working directory
318
+ g.checkout
319
+ g.checkout(another_index)
320
+ g.commit # commits to temp_index
321
+ end
322
+ end
323
+
324
+ g.set_index('/path/to/index')
325
+
326
+
327
+ g.with_index(path) do
328
+ # calls set_index, then switches back after
329
+ end
330
+
331
+ g.with_working(dir) do
332
+ # calls set_working, then switches back after
333
+ end
334
+
335
+ g.with_temp_working(dir) do
336
+ g.checkout_index(:prefix => dir, :path_limiter => path)
337
+ # do file work
338
+ g.commit # commits to index
339
+ end
340
+ ```
341
+
342
+ ## License
343
+
344
+ licensed under MIT License Copyright (c) 2008 Scott Chacon. See LICENSE for further details.
data/RELEASING.md ADDED
@@ -0,0 +1,62 @@
1
+ <!--
2
+ # @markup markdown
3
+ # @title Releasing
4
+ -->
5
+
6
+ # How to release a new git.gem
7
+
8
+ Releasing a new version of the `git` gem requires these steps:
9
+ * [Prepare the release](#prepare-the-release)
10
+ * [Create a GitHub release](#create-a-github-release)
11
+ * [Build and release the gem](#build-and-release-the-gem)
12
+
13
+ These instructions use an example where the current release version is `1.5.0`
14
+ and the new release version to be created is `1.6.0.pre1`.
15
+
16
+ ## Prepare the release
17
+
18
+ From a fork of ruby-git, create a PR containing changes to (1) bump the
19
+ version number, (2) update the CHANGELOG.md, and (3) tag the release.
20
+
21
+ * Bump the version number in lib/git/version.rb following [Semantic Versioning](https://semver.org)
22
+ guidelines
23
+ * Add a link in CHANGELOG.md to the release tag which will be created later
24
+ in this guide
25
+ * Create a new tag using [git-extras](https://github.com/tj/git-extras/blob/master/Commands.md#git-release)
26
+ `git release` command
27
+ * For example: `git release v1.6.0.pre1`
28
+ * These should be the only changes in the PR
29
+ * An example of these changes for `v1.6.0.pre1` can be found in [PR #435](https://github.com/ruby-git/ruby-git/pull/435)
30
+ * Get the PR reviewed, approved and merged to master.
31
+
32
+ ## Create a GitHub release
33
+
34
+ On [the ruby-git releases page](https://github.com/ruby-git/ruby-git/releases),
35
+ select `Draft a new release`
36
+
37
+ * Select the tag corresponding to the version being released `v1.6.0.pre1`
38
+ * The Target should be `master`
39
+ * For the release description, use the output of [changelog-rs](https://github.com/perlun/changelog-rs)
40
+ * Since the release has not been created yet, you will need to supply
41
+ `changeling-rs` with the current release tag and the tag the new release
42
+ is being created from
43
+ * For example: `changelog-rs . v1.5.0 v1.6.0.pre1`
44
+ * Copy the output, omitting the tag header `## v1.6.0.pre1` and paste into
45
+ the release description
46
+ * The release description can be edited later if needed
47
+ * Select the appropriate value for `This is a pre-release`
48
+ * Since `v1.6.0.pre1` is a pre-release, check `This is a pre-release`
49
+
50
+ ## Build and release the gem
51
+
52
+ Clone [ruby-git/ruby-git](https://github.com/ruby-git/ruby-git) directly (not a
53
+ fork) and ensure your local working copy is on the master branch
54
+
55
+ * Verify that you are not on a fork with the command `git remote -v`
56
+ * Verify that the version number is correct by running `rake -T` and inspecting
57
+ the output for the `release[remote]` task
58
+
59
+ Build the git gem and push it to rubygems.org with the command `rake release`
60
+
61
+ * Ensure that your `gem sources list` includes `https://rubygems.org` (in my
62
+ case, I usually have my work’s internal gem repository listed)
data/Rakefile ADDED
@@ -0,0 +1,56 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'English'
3
+
4
+ require "#{File.expand_path(File.dirname(__FILE__))}/lib/git/version"
5
+
6
+ default_tasks = []
7
+
8
+ desc 'Run Unit Tests'
9
+ task :test do
10
+ sh 'git config --global user.email "git@example.com"' if `git config user.email`.empty?
11
+ sh 'git config --global user.name "GitExample"' if `git config user.name`.empty?
12
+
13
+ require File.dirname(__FILE__) + '/tests/all_tests.rb'
14
+ end
15
+ default_tasks << :test
16
+
17
+ unless RUBY_PLATFORM == 'java'
18
+ #
19
+ # YARD documentation for this project can NOT be built with JRuby.
20
+ # This project uses the redcarpet gem which can not be installed on JRuby.
21
+ #
22
+ require 'yard'
23
+ YARD::Rake::YardocTask.new
24
+ CLEAN << '.yardoc'
25
+ CLEAN << 'doc'
26
+ default_tasks << :yard
27
+
28
+ require 'yardstick/rake/verify'
29
+ Yardstick::Rake::Verify.new(:'yardstick:coverage') do |t|
30
+ t.threshold = 50
31
+ t.require_exact_threshold = false
32
+ end
33
+ default_tasks << :'yardstick:coverage'
34
+
35
+ desc 'Run yardstick to check yard docs'
36
+ task :yardstick do
37
+ sh "yardstick 'lib/**/*.rb'"
38
+ end
39
+ # Do not include yardstick as a default task for now since there are too many
40
+ # warnings. Will work to get the warnings down before re-enabling it.
41
+ #
42
+ # default_tasks << :yardstick
43
+ end
44
+
45
+ default_tasks << :build
46
+
47
+ task default: default_tasks
48
+
49
+ desc 'Build and install the git gem and run a sanity check'
50
+ task :'test:gem' => :install do
51
+ output = `ruby -e "require 'git'; g = Git.open('.'); puts g.log.size"`.chomp
52
+ raise 'Gem test failed' unless $CHILD_STATUS.success?
53
+ raise 'Expected gem test to return an integer' unless output =~ /^\d+$/
54
+
55
+ puts 'Gem Test Succeeded'
56
+ end