Class: EacGit::Local::Remote
- Inherits:
-
Object
- Object
- EacGit::Local::Remote
- 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
- #add(url) ⇒ String
- #exist? ⇒ Boolean
-
#git_command ⇒ EacRubyUtils::Envs::Command
EacRubyUtils::Envs::Command.
- #push ⇒ EacGit::Local::Remote::Push
- #remote_reference ⇒ String
- #remove ⇒ String
- #url ⇒ String?
- #url=(new_url) ⇒ String
- #url_get ⇒ String?
- #url_set(url) ⇒ String
Methods included from RemoteLike
Instance Method Details
#add(url) ⇒ 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
18 19 20 |
# File 'lib/eac_git/local/remote.rb', line 18 def exist? url.present? end |
#git_command ⇒ EacRubyUtils::Envs::Command
Returns EacRubyUtils::Envs::Command.
23 24 25 |
# File 'lib/eac_git/local/remote.rb', line 23 def git_command(*) local.command(*) end |
#push ⇒ EacGit::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_reference ⇒ String
33 34 35 |
# File 'lib/eac_git/local/remote.rb', line 33 def remote_reference name end |
#remove ⇒ String
38 39 40 |
# File 'lib/eac_git/local/remote.rb', line 38 def remove local.command('remote', 'remove', name).execute! end |
#url ⇒ String?
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
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_get ⇒ String?
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
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 |