Class: EacGit::Local::Remote

Inherits:
Object
  • Object
show all
Includes:
RemoteLike
Defined in:
lib/eac_git/local/remote.rb,
lib/eac_git/local/remote/push.rb

Defined Under Namespace

Classes: Push

Constant Summary collapse

NO_SUCH_REMOTE_CODE =
512

Instance Method Summary collapse

Methods included from RemoteLike

#fetch, #ls

Instance Method Details

#add(url) ⇒ String

Returns:

  • (String)


13
14
15
# File 'lib/eac_git/local/remote.rb', line 13

def add(url)
  local.command('remote', 'add', name, url).execute!
end

#exist?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/eac_git/local/remote.rb', line 18

def exist?
  url.present?
end

#git_commandEacRubyUtils::Envs::Command

Returns EacRubyUtils::Envs::Command.

Returns:

  • (EacRubyUtils::Envs::Command)

    EacRubyUtils::Envs::Command



23
24
25
# File 'lib/eac_git/local/remote.rb', line 23

def git_command(*)
  local.command(*)
end

#pushEacGit::Local::Remote::Push



28
29
30
# File 'lib/eac_git/local/remote.rb', line 28

def push
  ::EacGit::Local::Remote::Push.new(self)
end

#remote_referenceString

Returns:

  • (String)


33
34
35
# File 'lib/eac_git/local/remote.rb', line 33

def remote_reference
  name
end

#removeString

Returns:

  • (String)


38
39
40
# File 'lib/eac_git/local/remote.rb', line 38

def remove
  local.command('remote', 'remove', name).execute!
end

#urlString?

Returns:

  • (String, nil)


43
44
45
# File 'lib/eac_git/local/remote.rb', line 43

def url
  url_get(exit_outputs: { NO_SUCH_REMOTE_CODE => nil }).if_present(nil, &:strip)
end

#url=(new_url) ⇒ String

Returns:

  • (String)


48
49
50
51
52
53
54
55
56
# File 'lib/eac_git/local/remote.rb', line 48

def url=(new_url)
  case [exist?, new_url.present?]
  when [false, false] # do nothing
  when [false, true] then add(new_url)
  when [true, false] then remove
  when [true, true] then url_set(new_url)
  else ibr
  end
end

#url_getString?

Returns:

  • (String, nil)


59
60
61
# File 'lib/eac_git/local/remote.rb', line 59

def url_get(**)
  local.command('remote', 'get-url', name).execute!(**)
end

#url_set(url) ⇒ String

Parameters:

  • url (String)

Returns:

  • (String)


65
66
67
# File 'lib/eac_git/local/remote.rb', line 65

def url_set(url)
  local.command('remote', 'set-url', name, url).execute!
end