mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Fix shadowed outer-scope attributes
This commit is contained in:
parent
81a6c27010
commit
f2751ef7c4
@ -80,11 +80,14 @@ def _config_getter(get_opt,
|
||||
|
||||
|
||||
def _expand_path(cwd, user):
|
||||
'''
|
||||
Expand home directory
|
||||
'''
|
||||
try:
|
||||
to_expand = '~' + user if user else '~'
|
||||
except TypeError:
|
||||
# Users should never be numeric but if we don't account for this then
|
||||
# we're going to get a traceback
|
||||
# we're going to get a traceback if someone passes this invalid input.
|
||||
to_expand = '~' + str(user) if user else '~'
|
||||
try:
|
||||
return os.path.join(os.path.expanduser(to_expand), cwd)
|
||||
@ -246,6 +249,9 @@ def _get_toplevel(path, user=None):
|
||||
|
||||
|
||||
def _git_config(cwd, user):
|
||||
'''
|
||||
Helper to retrive git config options
|
||||
'''
|
||||
contextkey = 'git.config.' + cwd
|
||||
if contextkey not in __context__:
|
||||
git_dir = rev_parse(cwd,
|
||||
@ -958,7 +964,6 @@ config_get_regex = config_get_regexp
|
||||
|
||||
def config_set(key,
|
||||
value=None,
|
||||
add=False,
|
||||
multivar=None,
|
||||
cwd=None,
|
||||
user=None,
|
||||
@ -1029,6 +1034,7 @@ def config_set(key,
|
||||
salt myminion git.config_set user.email foo@bar.com global=True
|
||||
'''
|
||||
kwargs = salt.utils.clean_kwargs(**kwargs)
|
||||
add_ = kwargs.pop('add', False)
|
||||
global_ = kwargs.pop('global', False)
|
||||
is_global = kwargs.pop('is_global', False)
|
||||
if kwargs:
|
||||
@ -1080,7 +1086,7 @@ def config_set(key,
|
||||
|
||||
if value is not None:
|
||||
command = copy.copy(command_prefix)
|
||||
if add:
|
||||
if add_:
|
||||
command.append('--add')
|
||||
else:
|
||||
command.append('--replace-all')
|
||||
@ -1830,8 +1836,8 @@ def merge(cwd,
|
||||
rev=None,
|
||||
opts='',
|
||||
user=None,
|
||||
branch=None,
|
||||
ignore_retcode=False):
|
||||
ignore_retcode=False,
|
||||
**kwargs):
|
||||
'''
|
||||
Interface to `git-merge(1)`_
|
||||
|
||||
@ -1883,14 +1889,19 @@ def merge(cwd,
|
||||
# .. or merge another rev
|
||||
salt myminion git.merge /path/to/repo rev=upstream/foo
|
||||
'''
|
||||
kwargs = salt.utils.clean_kwargs(**kwargs)
|
||||
branch_ = kwargs.pop('branch', None)
|
||||
if kwargs:
|
||||
salt.utils.invalid_kwargs(kwargs)
|
||||
|
||||
cwd = _expand_path(cwd, user)
|
||||
if branch:
|
||||
if branch_:
|
||||
salt.utils.warn_until(
|
||||
'Nitrogen',
|
||||
'The \'branch\' argument to git.merge has been deprecated, please '
|
||||
'use \'rev\' instead.'
|
||||
)
|
||||
rev = branch
|
||||
rev = branch_
|
||||
command = ['git', 'merge']
|
||||
command.extend(_format_opts(opts))
|
||||
if rev:
|
||||
@ -2201,7 +2212,7 @@ def push(cwd,
|
||||
user=None,
|
||||
identity=None,
|
||||
ignore_retcode=False,
|
||||
branch=None):
|
||||
**kwargs):
|
||||
'''
|
||||
Interface to `git-push(1)`_
|
||||
|
||||
@ -2270,14 +2281,19 @@ def push(cwd,
|
||||
# Delete remote branch 'upstream/temp'
|
||||
salt myminion git.push /path/to/repo upstream :temp
|
||||
'''
|
||||
kwargs = salt.utils.clean_kwargs(**kwargs)
|
||||
branch_ = kwargs.pop('branch', None)
|
||||
if kwargs:
|
||||
salt.utils.invalid_kwargs(kwargs)
|
||||
|
||||
cwd = _expand_path(cwd, user)
|
||||
if branch:
|
||||
if branch_:
|
||||
salt.utils.warn_until(
|
||||
'Nitrogen',
|
||||
'The \'branch\' argument to git.push has been deprecated, please '
|
||||
'use \'ref\' instead.'
|
||||
)
|
||||
ref = branch
|
||||
ref = branch_
|
||||
command = ['git', 'push']
|
||||
command.extend(_format_opts(opts))
|
||||
if not isinstance(remote, six.string_types):
|
||||
@ -2393,7 +2409,8 @@ def remote_get(cwd,
|
||||
cwd = _expand_path(cwd, user)
|
||||
all_remotes = remotes(cwd,
|
||||
user=user,
|
||||
redact_auth=redact_auth)
|
||||
redact_auth=redact_auth,
|
||||
ignore_retcode=ignore_retcode)
|
||||
if remote not in all_remotes:
|
||||
raise CommandExecutionError(
|
||||
'Remote \'{0}\' not present in git checkout located at {1}'
|
||||
@ -2959,8 +2976,8 @@ def submodule(cwd,
|
||||
opts='',
|
||||
user=None,
|
||||
identity=None,
|
||||
init=False,
|
||||
ignore_retcode=False):
|
||||
ignore_retcode=False,
|
||||
**kwargs):
|
||||
'''
|
||||
.. versionchanged:: 2015.8.0
|
||||
Added the ``command`` argument to allow for operations other than
|
||||
@ -3038,8 +3055,13 @@ def submodule(cwd,
|
||||
# Unregister submodule (2015.8.0 and later)
|
||||
salt myminion git.submodule /path/to/repo/sub/repo deinit
|
||||
'''
|
||||
kwargs = salt.utils.clean_kwargs(**kwargs)
|
||||
init_ = kwargs.pop('init', False)
|
||||
if kwargs:
|
||||
salt.utils.invalid_kwargs(kwargs)
|
||||
|
||||
cwd = _expand_path(cwd, user)
|
||||
if init:
|
||||
if init_:
|
||||
raise SaltInvocationError(
|
||||
'The \'init\' argument is no longer supported. Either set '
|
||||
'\'command\' to \'init\', or include \'--init\' in the \'opts\' '
|
||||
@ -3178,14 +3200,14 @@ def version(versioninfo=False):
|
||||
|
||||
def worktree_add(cwd,
|
||||
worktree_path,
|
||||
branch=None,
|
||||
ref=None,
|
||||
reset_branch=None,
|
||||
force=None,
|
||||
detach=False,
|
||||
opts='',
|
||||
user=None,
|
||||
ignore_retcode=False):
|
||||
ignore_retcode=False,
|
||||
**kwargs):
|
||||
'''
|
||||
.. versionadded:: 2015.8.0
|
||||
|
||||
@ -3254,8 +3276,13 @@ def worktree_add(cwd,
|
||||
salt myminion git.worktree_add /path/to/repo/main ../hotfix ref=origin/master
|
||||
salt myminion git.worktree_add /path/to/repo/main ../hotfix branch=hotfix21 ref=v2.1.9.3
|
||||
'''
|
||||
kwargs = salt.utils.clean_kwargs(**kwargs)
|
||||
branch_ = kwargs.pop('branch', None)
|
||||
if kwargs:
|
||||
salt.utils.invalid_kwargs(kwargs)
|
||||
|
||||
cwd = _expand_path(cwd, user)
|
||||
if branch and detach:
|
||||
if branch_ and detach:
|
||||
raise SaltInvocationError(
|
||||
'Only one of \'branch\' and \'detach\' is allowed'
|
||||
)
|
||||
@ -3269,9 +3296,9 @@ def worktree_add(cwd,
|
||||
)
|
||||
command.append('--detach')
|
||||
else:
|
||||
if not branch:
|
||||
branch = os.path.basename(worktree_path)
|
||||
command.extend(['-B' if reset_branch else '-b', branch])
|
||||
if not branch_:
|
||||
branch_ = os.path.basename(worktree_path)
|
||||
command.extend(['-B' if reset_branch else '-b', branch_])
|
||||
if force:
|
||||
command.append('--force')
|
||||
command.extend(_format_opts(opts))
|
||||
|
Loading…
Reference in New Issue
Block a user