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
14 15 16 |
# File 'lib/eac_git/local/remote.rb', line 14 def add(url) local.command('remote', 'add', name, url).execute! end |
#exist? ⇒ Boolean
19 20 21 |
# File 'lib/eac_git/local/remote.rb', line 19 def exist? url.present? end |
#git_command ⇒ EacRubyUtils::Envs::Command
Returns EacRubyUtils::Envs::Command.
24 25 26 |
# File 'lib/eac_git/local/remote.rb', line 24 def git_command(*) local.command(*) end |
#push ⇒ EacGit::Local::Remote::Push
29 30 31 |
# File 'lib/eac_git/local/remote.rb', line 29 def push ::EacGit::Local::Remote::Push.new(self) end |
#remote_reference ⇒ String
34 35 36 |
# File 'lib/eac_git/local/remote.rb', line 34 def remote_reference name end |
#remove ⇒ String
39 40 41 |
# File 'lib/eac_git/local/remote.rb', line 39 def remove local.command('remote', 'remove', name).execute! end |
#url ⇒ String?
44 45 46 |
# File 'lib/eac_git/local/remote.rb', line 44 def url url_get(exit_outputs: { NO_SUCH_REMOTE_CODE => nil }).if_present(nil, &:strip) end |
#url=(new_url) ⇒ String
49 50 51 52 53 54 55 56 57 |
# File 'lib/eac_git/local/remote.rb', line 49 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?
60 61 62 |
# File 'lib/eac_git/local/remote.rb', line 60 def url_get(**) local.command('remote', 'get-url', name).execute!(**) end |
#url_set(url) ⇒ String
66 67 68 |
# File 'lib/eac_git/local/remote.rb', line 66 def url_set(url) local.command('remote', 'set-url', name, url).execute! end |