mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +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
@ -204,12 +204,19 @@ def latest(name,
|
||||
# git pull is probably required
|
||||
log.debug(('target {0} is found, "git pull" '
|
||||
'is probably required'.format(target)))
|
||||
try:
|
||||
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
|
||||
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')
|
||||
|
||||
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