def update(self, distribution_version): try: if self.remote: branch = versions.best_match( git.branches(self.repo_dir, remote=self.remote), distribution_version) if branch: # Allow uncommitted changes iff we do not have to change the branch self.logger.info( "Checking out [%s] in [%s] for distribution version [%s].", branch, self.repo_dir, distribution_version) git.checkout(self.repo_dir, branch=branch) self.logger.info( "Rebasing on [%s] in [%s] for distribution version [%s].", branch, self.repo_dir, distribution_version) try: git.rebase(self.repo_dir, branch=branch) self.revision = git.head_revision(self.repo_dir) except exceptions.SupplyError: self.logger.exception( "Cannot rebase due to local changes in [%s]", self.repo_dir) console.warn( "Local changes in [%s] prevent %s update from remote. Please commit your changes." % (self.repo_dir, self.resource_name)) return else: msg = "Could not find %s remotely for distribution version [%s]. Trying to find %s locally." % \ (self.resource_name, distribution_version, self.resource_name) self.logger.warning(msg) branch = versions.best_match( git.branches(self.repo_dir, remote=False), distribution_version) if branch: if git.current_branch(self.repo_dir) != branch: self.logger.info( "Checking out [%s] in [%s] for distribution version [%s].", branch, self.repo_dir, distribution_version) git.checkout(self.repo_dir, branch=branch) self.revision = git.head_revision(self.repo_dir) else: self.logger.info( "No local branch found for distribution version [%s] in [%s]. Checking tags.", distribution_version, self.repo_dir) tag = self._find_matching_tag(distribution_version) if tag: self.logger.info( "Checking out tag [%s] in [%s] for distribution version [%s].", tag, self.repo_dir, distribution_version) git.checkout(self.repo_dir, branch=tag) self.revision = git.head_revision(self.repo_dir) else: raise exceptions.SystemSetupError( "Cannot find %s for distribution version %s" % (self.resource_name, distribution_version)) except exceptions.SupplyError as e: tb = sys.exc_info()[2] raise exceptions.DataError("Cannot update %s in [%s] (%s)." % (self.resource_name, self.repo_dir, e.message)).with_traceback(tb)
def _update(self, distribution_version): try: if self.remote and not self.offline: branch = versions.best_match(git.branches(self.tracks_dir, remote=self.remote), distribution_version) if branch: # Allow uncommitted changes iff we do not have to change the branch logger.info( "Checking out [%s] in [%s] for distribution version [%s]." % (branch, self.tracks_dir, distribution_version)) git.checkout(self.tracks_dir, branch=branch) logger.info("Rebasing on [%s] in [%s] for distribution version [%s]." % (branch, self.tracks_dir, distribution_version)) try: git.rebase(self.tracks_dir, branch=branch) except exceptions.SupplyError: logger.exception("Cannot rebase due to local changes in [%s]" % self.tracks_dir) console.warn( "Local changes in [%s] prevent track update from remote. Please commit your changes." % self.tracks_dir) return else: msg = "Could not find track data remotely for distribution version [%s]. " \ "Trying to find track data locally." % distribution_version logger.warn(msg) branch = versions.best_match(git.branches(self.tracks_dir, remote=False), distribution_version) if branch: logger.info("Checking out [%s] in [%s] for distribution version [%s]." % (branch, self.tracks_dir, distribution_version)) git.checkout(self.tracks_dir, branch=branch) else: raise exceptions.SystemSetupError("Cannot find track data for distribution version %s" % distribution_version) except exceptions.SupplyError: tb = sys.exc_info()[2] raise exceptions.DataError("Cannot update track data in [%s]." % self.tracks_dir).with_traceback(tb)
def _update(self, distribution_version): try: if self.remote and not self.offline: branch = versions.best_match( git.branches(self.tracks_dir, remote=self.remote), distribution_version) if branch: logger.info( "Rebasing on '%s' in '%s' for distribution version '%s'." % (branch, self.tracks_dir, distribution_version)) git.rebase(self.tracks_dir, branch=branch) return else: msg = "Could not find track data remotely for distribution version %s. " \ "Trying to find track data locally." % distribution_version logger.warn(msg) branch = versions.best_match( git.branches(self.tracks_dir, remote=False), distribution_version) if branch: logger.info( "Checking out '%s' in '%s' for distribution version '%s'." % (branch, self.tracks_dir, distribution_version)) git.checkout(self.tracks_dir, branch=branch) else: raise exceptions.SystemSetupError( "Cannot find track data for distribution version %s" % distribution_version) except exceptions.SupplyError as e: raise exceptions.DataError("Cannot update track data in '%s': %s" % (self.tracks_dir, e))
def _update(self, distribution_version): try: if self.remote and not self.offline: branch = versions.best_match(git.branches(self.tracks_dir, remote=self.remote), distribution_version) if branch: # Allow uncommitted changes iff we do not have to change the branch logger.info( "Checking out [%s] in [%s] for distribution version [%s]." % (branch, self.tracks_dir, distribution_version)) git.checkout(self.tracks_dir, branch=branch) logger.info("Rebasing on [%s] in [%s] for distribution version [%s]." % (branch, self.tracks_dir, distribution_version)) try: git.rebase(self.tracks_dir, branch=branch) except exceptions.SupplyError: logger.exception("Cannot rebase due to local changes in [%s]" % self.tracks_dir) console.warn( "Local changes in [%s] prevent track update from remote. Please commit your changes." % self.tracks_dir) return else: msg = "Could not find track data remotely for distribution version [%s]. " \ "Trying to find track data locally." % distribution_version logger.warning(msg) branch = versions.best_match(git.branches(self.tracks_dir, remote=False), distribution_version) if branch: logger.info("Checking out [%s] in [%s] for distribution version [%s]." % (branch, self.tracks_dir, distribution_version)) git.checkout(self.tracks_dir, branch=branch) else: raise exceptions.SystemSetupError("Cannot find track data for distribution version %s" % distribution_version) except exceptions.SupplyError: tb = sys.exc_info()[2] raise exceptions.DataError("Cannot update track data in [%s]." % self.tracks_dir).with_traceback(tb)
def test_rebase(self, run_subprocess_with_logging): run_subprocess_with_logging.return_value = 0 git.rebase("/src", remote="my-origin", branch="feature-branch") calls = [ mock.call("git -C /src checkout feature-branch"), mock.call("git -C /src rebase my-origin/feature-branch"), ] run_subprocess_with_logging.assert_has_calls(calls)
def test_rebase(self, run_subprocess): run_subprocess.return_value = False git.rebase("/src", remote="my-origin", branch="feature-branch") calls = [ mock.call("git -C /src checkout --quiet feature-branch"), mock.call("git -C /src rebase --quiet my-origin/feature-branch") ] run_subprocess.assert_has_calls(calls)
def _update(self, distribution_version): try: if self.remote: branch = versions.best_match(git.branches(self.tracks_dir, remote=self.remote), distribution_version) if branch: logger.info("Rebasing on '%s' in '%s' for distribution version '%s'." % (branch, self.tracks_dir, distribution_version)) git.rebase(self.tracks_dir, branch=branch) return else: msg = "Could not find track data remotely for distribution version %s. " \ "Trying to find track data locally." % distribution_version logger.warn(msg) branch = versions.best_match(git.branches(self.tracks_dir, remote=False), distribution_version) if branch: logger.info("Checking out '%s' in '%s' for distribution version '%s'." % (branch, self.tracks_dir, distribution_version)) git.checkout(self.tracks_dir, branch=branch) else: raise exceptions.SystemSetupError("Cannot find track data for distribution version %s" % distribution_version) except exceptions.SupplyError as e: raise exceptions.DataError("Cannot update track data in '%s': %s" % (self.tracks_dir, e))