From 45618a32dfdae7c02efabd8ca3a3d46114db22ef Mon Sep 17 00:00:00 2001 From: Gregory Ballantine Date: Tue, 25 Jul 2017 16:38:37 -0400 Subject: [PATCH] Added a check to make sure that the specified branch to existed first --- lib/FormulaRepo.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/FormulaRepo.py b/lib/FormulaRepo.py index 4f49ed2..cf9d6a1 100644 --- a/lib/FormulaRepo.py +++ b/lib/FormulaRepo.py @@ -1,5 +1,6 @@ from git import Repo import os +import sys class FormulaRepo(): @@ -30,6 +31,11 @@ class FormulaRepo(): if tracking_key == 0: # tracking a specific branch on the repo if tracking_value != False: + # check to make sure that the given branch name actually exists first + if not tracking_value in self.repo.branches: + print('%s is not an existing branch name for %s - please fix this.' % (tracking_value, self.repo_path)) + sys.exit(1) + repo_branch = self.repo.head.reference # check to make sure that the current tracked branch is, in fact, what we want if repo_branch != tracking_value: @@ -45,7 +51,9 @@ class FormulaRepo(): print('Tracking a commit') else: # we shouldn't get here... - print('We shouldn\'t have a tracking key that is not 0, 1 or 2') + print('So... somehow %s got a tracking key of %d, but that is not a valid tracking key!' % (self.repo_path, tracking_key)) + sys.exit(1) + # pull any new updates for the repo def pull_updates(self):