mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Merge pull request #22553 from alprs/fix-git_latest_empty
Make git.latest work with empty source repositories
This commit is contained in:
commit
bd83b6c0b5
@ -205,11 +205,18 @@ def latest(name,
|
||||
log.debug(('target {0} is found, "git pull" '
|
||||
'is probably required'.format(target)))
|
||||
try:
|
||||
current_rev = __salt__['git.revision'](target, user=user)
|
||||
try:
|
||||
current_rev = __salt__['git.revision'](target, user=user)
|
||||
except CommandExecutionError:
|
||||
current_rev = None
|
||||
|
||||
# handle the case where a branch was provided for rev
|
||||
remote_rev, new_rev = None, None
|
||||
branch = __salt__['git.current_branch'](target, user=user)
|
||||
try:
|
||||
branch = __salt__['git.current_branch'](target, user=user)
|
||||
except CommandExecutionError:
|
||||
branch = None
|
||||
|
||||
# We're only interested in the remote branch if a branch
|
||||
# (instead of a hash, for example) was provided for rev.
|
||||
if (branch != 'HEAD' and branch == rev) or rev is None:
|
||||
@ -309,7 +316,10 @@ def latest(name,
|
||||
identity=identity,
|
||||
opts='--recursive')
|
||||
|
||||
new_rev = __salt__['git.revision'](cwd=target, user=user)
|
||||
try:
|
||||
new_rev = __salt__['git.revision'](cwd=target, user=user)
|
||||
except CommandExecutionError:
|
||||
new_rev = None
|
||||
except Exception as exc:
|
||||
return _fail(
|
||||
ret,
|
||||
@ -369,8 +379,12 @@ def latest(name,
|
||||
identity=identity,
|
||||
opts='--recursive')
|
||||
|
||||
new_rev = None if bare else (
|
||||
__salt__['git.revision'](cwd=target, user=user))
|
||||
new_rev = None
|
||||
if not bare:
|
||||
try:
|
||||
new_rev = __salt__['git.revision'](cwd=target, user=user)
|
||||
except CommandExecutionError:
|
||||
pass
|
||||
|
||||
except Exception as exc:
|
||||
return _fail(
|
||||
|
Loading…
Reference in New Issue
Block a user