Esempio n. 1
0
def main():
  if '--clean' in sys.argv:
    clean_refs()
    return 0

  orig_branch = current_branch()
  if orig_branch == 'HEAD':
    orig_branch = git_hash('HEAD')

  if 'origin' in run_git('remote').splitlines():
    run_git('fetch', 'origin', stderr=None)
  else:
    run_git('svn', 'fetch', stderr=None)
  branch_tree = {}
  for branch in branches():
    parent = upstream(branch)
    if not parent:
      print 'Skipping %s: No upstream specified' % branch
      continue
    branch_tree[branch] = parent

  starting_refs = {}
  for branch, parent in branch_tree.iteritems():
    starting_refs[branch] = get_or_create_merge_base_tag(branch, parent)

  if VERBOSE:
    pprint(branch_tree)
    pprint(starting_refs)

  # XXX There is a more efficient way to do this, but for now...
  while branch_tree:
    this_pass = [i for i in branch_tree.items() if i[1] not in branch_tree]
    for branch, parent in this_pass:
      clean_branch(branch, parent, starting_refs[branch])
      del branch_tree[branch]

  clean_refs()

  bclean()

  if orig_branch in branches():
    run_git('checkout', orig_branch)
  else:
    run_git('checkout', 'origin/master')

  return 0
Esempio n. 2
0
def main():
  squash()
  clean_refs()
  return 0