|
|
|
@ -90,6 +90,19 @@ def clone(repo, dest):
|
|
|
|
|
cmd = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
|
|
|
return cmd.communicate()
|
|
|
|
|
|
|
|
|
|
def reset(dest):
|
|
|
|
|
'''
|
|
|
|
|
Resets the index and working tree to HEAD.
|
|
|
|
|
Discards any changes to tracked files in working
|
|
|
|
|
tree since that commit.
|
|
|
|
|
'''
|
|
|
|
|
os.chdir(dest)
|
|
|
|
|
cmd = "git reset --hard HEAD"
|
|
|
|
|
cmd = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
|
|
|
(out, err) = cmd.communicate()
|
|
|
|
|
rc = cmd.returncode
|
|
|
|
|
return (rc, out, err)
|
|
|
|
|
|
|
|
|
|
def pull(repo, dest):
|
|
|
|
|
''' updates repo from remote sources '''
|
|
|
|
|
os.chdir(dest)
|
|
|
|
@ -123,6 +136,9 @@ if not os.path.exists(gitconfig):
|
|
|
|
|
else:
|
|
|
|
|
# else do a pull
|
|
|
|
|
before = get_version(dest)
|
|
|
|
|
(rc, out, err) = reset(dest)
|
|
|
|
|
if rc != 0:
|
|
|
|
|
fail_json(out=out, err=err)
|
|
|
|
|
(out, err) = pull(repo, dest)
|
|
|
|
|
|
|
|
|
|
# handle errors from clone or pull
|
|
|
|
|