Update repos if they exist when populating

This commit is contained in:
Eli Ribble 2015-08-27 14:46:26 -06:00
parent 9f70876576
commit 7eebb69e51
1 changed files with 23 additions and 6 deletions

View File

@ -15,6 +15,20 @@ def _clone_repo(target, source):
]
return subprocess.check_output(command)
def _update_repo(target):
os.chdir(target)
command = ['git', 'checkout', 'master']
try:
subprocess.check_output(command)
except subprocess.CalledProcessError as e:
raise Exception("Failed to checkout master for repository at {}: {}".format(target, e))
command = ['git', 'pull']
try:
return subprocess.check_output(command)
except subprocess.CalledProcessError as e:
raise Exception("Failed to update repository at {}: {}".format(target, e))
def _create_virtualenv(target):
if os.path.exists(os.path.join(target, 've')):
print("Skipping virtualenv for {}".format(target))
@ -36,12 +50,15 @@ def main():
for repo in teamanalysis.repos.REPOSITORIES:
target = os.path.join(target_root, repo)
source = 'git@bitbucket.org:Authentise/{}.git'.format(repo)
output = _clone_repo(target, source)
_create_virtualenv(target)
try:
_install_dependencies(target)
except subprocess.CalledProcessError as e:
print("Failed to install dependencies for {}: {}".format(target, e))
if not os.path.exists(target):
output = _clone_repo(target, source)
_create_virtualenv(target)
try:
_install_dependencies(target)
except subprocess.CalledProcessError as e:
print("Failed to install dependencies for {}: {}".format(target, e))
else:
output = _update_repo(target)
if __name__ == '__main__':
main()