@ -888,7 +888,7 @@ def main():
ssh_opts = module . params [ ' ssh_opts ' ]
ssh_opts = module . params [ ' ssh_opts ' ]
umask = module . params [ ' umask ' ]
umask = module . params [ ' umask ' ]
result = dict ( warnings = list ( ) )
result = dict ( changed = False , warnings = list ( ) )
# evaluate and set the umask before doing anything else
# evaluate and set the umask before doing anything else
if umask is not None :
if umask is not None :
@ -968,7 +968,7 @@ def main():
# this does no checking that the repo is the actual repo
# this does no checking that the repo is the actual repo
# requested.
# requested.
result [ ' before ' ] = get_version ( module , git_path , dest )
result [ ' before ' ] = get_version ( module , git_path , dest )
result . update ( changed= False , after= result [ ' before ' ] )
result . update ( after= result [ ' before ' ] )
module . exit_json ( * * result )
module . exit_json ( * * result )
else :
else :
# else do a pull
# else do a pull
@ -981,6 +981,7 @@ def main():
# if force and in non-check mode, do a reset
# if force and in non-check mode, do a reset
if not module . check_mode :
if not module . check_mode :
reset ( git_path , module , dest )
reset ( git_path , module , dest )
result . update ( changed = True , msg = ' Local modifications exist. ' )
# exit if already at desired sha version
# exit if already at desired sha version
if module . check_mode :
if module . check_mode :
@ -990,7 +991,6 @@ def main():
remote_url_changed = set_remote_url ( git_path , module , repo , dest , remote )
remote_url_changed = set_remote_url ( git_path , module , repo , dest , remote )
result . update ( remote_url_changed = remote_url_changed )
result . update ( remote_url_changed = remote_url_changed )
if need_fetch :
if module . check_mode :
if module . check_mode :
remote_head = get_remote_head ( git_path , module , dest , version , remote , bare )
remote_head = get_remote_head ( git_path , module , dest , version , remote , bare )
result . update ( changed = ( result [ ' before ' ] != remote_head ) , after = remote_head )
result . update ( changed = ( result [ ' before ' ] != remote_head ) , after = remote_head )
@ -1005,12 +1005,6 @@ def main():
result [ ' after ' ] = get_version ( module , git_path , dest )
result [ ' after ' ] = get_version ( module , git_path , dest )
if result [ ' before ' ] == result [ ' after ' ] :
if local_mods :
result . update ( changed = True , after = remote_head , msg = ' Local modifications exist ' )
# no diff, since the repo didn't change
module . exit_json ( * * result )
# switch to version specified regardless of whether
# switch to version specified regardless of whether
# we got new revisions from the repository
# we got new revisions from the repository
if not bare :
if not bare :
@ -1033,7 +1027,6 @@ def main():
# determine if we changed anything
# determine if we changed anything
result [ ' after ' ] = get_version ( module , git_path , dest )
result [ ' after ' ] = get_version ( module , git_path , dest )
result . update ( changed = False )
if result [ ' before ' ] != result [ ' after ' ] or local_mods or submodules_updated or remote_url_changed :
if result [ ' before ' ] != result [ ' after ' ] or local_mods or submodules_updated or remote_url_changed :
result . update ( changed = True )
result . update ( changed = True )
if module . _diff :
if module . _diff :