Ejemplo n.º 1
0
 def test_get_submodules_succeeds(self):
     submodules = git.get_submodules('.', True)
     self.assertTrue(
         any(['third_party/android' in s.path for s in submodules]))
     # The following test essentially tests if you have stale entries
     # in .git/config. Removing entries from .gitmodules and running
     # "git submodule sync" does not remove entries from .git/config.
     submodules = git.get_submodules('.', False)
     self.assertTrue(
         any(['third_party/android' in s.path for s in submodules]))
Ejemplo n.º 2
0
 def test_get_submodules_succeeds(self):
   submodules = git.get_submodules('.', True)
   self.assertTrue(any(['third_party/android' in s.path
                        for s in submodules]))
   # The following test essentially tests if you have stale entries
   # in .git/config. Removing entries from .gitmodules and running
   # "git submodule sync" does not remove entries from .git/config.
   submodules = git.get_submodules('.', False)
   self.assertTrue(any(['third_party/android' in s.path
                        for s in submodules]))
Ejemplo n.º 3
0
def _add_and_sync_submodules(dest, force):
    """Make submodules match source and dest directories.

  Existing submodules are updated, new ones are added."""
    logging.info('Synchronizing submodules')
    dest_submodules = git.get_submodules(dest, use_gitmodules=False)
    dest_submodules_by_path = {}
    for dest_submodule in dest_submodules:
        dest_submodules_by_path[dest_submodule.path] = dest_submodule
    src_submodules = git.get_submodules('.', use_gitmodules=True)
    dest_submodules_paths = set(dest_submodules_by_path.keys())
    src_submodules_paths = set([s.path for s in src_submodules])
    for removed_submodule in dest_submodules_paths - src_submodules_paths:
        # TODO(kmixter): Support automatically removing abandoned submodules.
        logging.warning('Submodule %s in open source needs to be removed' %
                        removed_submodule)
    for submodule in src_submodules:
        _add_and_sync_submodule(dest, force, submodule,
                                dest_submodules_by_path.get(submodule.path))
    return src_submodules_paths
Ejemplo n.º 4
0
def _add_and_sync_submodules(dest, force):
  """Make submodules match source and dest directories.

  Existing submodules are updated, new ones are added."""
  logging.info('Synchronizing submodules')
  dest_submodules = git.get_submodules(dest, use_gitmodules=False)
  dest_submodules_by_path = {}
  for dest_submodule in dest_submodules:
    dest_submodules_by_path[dest_submodule.path] = dest_submodule
  src_submodules = git.get_submodules('.', use_gitmodules=True)
  dest_submodules_paths = set(dest_submodules_by_path.keys())
  src_submodules_paths = set([s.path for s in src_submodules])
  for removed_submodule in dest_submodules_paths - src_submodules_paths:
    # TODO(kmixter): Support automatically removing abandoned submodules.
    logging.warning('Submodule %s in open source needs to be removed' %
                    removed_submodule)
  for submodule in src_submodules:
    _add_and_sync_submodule(dest, force, submodule,
                            dest_submodules_by_path.get(submodule.path))
  return src_submodules_paths
Ejemplo n.º 5
0
def get_android_submodule_paths():
    """Get all the Android submodule paths currently used by ARC."""

    # Note we sort by longest path to smallest path
    # for identify_containing_submodule().
    return sorted(
        (submodule.path
         for submodule in git.get_submodules(constants.ARC_ROOT,
                                             use_gitmodules=True)
         if submodule.path.startswith(constants.ANDROID_SUBMODULE_PATH)),
        key=lambda path: len(path),
        reverse=True)
Ejemplo n.º 6
0
def get_android_submodule_paths():
    """Get all the Android submodule paths currently used by ARC."""

    # Note we sort by longest path to smallest path
    # for identify_containing_submodule().
    return sorted(
        (
            submodule.path
            for submodule in git.get_submodules(constants.ARC_ROOT, use_gitmodules=True)
            if submodule.path.startswith(constants.ANDROID_SUBMODULE_PATH)
        ),
        key=lambda path: len(path),
        reverse=True,
    )
Ejemplo n.º 7
0
def _do_update_all(args, verify_only=False):
  """Updates the version used for all Android sub-projects."""
  submodules = git.get_submodules('.', False)
  logging.info('Examining %d submodules....', len(submodules))
  rebase_state = state.State()
  for submodule in submodules:
    if submodule.url.startswith(_ANDROID_BASE_URL):
      third_party_dir = submodule.path
      subproject = submodule.url[len(_ANDROID_BASE_URL):].rstrip('/')
      if not os.path.exists(third_party_dir):
        # Some subprojects might be listed from older versions that are not used
        # anymore.
        logging.info('Ignoring %s as there is no local directory for it.',
                     submodule)
        continue
      _update_subproject(args.deps, rebase_state, subproject, third_party_dir,
                         verify_only=verify_only)
  do_post_update_messages(rebase_state, verify_only=verify_only)
Ejemplo n.º 8
0
def _do_update_all(args, verify_only=False):
    """Updates the version used for all Android sub-projects."""
    submodules = git.get_submodules('.', False)
    logging.info('Examining %d submodules....', len(submodules))
    rebase_state = state.State()
    for submodule in submodules:
        if submodule.url.startswith(_ANDROID_BASE_URL):
            third_party_dir = submodule.path
            subproject = submodule.url[len(_ANDROID_BASE_URL):].rstrip('/')
            if not os.path.exists(third_party_dir):
                # Some subprojects might be listed from older versions that are not used
                # anymore.
                logging.info(
                    'Ignoring %s as there is no local directory for it.',
                    submodule)
                continue
            _update_subproject(args.deps,
                               rebase_state,
                               subproject,
                               third_party_dir,
                               verify_only=verify_only)
    do_post_update_messages(rebase_state, verify_only=verify_only)