def _update_subproject(deps, state, subproject, module_path, verify_only=False): desired_revision = deps.get_revision_for(subproject) if desired_revision is None: logging.warning('Skipping unknown subproject %s', subproject) return logging.info('%s Fetching information about %s', subproject, desired_revision) # Convert the desired revision into a hash (if not already one). desired_revision = git.get_ref_hash(desired_revision, cwd=module_path) # Get the current version of the repo. We will need this to rebase the mods # after we roll forward. current_revision = git.get_head_revision(cwd=module_path) if desired_revision == current_revision: logging.info('%s is already at %s', subproject, desired_revision) # If we are doing an update, we can stop now, and assume that no work needs # to be done to the mods for that submodule. if not verify_only: return if not state.verify_submodule_path(current_revision, module_path): return # If we are only verifying, stop here before making any actual changes. if verify_only: return logging.info('%s checking out %s', subproject, desired_revision) git.force_checkout_revision(desired_revision, cwd=module_path) git.add_to_staging(module_path) logging.info('%s rebasing mods', subproject) state.rebase_submodule_path(current_revision, module_path)
def test_get_head_revision(self): self.assertIsNotNone(git.get_head_revision())