git 1.8.0 → 1.10.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of git might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0b4267b97da7a2024f34b388707eb119370d7006d6606efb8963c4bfde76f460
4
- data.tar.gz: 3383dffa2ff71b075c62bfa40f417e37c082dc78946f2cf4c413d3bdca89a153
3
+ metadata.gz: f7d02f0f135a2a2f9e4f8d661bc4c5d4323af8b46a527581c0f47ff17df88019
4
+ data.tar.gz: c45684c1b8f6af0c5a44a90c0e8918860653a6abb4a6464d11faff90278ef7c7
5
5
  SHA512:
6
- metadata.gz: 2bd0fdfe6cce4d48a0efe62204350227d4c9eb20f184e6be43cc12811639e3e1ba789a467ab74dd24374ba758d1abd311a1875c13a368fbe28ea42080109b58b
7
- data.tar.gz: cdc75148835d1a68b76681941a28a49955b42729f085f8fdac79dc393c293447099c33748701b86f66c4db1c93344df6a6c668eff72c6c3a2899ca88b65444b3
6
+ metadata.gz: 5bd13aa06dcdb48d0f47ac72d82608120a73b9fb83db278070715d9ce98023e18e75f61c5c42ea13fc24a8f125bde989e8afbc0460c94e1a6eb5c4cd658f7639
7
+ data.tar.gz: 5c9a4e9d8734a23162e9c858246ac705ac3413db73f8e728845b7ae62aec7b6096f2b06ddcdc195c57efe052058e26c5b9340f1d9dbdc972bf8f68f303c7eba9
data/.github/stale.yml ADDED
@@ -0,0 +1,25 @@
1
+ # Probot: Stale
2
+ # https://github.com/probot/stale
3
+
4
+ # Number of days of inactivity before an issue becomes stale
5
+ daysUntilStale: 60
6
+
7
+ # Number of days of inactivity before a stale issue is closed
8
+ # Set to false to disable. If disabled, issues still need to be closed
9
+ # manually, but will remain marked as stale.
10
+ daysUntilClose: false
11
+
12
+ # Issues with these labels will never be considered stale
13
+ exemptLabels:
14
+ - pinned
15
+ - security
16
+
17
+ # Label to use when marking an issue as stale
18
+ staleLabel: stale
19
+
20
+ # Comment to post when marking an issue as stale. Set to `false` to disable
21
+ markComment: >
22
+ A friendly reminder that this issue had no activity for 60 days.
23
+
24
+ # Comment to post when closing a stale issue. Set to `false` to disable
25
+ closeComment: false
@@ -0,0 +1,45 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+ branches: [master]
8
+
9
+ jobs:
10
+ continuous_integration_build:
11
+ continue-on-error: true
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ ruby: [2.3, 2.7]
16
+ operating-system: [ubuntu-latest]
17
+ include:
18
+ - ruby: head
19
+ operating-system: ubuntu-latest
20
+ - ruby: truffleruby-head
21
+ operating-system: ubuntu-latest
22
+ - ruby: 2.7
23
+ operating-system: windows-latest
24
+ - ruby: jruby-head
25
+ operating-system: windows-latest
26
+
27
+ name: Ruby ${{ matrix.ruby }} on ${{ matrix.operating-system }}
28
+
29
+ runs-on: ${{ matrix.operating-system }}
30
+
31
+ steps:
32
+ - name: Checkout Code
33
+ uses: actions/checkout@v2
34
+
35
+ - name: Setup Ruby
36
+ uses: ruby/setup-ruby@v1
37
+ with:
38
+ ruby-version: ${{ matrix.ruby }}
39
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
40
+
41
+ - name: Run Build
42
+ run: bundle exec rake default
43
+
44
+ - name: Test Gem
45
+ run: bundle exec rake test:gem
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ *.gem
2
+ *.kpf
3
+ *.sw?
4
+ .DS_Store
5
+ coverage
6
+ doc
7
+ .yardoc
8
+ pkg
9
+ rdoc
10
+ Gemfile.lock
data/.yardopts ADDED
@@ -0,0 +1,11 @@
1
+ --default-return=''
2
+ --hide-void-return
3
+ --markup-provider=redcarpet
4
+ --markup=markdown
5
+ --fail-on-warning
6
+ -
7
+ README.md
8
+ CHANGELOG.md
9
+ CONTRIBUTING.md
10
+ RELEASING.md
11
+ MAINTAINERS.md
data/CHANGELOG.md CHANGED
@@ -5,6 +5,22 @@
5
5
 
6
6
  # Change Log
7
7
 
8
+ ## 1.10.0
9
+
10
+ See https://github.com/ruby-git/ruby-git/releases/tag/v1.10.0
11
+
12
+ ## 1.9.1
13
+
14
+ See https://github.com/ruby-git/ruby-git/releases/tag/v1.9.1
15
+
16
+ ## 1.9.0
17
+
18
+ See https://github.com/ruby-git/ruby-git/releases/tag/v1.9.0
19
+
20
+ ## 1.8.1
21
+
22
+ See https://github.com/ruby-git/ruby-git/releases/tag/v1.8.1
23
+
8
24
  ## 1.8.0
9
25
 
10
26
  See https://github.com/ruby-git/ruby-git/releases/tag/v1.8.0
data/CONTRIBUTING.md CHANGED
@@ -78,12 +78,14 @@ In order to ensure high quality, all pull requests must meet these requirements:
78
78
 
79
79
  ### Unit tests
80
80
  * All changes must be accompanied by new or modified unit tests
81
- * The entire test suite must pass when `bundle exec rake test` is run from the
82
- project's local working copy
83
-
84
- ### Continuous Integration
85
- * All tests must pass in the project's [Travis CI](https://travis-ci.org/ruby-git/ruby-git)
86
- build before the pull request will be merged
81
+ * The entire test suite must pass when `bundle exec rake default` is run from the
82
+ project's local working copy.
83
+
84
+ ### Continuous integration
85
+ * All tests must pass in the project's [GitHub Continuous Integration build](https://github.com/ruby-git/ruby-git/actions?query=workflow%3ACI)
86
+ before the pull request will be merged.
87
+ * The [Continuous Integration workflow](https://github.com/ruby-git/ruby-git/blob/master/.github/workflows/continuous_integration.yml)
88
+ runs both `bundle exec rake default` and `bundle exec rake test:gem` from the project's [Rakefile](https://github.com/ruby-git/ruby-git/blob/master/Rakefile).
87
89
 
88
90
  ### Documentation
89
91
  * New and updated public methods must have [YARD](https://yardoc.org/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec :name => 'git'
4
+
data/ISSUE_TEMPLATE.md ADDED
@@ -0,0 +1,15 @@
1
+ ### Subject of the issue
2
+ Describe your issue here.
3
+
4
+ ### Your environment
5
+ * version of git and ruby-git
6
+ * version of ruby
7
+
8
+ ### Steps to reproduce
9
+ Tell us how to reproduce this issue.
10
+
11
+ ### Expected behaviour
12
+ What did you expect to happen?
13
+
14
+ ### Actual behaviour
15
+ What actually happened?
@@ -0,0 +1,9 @@
1
+ ### Your checklist for this pull request
2
+ 🚨Please review the [guidelines for contributing](https://github.com/ruby-git/ruby-git/blob/master/CONTRIBUTING.md) to this repository.
3
+
4
+ - [ ] Ensure all commits include DCO sign-off.
5
+ - [ ] Ensure that your contributions pass unit testing.
6
+ - [ ] Ensure that your contributions contain documentation if applicable.
7
+
8
+ ### Description
9
+ Please describe your pull request.
data/README.md CHANGED
@@ -146,6 +146,7 @@ g.revparse('v2.5:Makefile')
146
146
 
147
147
  g.branches # returns Git::Branch objects
148
148
  g.branches.local
149
+ g.current_branch
149
150
  g.branches.remote
150
151
  g.branches[:master].gcommit
151
152
  g.branches['origin/master'].gcommit
@@ -225,6 +226,14 @@ g.remove('file.txt', :cached => true) # git rm -f --cached -- "file.txt"
225
226
  g.commit('message')
226
227
  g.commit_all('message')
227
228
 
229
+ # Sign a commit using the gpg key configured in the user.signingkey config setting
230
+ g.config('user.signingkey', '0A46826A')
231
+ g.commit('message', gpg_sign: true)
232
+
233
+ # Sign a commit using a specified gpg key
234
+ key_id = '0A46826A'
235
+ g.commit('message', gpg_sign: key_id)
236
+
228
237
  g = Git.clone(repo, 'myrepo')
229
238
  g.chdir do
230
239
  new_file('test-file', 'blahblahblah')
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
data/git.gemspec ADDED
@@ -0,0 +1,46 @@
1
+ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
2
+ require 'git/version'
3
+
4
+ Gem::Specification.new do |s|
5
+ s.author = 'Scott Chacon and others'
6
+ s.email = 'schacon@gmail.com'
7
+ s.homepage = 'http://github.com/ruby-git/ruby-git'
8
+ s.license = 'MIT'
9
+ s.name = 'git'
10
+ s.summary = 'An API to create, read, and manipulate Git repositories'
11
+ s.description = <<~DESCRIPTION
12
+ The Git Gem provides an API that can be used to create, read, and manipulate
13
+ Git repositories by wrapping system calls to the `git` binary. The API can be
14
+ used for working with Git in complex interactions including branching and
15
+ merging, object inspection and manipulation, history, patch generation and
16
+ more.
17
+ DESCRIPTION
18
+ s.version = Git::VERSION
19
+
20
+ s.metadata['homepage_uri'] = s.homepage
21
+ s.metadata['source_code_uri'] = s.homepage
22
+ s.metadata['changelog_uri'] = 'http://rubydoc.info/gems/git/file.CHANGELOG.html'
23
+
24
+ s.require_paths = ['lib']
25
+ s.required_ruby_version = '>= 2.3'
26
+ s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to?(:required_rubygems_version=)
27
+ s.requirements = ['git 1.6.0.0, or greater']
28
+
29
+ s.add_runtime_dependency 'rchardet', '~> 1.8'
30
+
31
+ s.add_development_dependency 'minitar', '~> 0.9'
32
+ s.add_development_dependency 'rake', '~> 13.0'
33
+ s.add_development_dependency 'test-unit', '~> 3.3'
34
+
35
+ unless RUBY_PLATFORM == 'java'
36
+ s.add_development_dependency 'redcarpet', '~> 3.5'
37
+ s.add_development_dependency 'yard', '~> 0.9'
38
+ s.add_development_dependency 'yardstick', '~> 0.9'
39
+ end
40
+
41
+ # Specify which files should be added to the gem when it is released.
42
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
43
+ s.files = Dir.chdir(File.expand_path(__dir__)) do
44
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(tests|spec|features)/}) }
45
+ end
46
+ end
data/lib/git/base.rb CHANGED
@@ -12,40 +12,35 @@ module Git
12
12
 
13
13
  # (see Git.bare)
14
14
  def self.bare(git_dir, options = {})
15
- self.new({:repository => git_dir}.merge(options))
15
+ normalize_paths(options, default_repository: git_dir, bare: true)
16
+ self.new(options)
16
17
  end
17
18
 
18
19
  # (see Git.clone)
19
20
  def self.clone(repository, name, options = {})
20
- self.new(Git::Lib.new(nil, options[:log]).clone(repository, name, options))
21
+ new_options = Git::Lib.new(nil, options[:log]).clone(repository, name, options)
22
+ normalize_paths(new_options, bare: options[:bare] || options[:mirror])
23
+ self.new(new_options)
21
24
  end
22
25
 
23
26
  # Returns (and initialize if needed) a Git::Config instance
24
27
  #
25
28
  # @return [Git::Config] the current config instance.
26
29
  def self.config
27
- return @@config ||= Config.new
30
+ @@config ||= Config.new
28
31
  end
29
32
 
30
33
  # (see Git.init)
31
- def self.init(directory, options = {})
32
- options[:working_directory] ||= directory
33
- options[:repository] ||= File.join(options[:working_directory], '.git')
34
-
35
- FileUtils.mkdir_p(options[:working_directory]) if options[:working_directory] && !File.directory?(options[:working_directory])
34
+ def self.init(directory = '.', options = {})
35
+ normalize_paths(options, default_working_directory: directory, default_repository: directory, bare: options[:bare])
36
36
 
37
- init_options = { :bare => options[:bare] }
37
+ init_options = {
38
+ :bare => options[:bare],
39
+ :initial_branch => options[:initial_branch],
40
+ }
38
41
 
39
- options.delete(:working_directory) if options[:bare]
40
-
41
- # Submodules have a .git *file* not a .git folder.
42
- # This file's contents point to the location of
43
- # where the git refs are held (In the parent repo)
44
- if options[:working_directory] && File.file?(File.join(options[:working_directory], '.git'))
45
- git_file = File.open('.git').read[8..-1].strip
46
- options[:repository] = git_file
47
- options[:index] = git_file + '/index'
48
- end
42
+ directory = options[:bare] ? options[:repository] : options[:working_directory]
43
+ FileUtils.mkdir_p(directory) unless File.exist?(directory)
49
44
 
50
45
  # TODO: this dance seems awkward: this creates a Git::Lib so we can call
51
46
  # init so we can create a new Git::Base which in turn (ultimately)
@@ -63,21 +58,8 @@ module Git
63
58
  end
64
59
 
65
60
  # (see Git.open)
66
- def self.open(working_dir, options={})
67
- # TODO: move this to Git.open?
68
-
69
- options[:working_directory] ||= working_dir
70
- options[:repository] ||= File.join(options[:working_directory], '.git')
71
-
72
- # Submodules have a .git *file* not a .git folder.
73
- # This file's contents point to the location of
74
- # where the git refs are held (In the parent repo)
75
- if options[:working_directory] && File.file?(File.join(options[:working_directory], '.git'))
76
- git_file = File.open('.git').read[8..-1].strip
77
- options[:repository] = git_file
78
- options[:index] = git_file + '/index'
79
- end
80
-
61
+ def self.open(working_dir, options = {})
62
+ normalize_paths(options, default_working_directory: working_dir)
81
63
  self.new(options)
82
64
  end
83
65
 
@@ -137,13 +119,14 @@ module Git
137
119
 
138
120
  #g.config('user.name', 'Scott Chacon') # sets value
139
121
  #g.config('user.email', 'email@email.com') # sets value
122
+ #g.config('user.email', 'email@email.com', file: 'path/to/custom/config) # sets value in file
140
123
  #g.config('user.name') # returns 'Scott Chacon'
141
124
  #g.config # returns whole config hash
142
- def config(name = nil, value = nil)
143
- if(name && value)
125
+ def config(name = nil, value = nil, options = {})
126
+ if name && value
144
127
  # set value
145
- lib.config_set(name, value)
146
- elsif (name)
128
+ lib.config_set(name, value, options)
129
+ elsif name
147
130
  # return value
148
131
  lib.config_get(name)
149
132
  else
@@ -286,6 +269,7 @@ module Git
286
269
  # options:
287
270
  # :force
288
271
  # :d
272
+ # :ff
289
273
  #
290
274
  def clean(opts = {})
291
275
  self.lib.clean(opts)
@@ -387,7 +371,7 @@ module Git
387
371
  # @git.pull('upstream', 'develope') # pulls from upstream/develop
388
372
  #
389
373
  def pull(remote='origin', branch='master')
390
- self.lib.pull(remote, branch)
374
+ self.lib.pull(remote, branch)
391
375
  end
392
376
 
393
377
  # returns an array of Git:Remote objects
@@ -566,7 +550,6 @@ module Git
566
550
  with_working(temp_dir, &blk)
567
551
  end
568
552
 
569
-
570
553
  # runs git rev-parse to convert the objectish to a full sha
571
554
  #
572
555
  # @example
@@ -591,6 +574,93 @@ module Git
591
574
  self.lib.branch_current
592
575
  end
593
576
 
594
- end
577
+ private
578
+
579
+ # Normalize options before they are sent to Git::Base.new
580
+ #
581
+ # Updates the options parameter by setting appropriate values for the following keys:
582
+ # * options[:working_directory]
583
+ # * options[:repository]
584
+ # * options[:index]
585
+ #
586
+ # All three values will be set to absolute paths. An exception is that
587
+ # :working_directory will be set to nil if bare is true.
588
+ #
589
+ private_class_method def self.normalize_paths(
590
+ options, default_working_directory: nil, default_repository: nil, bare: false
591
+ )
592
+ normalize_working_directory(options, default: default_working_directory, bare: bare)
593
+ normalize_repository(options, default: default_repository, bare: bare)
594
+ normalize_index(options)
595
+ end
596
+
597
+ # Normalize options[:working_directory]
598
+ #
599
+ # If working with a bare repository, set to `nil`.
600
+ # Otherwise, set to the first non-nil value of:
601
+ # 1. `options[:working_directory]`,
602
+ # 2. the `default` parameter, or
603
+ # 3. the current working directory
604
+ #
605
+ # Finally, if options[:working_directory] is a relative path, convert it to an absoluite
606
+ # path relative to the current directory.
607
+ #
608
+ private_class_method def self.normalize_working_directory(options, default:, bare: false)
609
+ working_directory =
610
+ if bare
611
+ nil
612
+ else
613
+ File.expand_path(options[:working_directory] || default || Dir.pwd)
614
+ end
595
615
 
616
+ options[:working_directory] = working_directory
617
+ end
618
+
619
+ # Normalize options[:repository]
620
+ #
621
+ # If working with a bare repository, set to the first non-nil value out of:
622
+ # 1. `options[:repository]`
623
+ # 2. the `default` parameter
624
+ # 3. the current working directory
625
+ #
626
+ # Otherwise, set to the first non-nil value of:
627
+ # 1. `options[:repository]`
628
+ # 2. `.git`
629
+ #
630
+ # Next, if options[:repository] refers to a *file* and not a *directory*, set
631
+ # options[:repository] to the contents of that file. This is the case when
632
+ # working with a submodule or a secondary working tree (created with git worktree
633
+ # add). In these cases the repository is actually contained/nested within the
634
+ # parent's repository directory.
635
+ #
636
+ # Finally, if options[:repository] is a relative path, convert it to an absolute
637
+ # path relative to:
638
+ # 1. the current directory if working with a bare repository or
639
+ # 2. the working directory if NOT working with a bare repository
640
+ #
641
+ private_class_method def self.normalize_repository(options, default:, bare: false)
642
+ repository =
643
+ if bare
644
+ File.expand_path(options[:repository] || default || Dir.pwd)
645
+ else
646
+ File.expand_path(options[:repository] || '.git', options[:working_directory])
647
+ end
648
+
649
+ if File.file?(repository)
650
+ repository = File.expand_path(File.open(repository).read[8..-1].strip, options[:working_directory])
651
+ end
652
+
653
+ options[:repository] = repository
654
+ end
655
+
656
+ # Normalize options[:index]
657
+ #
658
+ # If options[:index] is a relative directory, convert it to an absolute
659
+ # directory relative to the repository directory
660
+ #
661
+ private_class_method def self.normalize_index(options)
662
+ index = File.expand_path(options[:index] || 'index', options[:repository])
663
+ options[:index] = index
664
+ end
665
+ end
596
666
  end
data/lib/git/lib.rb CHANGED
@@ -71,10 +71,12 @@ module Git
71
71
  # options:
72
72
  # :bare
73
73
  # :working_directory
74
+ # :initial_branch
74
75
  #
75
76
  def init(opts={})
76
77
  arr_opts = []
77
78
  arr_opts << '--bare' if opts[:bare]
79
+ arr_opts << "--initial-branch=#{opts[:initial_branch]}" if opts[:initial_branch]
78
80
 
79
81
  command('init', arr_opts)
80
82
  end
@@ -583,8 +585,12 @@ module Git
583
585
 
584
586
  ## WRITE COMMANDS ##
585
587
 
586
- def config_set(name, value)
587
- command('config', name, value)
588
+ def config_set(name, value, options = {})
589
+ if options[:file].to_s.empty?
590
+ command('config', name, value)
591
+ else
592
+ command('config', '--file', options[:file], name, value)
593
+ end
588
594
  end
589
595
 
590
596
  def global_config_set(name, value)
@@ -642,6 +648,7 @@ module Git
642
648
  # :date
643
649
  # :no_verify
644
650
  # :allow_empty_message
651
+ # :gpg_sign
645
652
  #
646
653
  # @param [String] message the commit message to be used
647
654
  # @param [Hash] opts the commit options to be used
@@ -655,6 +662,14 @@ module Git
655
662
  arr_opts << "--date=#{opts[:date]}" if opts[:date].is_a? String
656
663
  arr_opts << '--no-verify' if opts[:no_verify]
657
664
  arr_opts << '--allow-empty-message' if opts[:allow_empty_message]
665
+ if opts[:gpg_sign]
666
+ arr_opts <<
667
+ if opts[:gpg_sign] == true
668
+ '--gpg-sign'
669
+ else
670
+ "--gpg-sign=#{opts[:gpg_sign]}"
671
+ end
672
+ end
658
673
 
659
674
  command('commit', arr_opts)
660
675
  end
@@ -669,6 +684,7 @@ module Git
669
684
  def clean(opts = {})
670
685
  arr_opts = []
671
686
  arr_opts << '--force' if opts[:force]
687
+ arr_opts << '-ff' if opts[:ff]
672
688
  arr_opts << '-d' if opts[:d]
673
689
  arr_opts << '-x' if opts[:x]
674
690
 
@@ -759,6 +775,7 @@ module Git
759
775
 
760
776
  def merge(branch, message = nil, opts = {})
761
777
  arr_opts = []
778
+ arr_opts << '--no-commit' if opts[:no_commit]
762
779
  arr_opts << '--no-ff' if opts[:no_ff]
763
780
  arr_opts << '-m' << message if message
764
781
  arr_opts += [branch]
@@ -866,6 +883,7 @@ module Git
866
883
  arr_opts << '--tags' if opts[:t] || opts[:tags]
867
884
  arr_opts << '--prune' if opts[:p] || opts[:prune]
868
885
  arr_opts << '--unshallow' if opts[:unshallow]
886
+ arr_opts << '--depth' << opts[:depth] if opts[:depth]
869
887
 
870
888
  command('fetch', arr_opts)
871
889
  end
data/lib/git/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Git
2
2
  # The current gem version
3
3
  # @return [String] the current gem version.
4
- VERSION='1.8.0'
4
+ VERSION='1.10.0'
5
5
  end
@@ -0,0 +1,38 @@
1
+ require 'git/path'
2
+
3
+ module Git
4
+
5
+ class Worktree < Path
6
+
7
+ attr_accessor :full, :dir, :gcommit
8
+
9
+ def initialize(base, dir, gcommit = nil)
10
+ @full = dir
11
+ @full += ' ' + gcommit if !gcommit.nil?
12
+ @base = base
13
+ @dir = dir
14
+ @gcommit = gcommit
15
+ end
16
+
17
+ def gcommit
18
+ @gcommit ||= @base.gcommit(@full)
19
+ @gcommit
20
+ end
21
+
22
+ def add
23
+ @base.lib.worktree_add(@dir, @gcommit)
24
+ end
25
+
26
+ def remove
27
+ @base.lib.worktree_remove(@dir)
28
+ end
29
+
30
+ def to_a
31
+ [@full]
32
+ end
33
+
34
+ def to_s
35
+ @full
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,47 @@
1
+ module Git
2
+ # object that holds all the available worktrees
3
+ class Worktrees
4
+
5
+ include Enumerable
6
+
7
+ def initialize(base)
8
+ @worktrees = {}
9
+
10
+ @base = base
11
+
12
+ # Array contains [dir, git_hash]
13
+ @base.lib.worktrees_all.each do |w|
14
+ @worktrees[w[0]] = Git::Worktree.new(@base, w[0], w[1])
15
+ end
16
+ end
17
+
18
+ # array like methods
19
+
20
+ def size
21
+ @worktrees.size
22
+ end
23
+
24
+ def each(&block)
25
+ @worktrees.values.each(&block)
26
+ end
27
+
28
+ def [](worktree_name)
29
+ @worktrees.values.inject(@worktrees) do |worktrees, worktree|
30
+ worktrees[worktree.full] ||= worktree
31
+ worktrees
32
+ end[worktree_name.to_s]
33
+ end
34
+
35
+ def to_s
36
+ out = ''
37
+ @worktrees.each do |k, b|
38
+ out << b.to_s << "\n"
39
+ end
40
+ out
41
+ end
42
+
43
+ def prune
44
+ @base.lib.worktree_prune
45
+ end
46
+ end
47
+ end
data/lib/git.rb CHANGED
@@ -212,6 +212,9 @@ module Git
212
212
  # `"#{directory}/.git"`, create a bare repository at `"#{directory}"`.
213
213
  # See [what is a bare repository?](https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddefbarerepositoryabarerepository).
214
214
  #
215
+ # @option options [String] :initial_branch Use the specified name for the
216
+ # initial branch in the newly created repository.
217
+ #
215
218
  # @option options [Pathname] :repository the path to put the newly initialized
216
219
  # Git repository. The default for non-bare repository is `"#{directory}/.git"`.
217
220
  #
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Chacon and others
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-31 00:00:00.000000000 Z
11
+ date: 2021-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rchardet
@@ -119,11 +119,21 @@ executables: []
119
119
  extensions: []
120
120
  extra_rdoc_files: []
121
121
  files:
122
+ - ".github/stale.yml"
123
+ - ".github/workflows/continuous_integration.yml"
124
+ - ".gitignore"
125
+ - ".yardopts"
122
126
  - CHANGELOG.md
123
127
  - CONTRIBUTING.md
128
+ - Gemfile
129
+ - ISSUE_TEMPLATE.md
124
130
  - LICENSE
125
131
  - MAINTAINERS.md
132
+ - PULL_REQUEST_TEMPLATE.md
126
133
  - README.md
134
+ - RELEASING.md
135
+ - Rakefile
136
+ - git.gemspec
127
137
  - lib/git.rb
128
138
  - lib/git/author.rb
129
139
  - lib/git/base.rb
@@ -144,6 +154,8 @@ files:
144
154
  - lib/git/status.rb
145
155
  - lib/git/version.rb
146
156
  - lib/git/working_directory.rb
157
+ - lib/git/worktree.rb
158
+ - lib/git/worktrees.rb
147
159
  homepage: http://github.com/ruby-git/ruby-git
148
160
  licenses:
149
161
  - MIT
@@ -167,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
179
  version: '0'
168
180
  requirements:
169
181
  - git 1.6.0.0, or greater
170
- rubygems_version: 3.1.4
182
+ rubygems_version: 3.1.6
171
183
  signing_key:
172
184
  specification_version: 4
173
185
  summary: An API to create, read, and manipulate Git repositories