示例#1
0
文件: loader.py 项目: elastic/rally
 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)
示例#2
0
 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)
示例#3
0
 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))
示例#4
0
文件: loader.py 项目: levylll/rally
 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)
示例#5
0
文件: git_test.py 项目: joshuar/rally
 def test_list_local_branches(self, run_subprocess):
     run_subprocess.return_value = ["  HEAD",
                                    "  master",
                                    "  5.0.0-alpha1",
                                    "  5"]
     self.assertEqual(["master", "5.0.0-alpha1", "5"], git.branches("/src", remote=False))
     run_subprocess.assert_called_with("git -C /src for-each-ref refs/heads/ --format='%(refname:short)'")
示例#6
0
 def test_list_local_branches(self, run_subprocess_with_logging, run_subprocess):
     run_subprocess_with_logging.return_value = 0
     run_subprocess.return_value = ["  HEAD",
                                    "  master",
                                    "  5.0.0-alpha1",
                                    "  5"]
     self.assertEqual(["master", "5.0.0-alpha1", "5"], git.branches("/src", remote=False))
     run_subprocess.assert_called_with("git -C /src for-each-ref refs/heads/ --format='%(refname:short)'")
示例#7
0
 def test_list_remote_branches(self, run_subprocess_with_logging, run_subprocess):
     run_subprocess_with_logging.return_value = 0
     run_subprocess.return_value = ["  origin/HEAD",
                                    "  origin/master",
                                    "  origin/5.0.0-alpha1",
                                    "  origin/5"]
     self.assertEqual(["master", "5.0.0-alpha1", "5"], git.branches("/src", remote=True))
     run_subprocess.assert_called_with("git -C /src for-each-ref refs/remotes/ --format='%(refname:short)'")
示例#8
0
 def test_list_remote_branches(self, run_subprocess):
     run_subprocess.return_value = [
         "  origin/HEAD", "  origin/master", "  origin/5.0.0-alpha1",
         "  origin/5"
     ]
     self.assertEqual(["master", "5.0.0-alpha1", "5"],
                      git.branches("/src", remote=True))
     run_subprocess.assert_called_with(
         "git -C /src for-each-ref refs/remotes/ --format='%(refname:short)'"
     )
示例#9
0
文件: track.py 项目: joshuar/rally
 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))