Cleaned up some code; removed the tag and commit tracking features for now
This commit is contained in:
parent
076a905124
commit
987698d750
@ -49,11 +49,7 @@ class Formula():
|
||||
|
||||
# checks to see if a branch, tag, or commit to track has been defined
|
||||
def get_tracking_state(self):
|
||||
if 'track_branch' in self.formula_def:
|
||||
return 0, self.formula_def['track_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']
|
||||
if 'git_branch' in self.formula_def:
|
||||
return self.formula_def['git_branch']
|
||||
else:
|
||||
return 0, False
|
||||
return False
|
||||
|
@ -27,32 +27,24 @@ class FormulaRepo():
|
||||
self.repo = Repo(self.repo_path)
|
||||
|
||||
# check if the repo is up to date
|
||||
def check_tracking_info(self, tracking_key, tracking_value):
|
||||
if tracking_key == 0:
|
||||
def check_tracking_info(self, branch):
|
||||
if branch != False:
|
||||
# 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)
|
||||
# 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:
|
||||
self.repo.head.reference = repo_branch
|
||||
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:
|
||||
self.repo.head.reference = repo_branch
|
||||
|
||||
# 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))
|
||||
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:
|
||||
# we shouldn't get here...
|
||||
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)
|
||||
# no branch was specified, so we're going with what's there
|
||||
print('Using the default/current branch for %s' % (self.repo_path))
|
||||
|
||||
|
||||
# pull any new updates for the repo
|
||||
|
@ -44,9 +44,9 @@ def get_formulas(formulas, formulas_dir, formulas_url):
|
||||
formula_repo.retrieve()
|
||||
|
||||
# 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
|
||||
formula_repo.check_tracking_info(tracking_key, tracking_value)
|
||||
formula_repo.check_tracking_info(tracking_branch)
|
||||
|
||||
# pull any new commits for the repo
|
||||
formula_repo.pull_updates()
|
||||
|
Loading…
Reference in New Issue
Block a user