Class: Git::Remote
- Inherits:
-
Object
- Object
- Git::Remote
- Defined in:
- lib/git/remote.rb
Overview
A remote in a Git repository
Remote objects provide access to remote metadata and operations like fetch,
merge, and remove. They should be obtained via Git::Repository#remote,
not constructed directly.
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
Returns a Branch object for the given branch on this remote.
-
#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::CommandLineResult
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.
Use Git::Repository#remote instead of constructing directly
Initialize a new Remote object
49 50 51 52 53 54 55 |
# File 'lib/git/remote.rb', line 49 def initialize(base, name) @base = base config = 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
37 38 39 |
# File 'lib/git/remote.rb', line 37 def fetch_opts @fetch_opts end |
#name ⇒ String
The name of this remote (e.g. 'origin')
25 26 27 |
# File 'lib/git/remote.rb', line 25 def name @name end |
#url ⇒ String?
The URL of this remote
31 32 33 |
# File 'lib/git/remote.rb', line 31 def url @url end |
Instance Method Details
#branch(branch = nil) ⇒ Git::Branch
Returns a Branch object for the given branch on this remote
98 99 100 101 102 103 |
# File 'lib/git/remote.rb', line 98 def branch(branch = nil) branch ||= remote_repository.current_branch remote_tracking_branch = "#{@name}/#{branch}" branch_info = build_branch_info(remote_tracking_branch) Git::Branch.new(@base, branch_info) end |
#fetch(opts = {}) ⇒ String
Fetches from this remote
68 69 70 |
# File 'lib/git/remote.rb', line 68 def fetch(opts = {}) remote_repository.fetch(@name, opts) end |
#merge(branch = nil) ⇒ String
Merges this remote into the given (or current) local branch
83 84 85 86 87 |
# File 'lib/git/remote.rb', line 83 def merge(branch = nil) branch ||= remote_repository.current_branch remote_tracking_branch = "#{@name}/#{branch}" remote_repository.merge(remote_tracking_branch) end |
#remove ⇒ Git::CommandLineResult
Removes this remote from the repository
114 115 116 |
# File 'lib/git/remote.rb', line 114 def remove remote_repository.remote_remove(@name) end |
#to_s ⇒ String
Returns the name of this remote as a string
125 126 127 |
# File 'lib/git/remote.rb', line 125 def to_s @name end |