Cleaned up some code; removed the tag and commit tracking features for now

This commit is contained in:
Gregory Ballantine 2017-07-25 17:54:04 -04:00
parent 076a905124
commit 987698d750
3 changed files with 17 additions and 29 deletions

View File

@ -49,11 +49,7 @@ class Formula():
# checks to see if a branch, tag, or commit to track has been defined # checks to see if a branch, tag, or commit to track has been defined
def get_tracking_state(self): def get_tracking_state(self):
if 'track_branch' in self.formula_def: if 'git_branch' in self.formula_def:
return 0, self.formula_def['track_branch'] return self.formula_def['git_branch']
elif 'track_tag' in self.formula_def:
return 1, self.formula_def['track_tag']
elif 'track_commit' in self.formula_def:
return 2, self.formula_def['track_commit']
else: else:
return 0, False return False

View File

@ -27,10 +27,9 @@ class FormulaRepo():
self.repo = Repo(self.repo_path) self.repo = Repo(self.repo_path)
# check if the repo is up to date # check if the repo is up to date
def check_tracking_info(self, tracking_key, tracking_value): def check_tracking_info(self, branch):
if tracking_key == 0: if branch != False:
# tracking a specific branch on the repo # tracking a specific branch on the repo
if tracking_value != False:
# check to make sure that the given branch name actually exists first # check to make sure that the given branch name actually exists first
if not tracking_value in self.repo.branches: 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)) print('%s is not an existing branch name for %s - please fix this.' % (tracking_value, self.repo_path))
@ -43,16 +42,9 @@ class FormulaRepo():
# let the user know which branch we're using # let the user know which branch we're using
print('For %s, we\'re using the %s branch.' % (self.repo_path, self.repo.head.reference)) print('For %s, we\'re using the %s branch.' % (self.repo_path, self.repo.head.reference))
elif tracking_key == 1:
# tracking a specific tag on the repo
print('Tracking a tag')
elif tracking_key == 2:
# tracking a specific commit on the repo
print('Tracking a commit')
else: else:
# we shouldn't get here... # no branch was specified, so we're going with what's there
print('So... somehow %s got a tracking key of %d, but that is not a valid tracking key!' % (self.repo_path, tracking_key)) print('Using the default/current branch for %s' % (self.repo_path))
sys.exit(1)
# pull any new updates for the repo # pull any new updates for the repo

View File

@ -44,9 +44,9 @@ def get_formulas(formulas, formulas_dir, formulas_url):
formula_repo.retrieve() formula_repo.retrieve()
# get the repo tracking information from the formula definition # get the repo tracking information from the formula definition
tracking_key, tracking_value = formula.get_tracking_state() tracking_branch = formula.get_tracking_state()
# make sure our formula's repo is up-to-date with the latest tracked version # make sure our formula's repo is up-to-date with the latest tracked version
formula_repo.check_tracking_info(tracking_key, tracking_value) formula_repo.check_tracking_info(tracking_branch)
# pull any new commits for the repo # pull any new commits for the repo
formula_repo.pull_updates() formula_repo.pull_updates()