Update repos if they exist when populating
This commit is contained in:
parent
9f70876576
commit
7eebb69e51
|
@ -15,6 +15,20 @@ def _clone_repo(target, source):
|
||||||
]
|
]
|
||||||
return subprocess.check_output(command)
|
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):
|
def _create_virtualenv(target):
|
||||||
if os.path.exists(os.path.join(target, 've')):
|
if os.path.exists(os.path.join(target, 've')):
|
||||||
print("Skipping virtualenv for {}".format(target))
|
print("Skipping virtualenv for {}".format(target))
|
||||||
|
@ -36,12 +50,15 @@ def main():
|
||||||
for repo in teamanalysis.repos.REPOSITORIES:
|
for repo in teamanalysis.repos.REPOSITORIES:
|
||||||
target = os.path.join(target_root, repo)
|
target = os.path.join(target_root, repo)
|
||||||
source = 'git@bitbucket.org:Authentise/{}.git'.format(repo)
|
source = 'git@bitbucket.org:Authentise/{}.git'.format(repo)
|
||||||
output = _clone_repo(target, source)
|
if not os.path.exists(target):
|
||||||
_create_virtualenv(target)
|
output = _clone_repo(target, source)
|
||||||
try:
|
_create_virtualenv(target)
|
||||||
_install_dependencies(target)
|
try:
|
||||||
except subprocess.CalledProcessError as e:
|
_install_dependencies(target)
|
||||||
print("Failed to install dependencies for {}: {}".format(target, e))
|
except subprocess.CalledProcessError as e:
|
||||||
|
print("Failed to install dependencies for {}: {}".format(target, e))
|
||||||
|
else:
|
||||||
|
output = _update_repo(target)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in New Issue