Class: Git::Remote Deprecated
- Inherits:
-
Object
- Object
- Git::Remote
- Defined in:
- lib/git/remote.rb
Overview
Use Git::Repository::RemoteOperations#remote_list and the repository-level remote operations instead
Git::Repository::RemoteOperations#remote_list returns immutable
RemoteInfo value objects. Operations that lived on this class are
called on the repository with the remote name instead (for example
Git::Repository::RemoteOperations#fetch and
Git::Repository::RemoteOperations#remote_remove). Constructing a
Git::Remote emits a deprecation warning.
A remote in a Git repository
Remote objects provide access to remote metadata and operations like fetch,
merge, and remove. This class and Git::Repository#remote, which returns
it, are both deprecated: read remote configuration through
Git::Repository::RemoteOperations#remote_list and call the
repository-level operations with the remote name instead.
Instance Attribute Summary collapse
-
#fetch_opts ⇒ String?
The fetch refspec for this remote.
-
#name ⇒ String
The name of this remote (e.g.
'origin'). -
#url ⇒ String?
The URL of this remote.
Instance Method Summary collapse
-
#branch(branch = nil) ⇒ Git::Branch
deprecated
Deprecated.
Use
Git::Repository#branch_list("#{name}/#{branch || current_branch}").firstinsteadWith no argument this method falls back to the current branch, so the replacement has to supply
Git::Repository#current_branchitself. The replacement returns a BranchInfo value object rather than a Branch, and returnsnilwhen the remote-tracking branch does not exist. -
#fetch(opts = {}) ⇒ String
Fetches from this remote.
-
#initialize(base, name) ⇒ Remote
constructor
private
Initialize a new Remote object.
-
#merge(branch = nil) ⇒ String
Merges this remote into the given (or current) local branch.
-
#remove ⇒ Git::CommandLine::Result
Removes this remote from the repository.
-
#to_s ⇒ String
Returns the name of this remote as a string.
Constructor Details
#initialize(base, name) ⇒ Remote
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Do not construct directly. Git::Repository#remote is deprecated as
well; use Git::Repository::RemoteOperations#remote_list and the
repository-level remote operations instead.
Initialize a new Remote object
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/git/remote.rb', line 64 def initialize(base, name) Git::Deprecation.warn( 'Git::Remote is deprecated and will be removed in v6.0.0. ' \ 'Use Git::Repository#remote_list and the repository-level remote operations instead.' ) @base = base # config_remote is deprecated too; silence it so one Git::Remote.new emits one warning config = Git::Deprecation.silence { remote_repository.config_remote(name) } @name = name @url = config['url'] @fetch_opts = config['fetch'] end |
Instance Attribute Details
#fetch_opts ⇒ String?
The fetch refspec for this remote
50 51 52 |
# File 'lib/git/remote.rb', line 50 def fetch_opts @fetch_opts end |
#name ⇒ String
The name of this remote (e.g. 'origin')
38 39 40 |
# File 'lib/git/remote.rb', line 38 def name @name end |
#url ⇒ String?
The URL of this remote
44 45 46 |
# File 'lib/git/remote.rb', line 44 def url @url end |
Instance Method Details
#branch(branch = nil) ⇒ Git::Branch
Use
Git::Repository#branch_list("#{name}/#{branch || current_branch}").first
instead
With no argument this method falls back to the current branch, so the
replacement has to supply Git::Repository#current_branch itself. The
replacement returns a BranchInfo value object rather than a
Branch, and returns nil when the remote-tracking branch does
not exist.
Returns a Branch object for the given branch on this remote
152 153 154 155 |
# File 'lib/git/remote.rb', line 152 def branch(branch = nil) branch ||= remote_repository.current_branch Git::Branch.new(@base, "#{@name}/#{branch}") end |
#fetch(opts = {}) ⇒ String
Fetches from this remote
112 113 114 |
# File 'lib/git/remote.rb', line 112 def fetch(opts = {}) remote_repository.fetch(@name, opts) end |
#merge(branch = nil) ⇒ String
Merges this remote into the given (or current) local branch
127 128 129 130 131 |
# File 'lib/git/remote.rb', line 127 def merge(branch = nil) branch ||= remote_repository.current_branch remote_tracking_branch = "#{@name}/#{branch}" remote_repository.merge(remote_tracking_branch) end |
#remove ⇒ Git::CommandLine::Result
Removes this remote from the repository
166 167 168 |
# File 'lib/git/remote.rb', line 166 def remove remote_repository.remote_remove(@name) end |
#to_s ⇒ String
Returns the name of this remote as a string
177 178 179 |
# File 'lib/git/remote.rb', line 177 def to_s @name end |