git 5.2.0 → 5.4.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/lib/git/tag_info.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'git/author'
3
+ require 'time'
4
+
5
+ require 'git/author_info'
4
6
 
5
7
  module Git
6
8
  # Value object representing tag metadata from git tag output
@@ -9,19 +11,25 @@ module Git
9
11
  # commands. It contains only the data parsed from git output without any
10
12
  # repository context or operations.
11
13
  #
14
+ # The tagger identity is a nested {Git::AuthorInfo}. Its `date` is a `Time`
15
+ # parsed from git's strict ISO 8601 output, not an ISO 8601 string.
16
+ #
12
17
  # @example Annotated tag
13
18
  # info = Git::TagInfo.new(
14
19
  # name: 'v1.0.0',
15
20
  # oid: 'abc123def456', # tag object's ID
16
21
  # target_oid: 'def456abc789', # commit it points to
17
22
  # objecttype: 'tag',
18
- # tagger_name: 'John Doe',
19
- # tagger_email: '<john@example.com>',
20
- # tagger_date: '2024-01-15T10:30:00-08:00',
23
+ # tagger: Git::AuthorInfo.new(
24
+ # name: 'John Doe',
25
+ # email: 'john@example.com',
26
+ # date: Time.iso8601('2024-01-15T10:30:00-08:00')
27
+ # ),
21
28
  # message: 'Release version 1.0.0'
22
29
  # )
23
30
  # info.annotated? #=> true
24
31
  # info.tagger.name #=> 'John Doe'
32
+ # info.tagger.date #=> 2024-01-15 10:30:00 -0800
25
33
  #
26
34
  # @example Lightweight tag
27
35
  # info = Git::TagInfo.new(
@@ -29,18 +37,19 @@ module Git
29
37
  # oid: nil, # no tag object exists
30
38
  # target_oid: 'def456abc789', # commit ID
31
39
  # objecttype: 'commit',
32
- # tagger_name: nil,
33
- # tagger_email: nil,
34
- # tagger_date: nil,
40
+ # tagger: nil,
35
41
  # message: nil
36
42
  # )
37
43
  # info.lightweight? #=> true
38
44
  # info.tagger #=> nil
39
45
  #
40
- # @see Git::Tag for the full-featured tag object with operations
46
+ # @see Git::Repository::ObjectOperations#tag_list for the repository method
47
+ # that returns these
41
48
  #
42
49
  # @see Git::Commands::Tag::List for the command that produces these
43
50
  #
51
+ # @see Git::AuthorInfo for the nested tagger identity
52
+ #
44
53
  # @api public
45
54
  #
46
55
  # @!attribute [r] name
@@ -65,19 +74,18 @@ module Git
65
74
  # @!attribute [r] objecttype
66
75
  # @return [String] 'tag' for annotated tags, 'commit' for lightweight tags
67
76
  #
68
- # @!attribute [r] tagger_name
69
- # @return [String, nil] the tagger's name, or nil for lightweight tags
77
+ # @!attribute [r] tagger
78
+ # The identity of the person who created the tag object.
70
79
  #
71
- # @!attribute [r] tagger_email
72
- # @return [String, nil] the tagger's email, or nil for lightweight tags
80
+ # Lightweight tags have no tag object and therefore no tagger. The nested
81
+ # `email` has no angle brackets and the nested `date` is a `Time`.
73
82
  #
74
- # @!attribute [r] tagger_date
75
- # @return [String, nil] the tag date in ISO 8601 format, or nil for lightweight tags
83
+ # @return [Git::AuthorInfo, nil] the tagger, or nil for lightweight tags
76
84
  #
77
85
  # @!attribute [r] message
78
86
  # @return [String, nil] the tag message, or nil for lightweight tags
79
87
  #
80
- TagInfo = Data.define(:name, :oid, :target_oid, :objecttype, :tagger_name, :tagger_email, :tagger_date, :message) do
88
+ TagInfo = Data.define(:name, :oid, :target_oid, :objecttype, :tagger, :message) do
81
89
  # @return [Boolean] true if this is an annotated tag (oid is present)
82
90
  def annotated?
83
91
  !oid.nil?
@@ -87,20 +95,5 @@ module Git
87
95
  def lightweight?
88
96
  oid.nil?
89
97
  end
90
-
91
- # Return the tagger as an Author object
92
- #
93
- # @return [Git::Author, nil] the tagger as an Author object, or nil for lightweight tags
94
- def tagger
95
- return nil unless annotated? && tagger_name && tagger_email
96
-
97
- # Git::Author expects format "Name <email> timestamp timezone"
98
- # We construct a minimal format that will parse correctly
99
- author = Git::Author.new('')
100
- author.name = tagger_name
101
- # Remove angle brackets if present
102
- author.email = tagger_email.gsub(/\A<|>\z/, '')
103
- author
104
- end
105
98
  end
106
99
  end
data/lib/git/version.rb CHANGED
@@ -4,7 +4,7 @@ module Git
4
4
  # The current gem version
5
5
  #
6
6
  # @return [String] the current gem version
7
- VERSION = '5.2.0'
7
+ VERSION = '5.4.0'
8
8
 
9
9
  # Represents a git version with major, minor, and patch components
10
10
  #
data/lib/git/worktree.rb CHANGED
@@ -12,6 +12,17 @@ module Git
12
12
  # worktree.add
13
13
  # worktree.remove
14
14
  #
15
+ # @deprecated Use {Git::Repository::WorktreeOperations#worktree_list} and the
16
+ # path-based worktree operations on {Git::Repository} instead
17
+ #
18
+ # {Git::Repository::WorktreeOperations#worktree_list} returns immutable
19
+ # {Git::WorktreeInfo} value objects. Operations that lived on this class are
20
+ # called on the repository with the worktree path instead (for example
21
+ # {Git::Repository::WorktreeOperations#worktree_add} and
22
+ # {Git::Repository::WorktreeOperations#worktree_remove}). {#gcommit},
23
+ # {#add}, and {#remove} each emit a deprecation warning; the `dir`, `full`,
24
+ # `to_s`, and `to_a` readers do not.
25
+ #
15
26
  # @api public
16
27
  #
17
28
  class Worktree
@@ -69,7 +80,19 @@ module Git
69
80
  # @raise [Git::FailedError] if git must resolve the commit and exits with a
70
81
  # non-zero exit status
71
82
  #
83
+ # @deprecated Use {Git::WorktreeInfo#head} from
84
+ # {Git::Repository::WorktreeOperations#worktree_list} instead
85
+ #
86
+ # `head` is always the commit SHA as a `String` (or `nil` for a bare main
87
+ # worktree). Call `repo.gcommit(info.head)` for the commit object.
88
+ #
89
+ # @see Git::WorktreeInfo#head
90
+ #
72
91
  def gcommit
92
+ Git::Deprecation.warn(
93
+ 'Git::Worktree#gcommit is deprecated and will be removed in v6.0.0. ' \
94
+ 'Use Git::WorktreeInfo#head from Git::Repository#worktree_list instead.'
95
+ )
73
96
  @gcommit ||= worktree_repository.gcommit(@full)
74
97
  @gcommit
75
98
  end
@@ -87,7 +110,15 @@ module Git
87
110
  #
88
111
  # @raise [Git::FailedError] if git exits with a non-zero exit status
89
112
  #
113
+ # @deprecated Use {Git::Repository::WorktreeOperations#worktree_add} instead
114
+ #
115
+ # @see Git::Repository::WorktreeOperations#worktree_add
116
+ #
90
117
  def add
118
+ Git::Deprecation.warn(
119
+ 'Git::Worktree#add is deprecated and will be removed in v6.0.0. ' \
120
+ 'Use Git::Repository#worktree_add instead.'
121
+ )
91
122
  worktree_repository.worktree_add(@dir, @gcommit)
92
123
  end
93
124
 
@@ -102,7 +133,15 @@ module Git
102
133
  #
103
134
  # @raise [Git::FailedError] if git exits with a non-zero exit status
104
135
  #
136
+ # @deprecated Use {Git::Repository::WorktreeOperations#worktree_remove} instead
137
+ #
138
+ # @see Git::Repository::WorktreeOperations#worktree_remove
139
+ #
105
140
  def remove
141
+ Git::Deprecation.warn(
142
+ 'Git::Worktree#remove is deprecated and will be removed in v6.0.0. ' \
143
+ 'Use Git::Repository#worktree_remove instead.'
144
+ )
106
145
  worktree_repository.worktree_remove(@dir)
107
146
  end
108
147
 
@@ -0,0 +1,128 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Git
4
+ # Immutable value object for one entry of `git worktree list`
5
+ #
6
+ # Each entry carries what `git worktree list --porcelain` reports for a
7
+ # worktree: its path, the checked-out HEAD and branch, and whether it is bare,
8
+ # detached, locked, or prunable, with the reason git gives for the last two.
9
+ #
10
+ # @example A locked linked worktree with a branch checked out
11
+ # info = Git::WorktreeInfo.new(
12
+ # path: '/tmp/wt/linked',
13
+ # head: 'f3e2c1ffb860086504eeb27b77a1d0028b68fd8f',
14
+ # branch: 'refs/heads/linked',
15
+ # bare: false,
16
+ # detached: false,
17
+ # locked: true,
18
+ # lock_reason: 'on purpose',
19
+ # prunable: false,
20
+ # prune_reason: nil
21
+ # )
22
+ #
23
+ # info.path # => '/tmp/wt/linked'
24
+ # info.head # => 'f3e2c1ffb860086504eeb27b77a1d0028b68fd8f'
25
+ # info.branch # => 'refs/heads/linked'
26
+ # info.locked? # => true
27
+ # info.lock_reason # => 'on purpose'
28
+ # info.detached? # => false
29
+ # info.to_s # => '/tmp/wt/linked'
30
+ #
31
+ # @example Pass an entry back to a worktree operation
32
+ # info = repo.worktree_list.find { |w| w.branch == 'refs/heads/linked' }
33
+ # repo.worktree_remove(info)
34
+ #
35
+ # @see Git::Repository::WorktreeOperations#worktree_list for the repository
36
+ # method that returns these
37
+ #
38
+ # @api public
39
+ #
40
+ # @!attribute [r] path
41
+ # @return [String] the worktree directory as git reports it
42
+ #
43
+ # @!attribute [r] head
44
+ # @return [String, nil] the full object ID of the checked-out HEAD commit
45
+ # (the all-zero object ID when the branch has no commits yet), or nil for a
46
+ # bare main worktree
47
+ #
48
+ # @!attribute [r] branch
49
+ # @return [String, nil] the full refname of the checked-out branch (e.g.,
50
+ # 'refs/heads/main'), or nil when the worktree is bare or detached
51
+ #
52
+ # @!attribute [r] bare
53
+ # @return [Boolean] true if this is the main worktree of a bare repository
54
+ #
55
+ # @!attribute [r] detached
56
+ # @return [Boolean] true if HEAD is detached in this worktree
57
+ #
58
+ # @!attribute [r] locked
59
+ # @return [Boolean] true if the worktree is locked
60
+ #
61
+ # @!attribute [r] lock_reason
62
+ # @return [String, nil] the reason given when the worktree was locked, or nil
63
+ # when it is not locked or was locked without a reason
64
+ #
65
+ # @!attribute [r] prunable
66
+ # @return [Boolean] true if `git worktree prune` would remove this entry
67
+ #
68
+ # @!attribute [r] prune_reason
69
+ # @return [String, nil] git's explanation of why the entry is prunable, or
70
+ # nil when it is not prunable
71
+ #
72
+ WorktreeInfo = Data.define(
73
+ :path,
74
+ :head,
75
+ :branch,
76
+ :bare,
77
+ :detached,
78
+ :locked,
79
+ :lock_reason,
80
+ :prunable,
81
+ :prune_reason
82
+ ) do
83
+ # Whether this is the main worktree of a bare repository
84
+ #
85
+ # @example
86
+ # info.bare? # => false
87
+ #
88
+ # @return [Boolean] true if the worktree is bare
89
+ def bare? = bare
90
+
91
+ # Whether HEAD is detached in this worktree
92
+ #
93
+ # @example
94
+ # info.detached? # => false
95
+ #
96
+ # @return [Boolean] true if HEAD is detached
97
+ def detached? = detached
98
+
99
+ # Whether the worktree is locked
100
+ #
101
+ # @example
102
+ # info.locked? # => true
103
+ #
104
+ # @return [Boolean] true if the worktree is locked
105
+ def locked? = locked
106
+
107
+ # Whether `git worktree prune` would remove this entry
108
+ #
109
+ # @example
110
+ # info.prunable? # => false
111
+ #
112
+ # @return [Boolean] true if the entry is prunable
113
+ def prunable? = prunable
114
+
115
+ # Returns the worktree path
116
+ #
117
+ # Lets an entry be passed directly to the worktree operations that take a
118
+ # path, such as {Git::Repository::WorktreeOperations#worktree_remove}.
119
+ #
120
+ # @example Convert to string
121
+ # info.to_s # => '/tmp/wt/linked'
122
+ #
123
+ # @return [String] the worktree path
124
+ def to_s
125
+ path
126
+ end
127
+ end
128
+ end
data/lib/git/worktrees.rb CHANGED
@@ -10,6 +10,15 @@ module Git
10
10
  # worktrees = repo.worktrees
11
11
  # worktrees.each { |wt| puts wt.dir }
12
12
  #
13
+ # @deprecated Use {Git::Repository::WorktreeOperations#worktree_list} instead
14
+ #
15
+ # {Git::Repository::WorktreeOperations#worktree_list} returns
16
+ # `Array<Git::WorktreeInfo>` (immutable value objects). Look a worktree up
17
+ # by path with `worktree_list.find { |w| w.path == path }` in place of
18
+ # {#[]}, and call {Git::Repository::WorktreeOperations#worktree_prune} in
19
+ # place of {#prune}. Constructing a `Git::Worktrees` emits a deprecation
20
+ # warning.
21
+ #
13
22
  # @api public
14
23
  #
15
24
  class Worktrees
@@ -24,12 +33,21 @@ module Git
24
33
  #
25
34
  # @raise [Git::FailedError] if git exits with a non-zero exit status
26
35
  #
36
+ # @deprecated Use {Git::Repository::WorktreeOperations#worktree_list} instead
37
+ #
38
+ # @see Git::Repository::WorktreeOperations#worktree_list
39
+ #
27
40
  def initialize(base)
41
+ Git::Deprecation.warn(
42
+ 'Git::Worktrees is deprecated and will be removed in v6.0.0. ' \
43
+ 'Use Git::Repository#worktree_list instead.'
44
+ )
28
45
  @worktrees = {}
29
46
 
30
47
  @base = base
31
48
 
32
- worktree_repository.worktrees_all.each do |w|
49
+ # worktrees_all is deprecated too; silence it so one Git::Worktrees.new emits one warning
50
+ Git::Deprecation.silence { worktree_repository.worktrees_all }.each do |w|
33
51
  @worktrees[w[0]] = Git::Worktree.new(@base, w[0], w[1])
34
52
  end
35
53
  end
data/lib/git.rb CHANGED
@@ -46,6 +46,7 @@ module Git
46
46
  end
47
47
 
48
48
  require 'git/author'
49
+ require 'git/author_info'
49
50
  require 'git/branch'
50
51
  require 'git/branch_info'
51
52
  require 'git/branches'
@@ -74,6 +75,7 @@ require 'git/fsck_object'
74
75
  require 'git/fsck_result'
75
76
  require 'git/parsers/ls_remote'
76
77
  require 'git/parsers/remote'
78
+ require 'git/parsers/status'
77
79
  require 'git/version_constraint'
78
80
  require 'git/commands'
79
81
  require 'git/log'
@@ -82,6 +84,8 @@ require 'git/remote'
82
84
  require 'git/remote_info'
83
85
  require 'git/repository'
84
86
  require 'git/status'
87
+ require 'git/status_file_info'
88
+ require 'git/status_info'
85
89
  require 'git/stash'
86
90
  require 'git/stash_info'
87
91
  require 'git/stashes'
@@ -91,6 +95,7 @@ require 'git/tag_info'
91
95
  require 'git/url'
92
96
  require 'git/version'
93
97
  require 'git/worktree'
98
+ require 'git/worktree_info'
94
99
  require 'git/worktrees'
95
100
 
96
101
  # The Git module provides the basic functions to open a git
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.0
4
+ version: 5.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Chacon and others
@@ -311,6 +311,7 @@ files:
311
311
  - git.gemspec
312
312
  - lib/git.rb
313
313
  - lib/git/author.rb
314
+ - lib/git/author_info.rb
314
315
  - lib/git/branch.rb
315
316
  - lib/git/branch_delete_failure.rb
316
317
  - lib/git/branch_delete_result.rb
@@ -504,7 +505,9 @@ files:
504
505
  - lib/git/parsers/ls_tree.rb
505
506
  - lib/git/parsers/remote.rb
506
507
  - lib/git/parsers/stash.rb
508
+ - lib/git/parsers/status.rb
507
509
  - lib/git/parsers/tag.rb
510
+ - lib/git/parsers/worktree.rb
508
511
  - lib/git/path_resolver.rb
509
512
  - lib/git/remote.rb
510
513
  - lib/git/remote_info.rb
@@ -528,6 +531,8 @@ files:
528
531
  - lib/git/stash_info.rb
529
532
  - lib/git/stashes.rb
530
533
  - lib/git/status.rb
534
+ - lib/git/status_file_info.rb
535
+ - lib/git/status_info.rb
531
536
  - lib/git/tag_delete_failure.rb
532
537
  - lib/git/tag_delete_result.rb
533
538
  - lib/git/tag_info.rb
@@ -535,6 +540,7 @@ files:
535
540
  - lib/git/version.rb
536
541
  - lib/git/version_constraint.rb
537
542
  - lib/git/worktree.rb
543
+ - lib/git/worktree_info.rb
538
544
  - lib/git/worktrees.rb
539
545
  homepage: http://github.com/ruby-git/ruby-git
540
546
  licenses:
@@ -542,8 +548,8 @@ licenses:
542
548
  metadata:
543
549
  homepage_uri: http://github.com/ruby-git/ruby-git
544
550
  source_code_uri: http://github.com/ruby-git/ruby-git
545
- changelog_uri: https://rubydoc.info/gems/git/5.2.0/file/CHANGELOG.md
546
- documentation_uri: https://rubydoc.info/gems/git/5.2.0
551
+ changelog_uri: https://rubydoc.info/gems/git/5.4.0/file/CHANGELOG.md
552
+ documentation_uri: https://rubydoc.info/gems/git/5.4.0
547
553
  rubygems_mfa_required: 'true'
548
554
  rdoc_options: []
549
555
  require_paths: