git 1.15.0 → 1.17.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +25 -0
- data/CONTRIBUTING.md +3 -3
- data/README.md +49 -21
- data/Rakefile +1 -1
- data/git.gemspec +1 -0
- data/lib/git/base/factory.rb +1 -3
- data/lib/git/base.rb +25 -10
- data/lib/git/lib.rb +82 -13
- data/lib/git/remote.rb +15 -13
- data/lib/git/version.rb +1 -1
- data/lib/git.rb +69 -4
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dcca4b91f56e1bf6b99c471f918fbe4b1ed6d56b0058021e345514676e153223
|
4
|
+
data.tar.gz: 9f4386702fca4248c3a7a07400c6ff3e52fa7898f0e16bbcb3b90bf945fde1da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d943759fc15a56baee49734b4628cf1b5651416c13842077a9bfe979df1bdc05afbe114af904b2161ef84be090207f9691a80a704efe2d8a3a14bb4c80df8f6
|
7
|
+
data.tar.gz: 8feccfa435ec2f3d95a52ec0fd3920b5a956b2dc3cbcddfbc63c48052ddf64686ba1ef849f0b96307e573134d0e818c6d5bfaae8f3dad877a6f74a516806754a
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,31 @@
|
|
5
5
|
|
6
6
|
# Change Log
|
7
7
|
|
8
|
+
## v1.17.0 (2023-03-05)
|
9
|
+
|
10
|
+
[Full Changelog](https://github.com/ruby-git/ruby-git/compare/v1.16.0..v1.17.0)
|
11
|
+
|
12
|
+
Changes since v1.16.0:
|
13
|
+
|
14
|
+
* 1311 Add deprecation mechanism (introduces runtime dependency on ActiveSupport) (#645)
|
15
|
+
* 50b8 Add the push_option option for Git::Lib#push (#644)
|
16
|
+
* a799 Make Git::Base#ls_tree handle commit objects (#643)
|
17
|
+
* 6db3 Implememt Git.default_branch (#571)
|
18
|
+
|
19
|
+
## v1.16.0 (2023-03-03)
|
20
|
+
|
21
|
+
[Full Changelog](https://github.com/ruby-git/ruby-git/compare/v1.15.0..v1.16.0)
|
22
|
+
|
23
|
+
Changes since v1.15.0:
|
24
|
+
|
25
|
+
* 536d Fix parsing when in detached HEAD state in Git::Lib#branches_all (#641)
|
26
|
+
* 5c68 Fix parsing of symbolic refs in `Git::Lib#branches_all` (#640)
|
27
|
+
* 7d88 Remote#branch and #merge should default to current branch instead of "master" (#639)
|
28
|
+
* 3dda0 `#branch` name should default to current branch instead of `master` (#638)
|
29
|
+
* d33d #checkout without args should do same as `git checkout` with no args (#637)
|
30
|
+
* 0c90 #push without args should do same as `git push` with no args (#636)
|
31
|
+
* 2b19 Make it easier to run test files from the command line (#635)
|
32
|
+
|
8
33
|
## v1.15.0 (2023-03-01)
|
9
34
|
|
10
35
|
[Full Changelog](https://github.com/ruby-git/ruby-git/compare/v1.14.0..v1.15.0)
|
data/CONTRIBUTING.md
CHANGED
@@ -84,11 +84,11 @@ In order to ensure high quality, all pull requests must meet these requirements:
|
|
84
84
|
While working on specific features you can run individual test files or
|
85
85
|
a group of tests using `bin/test`:
|
86
86
|
|
87
|
-
# run a single file:
|
88
|
-
$ bin/test
|
87
|
+
# run a single file (from tests/units):
|
88
|
+
$ bin/test test_object
|
89
89
|
|
90
90
|
# run multiple files:
|
91
|
-
$ bin/test
|
91
|
+
$ bin/test test_object test_archive
|
92
92
|
|
93
93
|
# run all unit tests:
|
94
94
|
$ bin/test
|
data/README.md
CHANGED
@@ -3,47 +3,73 @@
|
|
3
3
|
# @title README
|
4
4
|
-->
|
5
5
|
|
6
|
-
# The
|
6
|
+
# The `git` Gem
|
7
7
|
|
8
|
-
|
8
|
+
[](https://badge.fury.io/rb/git)
|
9
|
+
[](https://rubydoc.info/gems/git/file/CHANGELOG.md)
|
10
|
+
[](https://github.com/ruby-git/ruby-git/actions/workflows/continuous_integration.yml)
|
11
|
+
[](https://codeclimate.com/github/ruby-git/ruby-git)
|
12
|
+
[](https://github.com/ruby-git/ruby-git)
|
13
|
+
[](https://rubydoc.info/gems/git)
|
14
|
+
[](https://github.com/ruby-git/ruby-git/blob/master/LICENSE)
|
15
|
+
|
16
|
+
The git Gem provides an API that can be used to create, read, and manipulate
|
9
17
|
Git repositories by wrapping system calls to the `git` binary. The API can be
|
10
18
|
used for working with Git in complex interactions including branching and
|
11
19
|
merging, object inspection and manipulation, history, patch generation and
|
12
20
|
more.
|
13
21
|
|
14
|
-
##
|
22
|
+
## Basic Usage
|
15
23
|
|
16
|
-
|
24
|
+
Get started by obtaining a repository object by:
|
17
25
|
|
18
|
-
|
26
|
+
* Opening an existing working copy with [Git.open](https://rubydoc.info/gems/git/Git#open-class_method)
|
27
|
+
* Initializing a new repository with [Git.init](https://rubydoc.info/gems/git/Git#init-class_method)
|
28
|
+
* Cloning a repository with [Git.clone](https://rubydoc.info/gems/git/Git#clone-class_method)
|
19
29
|
|
20
|
-
|
30
|
+
Methods that can be called on a repository object are documented in [Git::Base](https://rubydoc.info/gems/git/Git/Base)
|
21
31
|
|
22
|
-
|
32
|
+
## Install
|
23
33
|
|
24
|
-
|
34
|
+
You can install the `git` gem with the following command:
|
25
35
|
|
26
|
-
|
27
|
-
|
28
|
-
|
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)
|
36
|
+
```shell
|
37
|
+
gem install git
|
38
|
+
```
|
31
39
|
|
32
|
-
|
40
|
+
## Deprecation Warnings
|
33
41
|
|
34
|
-
|
42
|
+
Deprecation warnings are managed with the `Git.deprecation` attribute.
|
35
43
|
|
36
|
-
|
44
|
+
Use this object to define deprecations in the source code:
|
37
45
|
|
46
|
+
```ruby
|
47
|
+
Git.deprecation.deprecate_methods(Git::Branch, stashes: 'use Git::Base#stash_list instead')
|
38
48
|
```
|
39
|
-
|
49
|
+
|
50
|
+
The default action when using deprecated items (methods, classes, etc.) is to output
|
51
|
+
a **DEPRECATION WARNING** to `$stderr` like the following:
|
52
|
+
|
53
|
+
```text
|
54
|
+
DEPRECATION WARNING: stashes is deprecated and will be removed from git 2.0.0 (use Git::Base.stash_list instead)
|
40
55
|
```
|
41
56
|
|
42
|
-
|
57
|
+
The action taken when a deprecated item is used is defined by setting the behavior
|
58
|
+
on the deprecation object:
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
# Log all deprecation warnings to $stderr (the default)
|
62
|
+
Git.deprecation = :stderr
|
43
63
|
|
44
|
-
|
45
|
-
|
46
|
-
|
64
|
+
# Raise an ActiveSupport::DeprecationException
|
65
|
+
Git.deprecation = :raise
|
66
|
+
|
67
|
+
# Do nothing
|
68
|
+
Git.deprecation = :silence
|
69
|
+
```
|
70
|
+
|
71
|
+
See [ActiveSupport::Deprecation](https://api.rubyonrails.org/classes/ActiveSupport/Deprecation.html)
|
72
|
+
for more details on how to use deprecations.
|
47
73
|
|
48
74
|
## Major Objects
|
49
75
|
|
@@ -197,6 +223,8 @@ g.show('v2.8', 'README.md')
|
|
197
223
|
Git.ls_remote('https://github.com/ruby-git/ruby-git.git') # returns a hash containing the available references of the repo.
|
198
224
|
Git.ls_remote('/path/to/local/repo')
|
199
225
|
Git.ls_remote() # same as Git.ls_remote('.')
|
226
|
+
|
227
|
+
Git.default_branch('https://github.com/ruby-git/ruby-git') #=> 'master'
|
200
228
|
```
|
201
229
|
|
202
230
|
And here are the operations that will need to write to your git repository.
|
data/Rakefile
CHANGED
@@ -18,7 +18,7 @@ task :test do
|
|
18
18
|
end
|
19
19
|
default_tasks << :test
|
20
20
|
|
21
|
-
unless RUBY_PLATFORM == 'java'
|
21
|
+
unless RUBY_PLATFORM == 'java' || RUBY_ENGINE == 'truffleruby'
|
22
22
|
#
|
23
23
|
# YARD documentation for this project can NOT be built with JRuby.
|
24
24
|
# This project uses the redcarpet gem which can not be installed on JRuby.
|
data/git.gemspec
CHANGED
@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
|
|
26
26
|
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to?(:required_rubygems_version=)
|
27
27
|
s.requirements = ['git 1.6.0.0, or greater']
|
28
28
|
|
29
|
+
s.add_runtime_dependency 'activesupport', '>= 4.0.0'
|
29
30
|
s.add_runtime_dependency 'addressable', '~> 2.8'
|
30
31
|
s.add_runtime_dependency 'rchardet', '~> 1.8'
|
31
32
|
|
data/lib/git/base/factory.rb
CHANGED
@@ -3,9 +3,8 @@ module Git
|
|
3
3
|
class Base
|
4
4
|
|
5
5
|
module Factory
|
6
|
-
|
7
6
|
# @return [Git::Branch] an object for branch_name
|
8
|
-
def branch(branch_name =
|
7
|
+
def branch(branch_name = self.current_branch)
|
9
8
|
Git::Branch.new(self, branch_name)
|
10
9
|
end
|
11
10
|
|
@@ -93,7 +92,6 @@ module Git
|
|
93
92
|
shas = self.lib.merge_base(*args)
|
94
93
|
shas.map { |sha| gcommit(sha) }
|
95
94
|
end
|
96
|
-
|
97
95
|
end
|
98
96
|
|
99
97
|
end
|
data/lib/git/base.rb
CHANGED
@@ -24,6 +24,11 @@ module Git
|
|
24
24
|
new(new_options)
|
25
25
|
end
|
26
26
|
|
27
|
+
# (see Git.default_branch)
|
28
|
+
def self.repository_default_branch(repository, options = {})
|
29
|
+
Git::Lib.new(nil, options[:log]).repository_default_branch(repository)
|
30
|
+
end
|
31
|
+
|
27
32
|
# Returns (and initialize if needed) a Git::Config instance
|
28
33
|
#
|
29
34
|
# @return [Git::Config] the current config instance.
|
@@ -350,8 +355,8 @@ module Git
|
|
350
355
|
end
|
351
356
|
|
352
357
|
# checks out a branch as the new git working directory
|
353
|
-
def checkout(
|
354
|
-
self.lib.checkout(
|
358
|
+
def checkout(*args, **options)
|
359
|
+
self.lib.checkout(*args, **options)
|
355
360
|
end
|
356
361
|
|
357
362
|
# checks out an old version of a file
|
@@ -369,16 +374,26 @@ module Git
|
|
369
374
|
self.lib.fetch(remote, opts)
|
370
375
|
end
|
371
376
|
|
372
|
-
#
|
373
|
-
# otherwise you may have to run something like this first to setup the push parameters:
|
377
|
+
# Push changes to a remote repository
|
374
378
|
#
|
375
|
-
#
|
379
|
+
# @overload push(remote = nil, branch = nil, options = {})
|
380
|
+
# @param remote [String] the remote repository to push to
|
381
|
+
# @param branch [String] the branch to push
|
382
|
+
# @param options [Hash] options to pass to the push command
|
376
383
|
#
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
384
|
+
# @option opts [Boolean] :mirror (false) Push all refs under refs/heads/, refs/tags/ and refs/remotes/
|
385
|
+
# @option opts [Boolean] :delete (false) Delete refs that don't exist on the remote
|
386
|
+
# @option opts [Boolean] :force (false) Force updates
|
387
|
+
# @option opts [Boolean] :tags (false) Push all refs under refs/tags/
|
388
|
+
# @option opts [Array, String] :push_options (nil) Push options to transmit
|
389
|
+
#
|
390
|
+
# @return [Void]
|
391
|
+
#
|
392
|
+
# @raise [Git::FailedError] if the push fails
|
393
|
+
# @raise [ArgumentError] if a branch is given without a remote
|
394
|
+
#
|
395
|
+
def push(*args, **options)
|
396
|
+
self.lib.push(*args, **options)
|
382
397
|
end
|
383
398
|
|
384
399
|
# merges one or more branches into the current working branch
|
data/lib/git/lib.rb
CHANGED
@@ -124,6 +124,24 @@ module Git
|
|
124
124
|
base_opts
|
125
125
|
end
|
126
126
|
|
127
|
+
# Returns the name of the default branch of the given repository
|
128
|
+
#
|
129
|
+
# @param repository [URI, Pathname, String] The (possibly remote) repository to clone from
|
130
|
+
#
|
131
|
+
# @return [String] the name of the default branch
|
132
|
+
#
|
133
|
+
def repository_default_branch(repository)
|
134
|
+
output = command('ls-remote', '--symref', '--', repository, 'HEAD')
|
135
|
+
|
136
|
+
match_data = output.match(%r{^ref: refs/remotes/origin/(?<default_branch>[^\t]+)\trefs/remotes/origin/HEAD$})
|
137
|
+
return match_data[:default_branch] if match_data
|
138
|
+
|
139
|
+
match_data = output.match(%r{^ref: refs/heads/(?<default_branch>[^\t]+)\tHEAD$})
|
140
|
+
return match_data[:default_branch] if match_data
|
141
|
+
|
142
|
+
raise 'Unable to determine the default branch'
|
143
|
+
end
|
144
|
+
|
127
145
|
## READ COMMANDS ##
|
128
146
|
|
129
147
|
#
|
@@ -320,7 +338,7 @@ module Git
|
|
320
338
|
end
|
321
339
|
|
322
340
|
def ls_tree(sha)
|
323
|
-
data = {'blob' => {}, 'tree' => {}}
|
341
|
+
data = { 'blob' => {}, 'tree' => {}, 'commit' => {} }
|
324
342
|
|
325
343
|
command_lines('ls-tree', sha).each do |line|
|
326
344
|
(info, filenm) = line.split("\t")
|
@@ -347,13 +365,42 @@ module Git
|
|
347
365
|
command('symbolic-ref', 'HEAD', "refs/heads/#{branch_name}")
|
348
366
|
end
|
349
367
|
|
368
|
+
BRANCH_LINE_REGEXP = /
|
369
|
+
^
|
370
|
+
# Prefix indicates if this branch is checked out. The prefix is one of:
|
371
|
+
(?:
|
372
|
+
(?<current>\*[[:blank:]]) | # Current branch (checked out in the current worktree)
|
373
|
+
(?<worktree>\+[[:blank:]]) | # Branch checked out in a different worktree
|
374
|
+
[[:blank:]]{2} # Branch not checked out
|
375
|
+
)
|
376
|
+
|
377
|
+
# The branch's full refname
|
378
|
+
(?:
|
379
|
+
(?<not_a_branch>\(not[[:blank:]]a[[:blank:]]branch\)) |
|
380
|
+
(?:\(HEAD[[:blank:]]detached[[:blank:]]at[[:blank:]](?<detached_ref>[^\)]+)\)) |
|
381
|
+
(?<refname>[^[[:blank:]]]+)
|
382
|
+
)
|
383
|
+
|
384
|
+
# Optional symref
|
385
|
+
# If this ref is a symbolic reference, this is the ref referenced
|
386
|
+
(?:
|
387
|
+
[[:blank:]]->[[:blank:]](?<symref>.*)
|
388
|
+
)?
|
389
|
+
$
|
390
|
+
/x
|
391
|
+
|
350
392
|
def branches_all
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
393
|
+
command_lines('branch', '-a').map do |line|
|
394
|
+
match_data = line.match(BRANCH_LINE_REGEXP)
|
395
|
+
raise GitExecuteError, 'Unexpected branch line format' unless match_data
|
396
|
+
next nil if match_data[:not_a_branch] || match_data[:detached_ref]
|
397
|
+
[
|
398
|
+
match_data[:refname],
|
399
|
+
!match_data[:current].nil?,
|
400
|
+
!match_data[:worktree].nil?,
|
401
|
+
match_data[:symref]
|
402
|
+
]
|
403
|
+
end.compact
|
357
404
|
end
|
358
405
|
|
359
406
|
def worktrees_all
|
@@ -772,11 +819,16 @@ module Git
|
|
772
819
|
#
|
773
820
|
# @param [String] branch
|
774
821
|
# @param [Hash] opts
|
775
|
-
def checkout(branch, opts = {})
|
822
|
+
def checkout(branch = nil, opts = {})
|
823
|
+
if branch.is_a?(Hash) && opts == {}
|
824
|
+
opts = branch
|
825
|
+
branch = nil
|
826
|
+
end
|
827
|
+
|
776
828
|
arr_opts = []
|
777
829
|
arr_opts << '-b' if opts[:new_branch] || opts[:b]
|
778
830
|
arr_opts << '--force' if opts[:force] || opts[:f]
|
779
|
-
arr_opts << branch
|
831
|
+
arr_opts << branch if branch
|
780
832
|
arr_opts << opts[:start_point] if opts[:start_point] && arr_opts.include?('-b')
|
781
833
|
|
782
834
|
command('checkout', *arr_opts)
|
@@ -908,20 +960,37 @@ module Git
|
|
908
960
|
command('fetch', *arr_opts)
|
909
961
|
end
|
910
962
|
|
911
|
-
def push(remote, branch =
|
963
|
+
def push(remote = nil, branch = nil, opts = nil)
|
964
|
+
if opts.nil? && branch.instance_of?(Hash)
|
965
|
+
opts = branch
|
966
|
+
branch = nil
|
967
|
+
end
|
968
|
+
|
969
|
+
if opts.nil? && remote.instance_of?(Hash)
|
970
|
+
opts = remote
|
971
|
+
remote = nil
|
972
|
+
end
|
973
|
+
|
974
|
+
opts ||= {}
|
975
|
+
|
912
976
|
# Small hack to keep backwards compatibility with the 'push(remote, branch, tags)' method signature.
|
913
977
|
opts = {:tags => opts} if [true, false].include?(opts)
|
914
978
|
|
979
|
+
raise ArgumentError, "You must specify a remote if a branch is specified" if remote.nil? && !branch.nil?
|
980
|
+
|
915
981
|
arr_opts = []
|
916
982
|
arr_opts << '--mirror' if opts[:mirror]
|
917
983
|
arr_opts << '--delete' if opts[:delete]
|
918
984
|
arr_opts << '--force' if opts[:force] || opts[:f]
|
919
|
-
arr_opts <<
|
985
|
+
Array(opts[:push_option]).each { |o| arr_opts << '--push-option' << o } if opts[:push_option]
|
986
|
+
arr_opts << remote if remote
|
987
|
+
arr_opts_with_branch = arr_opts.dup
|
988
|
+
arr_opts_with_branch << branch if branch
|
920
989
|
|
921
990
|
if opts[:mirror]
|
922
|
-
command('push', *
|
991
|
+
command('push', *arr_opts_with_branch)
|
923
992
|
else
|
924
|
-
command('push', *
|
993
|
+
command('push', *arr_opts_with_branch)
|
925
994
|
command('push', '--tags', *arr_opts) if opts[:tags]
|
926
995
|
end
|
927
996
|
end
|
data/lib/git/remote.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module Git
|
2
2
|
class Remote < Path
|
3
|
-
|
3
|
+
|
4
4
|
attr_accessor :name, :url, :fetch_opts
|
5
|
-
|
5
|
+
|
6
6
|
def initialize(base, name)
|
7
7
|
@base = base
|
8
8
|
config = @base.lib.config_remote(name)
|
@@ -10,27 +10,29 @@ module Git
|
|
10
10
|
@url = config['url']
|
11
11
|
@fetch_opts = config['fetch']
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
def fetch(opts={})
|
15
15
|
@base.fetch(@name, opts)
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
# merge this remote locally
|
19
|
-
def merge(branch =
|
20
|
-
|
19
|
+
def merge(branch = @base.current_branch)
|
20
|
+
remote_tracking_branch = "#{@name}/#{branch}"
|
21
|
+
@base.merge(remote_tracking_branch)
|
21
22
|
end
|
22
|
-
|
23
|
-
def branch(branch =
|
24
|
-
|
23
|
+
|
24
|
+
def branch(branch = @base.current_branch)
|
25
|
+
remote_tracking_branch = "#{@name}/#{branch}"
|
26
|
+
Git::Branch.new(@base, remote_tracking_branch)
|
25
27
|
end
|
26
|
-
|
28
|
+
|
27
29
|
def remove
|
28
|
-
@base.lib.remote_remove(@name)
|
30
|
+
@base.lib.remote_remove(@name)
|
29
31
|
end
|
30
|
-
|
32
|
+
|
31
33
|
def to_s
|
32
34
|
@name
|
33
35
|
end
|
34
|
-
|
36
|
+
|
35
37
|
end
|
36
38
|
end
|
data/lib/git/version.rb
CHANGED
data/lib/git.rb
CHANGED
@@ -1,7 +1,32 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
require 'active_support/deprecation'
|
2
|
+
|
3
|
+
module Git
|
4
|
+
# An object used to manage deprecations
|
5
|
+
#
|
6
|
+
# A ActiveSupport::Deprecation object used to manage the deprecations scheduled
|
7
|
+
# to be removed in the next major release of the `git`` gem.
|
8
|
+
#
|
9
|
+
# @example Deprecate a method
|
10
|
+
# Git.deprecation.deprecate_methods(Git::Branch, stashes: 'use Git::Base#stash_list instead')
|
11
|
+
#
|
12
|
+
# @example Set the deprecation behavior
|
13
|
+
# # Log all deprecation warnings to $stderr (the default)
|
14
|
+
# Git.deprecation.behavior = :stderr
|
15
|
+
#
|
16
|
+
# # Raise an ActiveSupport::DeprecationException
|
17
|
+
# Git.deprecation.behavior = :raise
|
18
|
+
#
|
19
|
+
# # Do nothing
|
20
|
+
# Git.deprecation.behavior = :raise
|
21
|
+
#
|
22
|
+
# @see https://api.rubyonrails.org/classes/ActiveSupport/Deprecation.html ActiveSupport::Deprecation
|
23
|
+
#
|
24
|
+
# @return [ActiveSupport::Deprecation]
|
25
|
+
#
|
26
|
+
def self.deprecation
|
27
|
+
@deprecation ||= ActiveSupport::Deprecation.new('2.0.0', 'git')
|
28
|
+
end
|
29
|
+
end
|
5
30
|
|
6
31
|
require 'git/author'
|
7
32
|
require 'git/base'
|
@@ -175,6 +200,46 @@ module Git
|
|
175
200
|
Base.clone(repository_url, directory, options)
|
176
201
|
end
|
177
202
|
|
203
|
+
# Returns the name of the default branch of the given repository
|
204
|
+
#
|
205
|
+
# @example with a URI string
|
206
|
+
# Git.default_branch('https://github.com/ruby-git/ruby-git') # => 'master'
|
207
|
+
# Git.default_branch('https://github.com/rspec/rspec-core') # => 'main'
|
208
|
+
#
|
209
|
+
# @example with a URI object
|
210
|
+
# repository_uri = URI('https://github.com/ruby-git/ruby-git')
|
211
|
+
# Git.default_branch(repository_uri) # => 'master'
|
212
|
+
#
|
213
|
+
# @example with a local repository
|
214
|
+
# Git.default_branch('.') # => 'master'
|
215
|
+
#
|
216
|
+
# @example with a local repository Pathname
|
217
|
+
# repository_path = Pathname('.')
|
218
|
+
# Git.default_branch(repository_path) # => 'master'
|
219
|
+
#
|
220
|
+
# @example with the logging option
|
221
|
+
# logger = Logger.new(STDOUT, level: Logger::INFO)
|
222
|
+
# Git.default_branch('.', log: logger) # => 'master'
|
223
|
+
# I, [2022-04-13T16:01:33.221596 #18415] INFO -- : git '-c' 'core.quotePath=true' '-c' 'color.ui=false' ls-remote '--symref' '--' '.' 'HEAD' 2>&1
|
224
|
+
#
|
225
|
+
# @param repository [URI, Pathname, String] The (possibly remote) repository to get the default branch name for
|
226
|
+
#
|
227
|
+
# See [GIT URLS](https://git-scm.com/docs/git-clone#_git_urls_a_id_urls_a)
|
228
|
+
# for more information.
|
229
|
+
#
|
230
|
+
# @param [Hash] options The options for this command (see list of valid
|
231
|
+
# options below)
|
232
|
+
#
|
233
|
+
# @option options [Logger] :log A logger to use for Git operations. Git
|
234
|
+
# commands are logged at the `:info` level. Additional logging is done
|
235
|
+
# at the `:debug` level.
|
236
|
+
#
|
237
|
+
# @return [String] the name of the default branch
|
238
|
+
#
|
239
|
+
def self.default_branch(repository, options = {})
|
240
|
+
Base.repository_default_branch(repository, options)
|
241
|
+
end
|
242
|
+
|
178
243
|
# Export the current HEAD (or a branch, if <tt>options[:branch]</tt>
|
179
244
|
# is specified) into the +name+ directory, then remove all traces of git from the
|
180
245
|
# directory.
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.17.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: 2023-03-
|
11
|
+
date: 2023-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.0.0
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: addressable
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|