From 2fea684fa3e899f5fbddcf4aec12f5be04e1f504 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Mon, 14 Jun 2021 14:42:13 -0400 Subject: [PATCH] Add :push option to remote_set_url. This allows specifying, for example: git.set_remote_url('upstream', 'git@github.com:foo/bar', push: true) --- lib/git/base.rb | 7 +++++-- lib/git/lib.rb | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/git/base.rb b/lib/git/base.rb index 2d931cf3..c58bafe8 100644 --- a/lib/git/base.rb +++ b/lib/git/base.rb @@ -402,11 +402,14 @@ def add_remote(name, url, opts = {}) # sets the url for a remote # url can be a git url or a Git::Base object if it's a local reference # + # accepts options: + # :push + # # @git.set_remote_url('scotts_git', 'git://repo.or.cz/rubygit.git') # - def set_remote_url(name, url) + def set_remote_url(name, url, opts = {}) url = url.repo.path if url.is_a?(Git::Base) - self.lib.remote_set_url(name, url) + self.lib.remote_set_url(name, url, opts) Git::Remote.new(self, name) end diff --git a/lib/git/lib.rb b/lib/git/lib.rb index cb408246..907c7196 100644 --- a/lib/git/lib.rb +++ b/lib/git/lib.rb @@ -830,10 +830,13 @@ def remote_add(name, url, opts = {}) command('remote', arr_opts) end - def remote_set_url(name, url) + # accepts options: + # :push + def remote_set_url(name, url, opts = {}) arr_opts = ['set-url'] arr_opts << name arr_opts << url + arr_opts << '--push' if opts[:push] command('remote', arr_opts) end