Class: Remotes::Remote

Inherits:
Object
  • Object
show all
Defined in:
lib/remotes/remote.rb

Instance Method Summary collapse

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_specsObject



17
18
19
# File 'lib/remotes/remote.rb', line 17

def fetch_specs
  @config.get_all(["remote", @name, "fetch"])
end

#fetch_urlObject



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.expand(fetch_specs, [merge])

  targets.keys.first
end

#push_specsObject



25
26
27
# File 'lib/remotes/remote.rb', line 25

def push_specs
  @config.get_all(["remote", @name, "push"])
end

#push_urlObject



21
22
23
# File 'lib/remotes/remote.rb', line 21

def push_url
  @config.get(["remote", @name, "pushurl"]) || fetch_url
end

#receiverObject



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

#uploaderObject



29
30
31
# File 'lib/remotes/remote.rb', line 29

def uploader
  @config.get(["remote", @name, "uploadpack"])
end