module Git::Repository::RemoteOperations::Private
Helpers private to the ‘RemoteOperations` topic module
@api private
Public Instance Methods
Source
# File lib/git/repository/remote_operations.rb, line 922 def config_list(execution_context) lines = Git::Commands::ConfigOptionSyntax::List.new(execution_context).call.stdout.split("\n") lines.each_with_object({}) do |line, hsh| key, value = line.split('=', 2) hsh[key] = value || '' end end
Retrieve all config entries as a flat hash
Runs ‘git config –list` and parses each `key=value` line into a hash. When no value is present for a key, the value defaults to an empty string.
@param execution_context [Git::ExecutionContext::Repository] the
execution context for the repository
@return [Hash{String => String}] all visible config entries, keyed by
their full dotted key names For example, `"remote.origin.url"` is a valid key.
@api private
Source
# File lib/git/repository/remote_operations.rb, line 901 def normalize_add_remote_keys(opts) normalized = opts.dup normalized[:fetch] = normalized.delete(:with_fetch) if normalized.key?(:with_fetch) normalized end
Normalize deprecated option keys for {#remote_add} to their canonical equivalents
Renames the deprecated ‘:with_fetch` key to `:fetch`, removing it from the copy. When both keys are present, `:with_fetch` takes precedence.
@param opts [Hash] the raw options hash passed by the caller
@option opts [Boolean, nil] :with_fetch (nil) deprecated alias for
immediate fetch behavior
@option opts [Boolean, nil] :fetch (nil) fetch from the remote after adding
@option opts [String, nil] :track (nil) track the given branch during fetch
@return [Hash] a new hash with all applicable keys normalized
@api private
Source
# File lib/git/repository/remote_operations.rb, line 751 def normalize_fetch_keys(opts) opts.transform_keys do |k| sym = k.is_a?(Symbol) ? k : k.to_sym FETCH_KEY_NORMALIZATIONS.fetch(sym, sym) end end
Normalize dash-style option keys to their underscore equivalents
Converts any key in {FETCH_KEY_NORMALIZATIONS} from its dash-style symbol form (e.g., ‘:’update-head-ok’‘) to the canonical underscore-style form (e.g., `:update_head_ok`). Unrecognized keys are returned unchanged.
@param opts [Hash] the raw options hash passed by the caller
@option opts [Object] :‘prune-tags’ a legacy dash-style fetch option value
@option opts [Object] :‘update-head-ok’ a legacy dash-style fetch option
value
@return [Hash] a new hash with all applicable keys normalized
@api private
Source
# File lib/git/repository/remote_operations.rb, line 789 def normalize_push_args(remote, branch, opts) if branch.is_a?(Hash) opts = branch branch = nil elsif remote.is_a?(Hash) opts = remote remote = nil end opts ||= {} # Backwards compatibility for `push(remote, branch, true)` to push tags # without requiring the caller to use keyword arguments opts = { tags: opts } if [true, false].include?(opts) [remote, branch, opts] end
Normalize the flexible argument list accepted by {RemoteOperations#push}
Handles three call forms:
-
‘push(opts)` — Hash promoted from `remote` position
-
‘push(remote, opts)` — Hash promoted from `branch` position
-
‘push(remote, branch, true|false)` — Boolean `opts` converted to `{ tags: opts }` for backward compatibility
@param remote [String, Hash, nil] remote name, URL, or opts hash
@param branch [String, Hash, nil] branch/refspec, or opts hash
@param opts [Hash, Boolean, nil] options hash or legacy Boolean shorthand
@option opts [Boolean, nil] :all (nil) push all branches
@option opts [Boolean, nil] :mirror (nil) mirror all refs
@option opts [Boolean, nil] :tags (nil) push all tags
@option opts [Boolean, nil] :delete (nil) delete refs on the remote
@option opts [Boolean, nil] :force (nil) force updates
@option opts [String, Array<String>] :push_option (nil) one or more
push-option values
@return [Array((String, nil), (String, nil), Hash)] normalized [remote, branch, opts]
@api private
Source
# File lib/git/repository/remote_operations.rb, line 836 def push_refs(execution_context, remote, branch, opts) positionals = [remote, branch].compact Git::Commands::Push.new(execution_context).call(*positionals, **opts.except(:tags)) end
Issue the refs push (first push when ‘:tags` is given separately)
Strips ‘:tags` from the options so that only refs — not tags — are pushed in this first call. Tags are pushed in a separate call when {push_tags_separately?} is true.
@param execution_context [Git::ExecutionContext::Repository] the repository execution context
@param remote [String, nil] remote name or URL
@param branch [String, nil] branch or refspec
@param opts [Hash] push options (‘:tags` key will be stripped)
@option opts [Boolean, nil] :all (nil) push all branches
@option opts [Boolean, nil] :mirror (nil) mirror all refs
@option opts [Boolean, nil] :delete (nil) delete refs on the remote
@option opts [Boolean, nil] :force (nil) force updates
@option opts [String, Array<String>] :push_option (nil) one or more
push-option values
@return [Git::CommandLine::Result]
@api private
Source
# File lib/git/repository/remote_operations.rb, line 723 def resolve_fetch_target(remote, opts) if remote.is_a?(Hash) opts = remote remote = nil end raise ArgumentError, ':ref requires an explicit remote' if remote.nil? && opts.key?(:ref) [remote, opts] end
Resolve the (remote, opts) pair for {#fetch}, supporting the hash-only form
‘fetch` may be called as `fetch(remote, opts)` or `fetch(opts)`. When a bare options hash is passed the remote is treated as nil. A `:ref` is only meaningful with an explicit remote, so requesting one without a remote (it would otherwise be silently promoted to the remote-name slot) is rejected.
@param remote [String, Hash, nil] the remote name, or an options hash
@param opts [Hash] the options hash when remote is given positionally
@option opts [String, Array<String>, nil] :ref (nil) one or more refspecs
forwarded after the remote name Requires an explicit `remote`.
@return [Array(String, Hash), Array(nil, Hash)] the resolved remote and opts
@raise [ArgumentError] when :ref is supplied without an explicit remote
@api private