def handle_recipe()

in legacy/autopkg_tools/autopkg_tools.py [0:0]


def handle_recipe(recipe, pkg_path=None):
  """Handle the complete workflow of an autopkg recipe."""
  display_verbose("Handling %s" % recipe)
  if autopkglib.get_pref('RECIPE_REPO_DIR'):
    recipe_repo_dir = autopkglib.get_pref('RECIPE_REPO_DIR')
  else:
    recipe_repo_dir = os.path.expanduser('~/Library/AutoPkg/RecipeRepos')
  report_plist_path = os.path.join(
    os.path.dirname(recipe_repo_dir),
    'autopkg.plist'
  )
  # 1. Syncing is no longer implemented
  # 2. Parse recipe name for basic item name
  branchname = parse_recipe_name(recipe)
  # 3. Create feature branch
  create_feature_branch(branchname)
  # 4. Run autopkg for that recipe
  run_recipe(recipe, report_plist_path, pkg_path)
  # 5. Parse report plist
  run_results = parse_report_plist(report_plist_path)
  if not run_results['imported'] and not run_results['failed']:
    # Nothing happened
    cleanup_branch(branchname)
    return
  if run_results['failed']:
    # Item failed, so file a task
    failed_task(run_results['failed'])
    cleanup_branch(branchname)
    return
  if run_results['imported']:
    # Item succeeded, so continue.
    # 6. Run any binary-handling middleware
    binary_middleware(run_results['imported'][0])
    # 7. If any changes occurred, create git commit
    create_commit(run_results['imported'][0])
    # 8. Rename branch with version
    rename_branch_version(
      branchname,
      str(run_results['imported'][0]['version'])
    )
    # 9. File a task
    imported_task(run_results['imported'][0])
  # 10. Switch back to master
  change_feature_branch('master')