Class: Remotes::Remote
- Inherits:
-
Object
- Object
- Remotes::Remote
- Defined in:
- lib/remotes/remote.rb
Instance Method Summary collapse
- #fetch_specs ⇒ Object
- #fetch_url ⇒ Object
- #get_upstream(branch) ⇒ Object
-
#initialize(config, name) ⇒ Remote
constructor
A new instance of Remote.
- #push_specs ⇒ Object
- #push_url ⇒ Object
- #receiver ⇒ Object
- #set_upstream(branch, upstream) ⇒ Object
- #uploader ⇒ Object
Constructor Details
#initialize(config, name) ⇒ Remote
Returns a new instance of Remote.
6 7 8 9 10 11 |
# File 'lib/remotes/remote.rb', line 6 def initialize(config, name) @config = config @name = name @config.open end |
Instance Method Details
#fetch_specs ⇒ Object
17 18 19 |
# File 'lib/remotes/remote.rb', line 17 def fetch_specs @config.get_all(["remote", @name, "fetch"]) end |
#fetch_url ⇒ Object
13 14 15 |
# File 'lib/remotes/remote.rb', line 13 def fetch_url @config.get(["remote", @name, "url"]) end |
#get_upstream(branch) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/remotes/remote.rb', line 37 def get_upstream(branch) merge = @config.get(["branch", branch, "merge"]) targets = Refspec.(fetch_specs, [merge]) targets.keys.first end |
#push_specs ⇒ Object
25 26 27 |
# File 'lib/remotes/remote.rb', line 25 def push_specs @config.get_all(["remote", @name, "push"]) end |
#push_url ⇒ Object
21 22 23 |
# File 'lib/remotes/remote.rb', line 21 def push_url @config.get(["remote", @name, "pushurl"]) || fetch_url end |
#receiver ⇒ Object
33 34 35 |
# File 'lib/remotes/remote.rb', line 33 def receiver @config.get(["remote", @name, "receivepack"]) end |
#set_upstream(branch, upstream) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/remotes/remote.rb', line 44 def set_upstream(branch, upstream) ref_name = Refspec.invert(fetch_specs, upstream) return nil unless ref_name @config.open_for_update @config.set(["branch", branch, "remote"], @name) @config.set(["branch", branch, "merge"], ref_name) @config.save ref_name end |
#uploader ⇒ Object
29 30 31 |
# File 'lib/remotes/remote.rb', line 29 def uploader @config.get(["remote", @name, "uploadpack"]) end |