コード例 #1
0
 def test_fetch_successful(self, run_subprocess_with_logging,
                           run_subprocess):
     run_subprocess_with_logging.return_value = 0
     run_subprocess.return_value = False
     git.fetch("/src", remote="my-origin")
     run_subprocess.assert_called_with(
         "git -C /src fetch --prune --quiet my-origin")
コード例 #2
0
 def test_fetch_with_error(self, run_subprocess_with_logging, run_subprocess):
     run_subprocess_with_logging.return_value = 0
     run_subprocess.return_value = True
     with self.assertRaises(exceptions.SupplyError) as ctx:
         git.fetch("/src", remote="my-origin")
     self.assertEqual("Could not fetch source tree from [my-origin]", ctx.exception.args[0])
     run_subprocess.assert_called_with("git -C /src fetch --prune --quiet my-origin")
コード例 #3
0
ファイル: git_test.py プロジェクト: danielmitterdorfer/rally
 def test_fetch_with_error(self, run_subprocess_with_logging, run_subprocess):
     run_subprocess_with_logging.return_value = 0
     run_subprocess.return_value = True
     with self.assertRaises(exceptions.SupplyError) as ctx:
         git.fetch("/src", remote="my-origin")
     self.assertEqual("Could not fetch source tree from 'my-origin'", ctx.exception.args[0])
     run_subprocess.assert_called_with("git -C /src fetch --prune --quiet my-origin")
コード例 #4
0
ファイル: repo.py プロジェクト: marks-chan/rally
 def __init__(self,
              remote_url,
              root_dir,
              repo_name,
              resource_name,
              offline,
              fetch=True):
     # If no URL is found, we consider this a local only repo (but still require that it is a git repo)
     self.url = remote_url
     self.remote = self.url is not None and self.url.strip() != ""
     self.repo_dir = os.path.join(root_dir, repo_name)
     self.resource_name = resource_name
     self.offline = offline
     self.logger = logging.getLogger(__name__)
     if self.remote and not self.offline and fetch:
         # a normal git repo with a remote
         if not git.is_working_copy(self.repo_dir):
             git.clone(src=self.repo_dir, remote=self.url)
         else:
             try:
                 git.fetch(src=self.repo_dir)
             except exceptions.SupplyError:
                 console.warn(
                     "Could not update %s. Continuing with your locally available state."
                     % self.resource_name)
     else:
         if not git.is_working_copy(self.repo_dir):
             raise exceptions.SystemSetupError(
                 "[{src}] must be a git repository.\n\nPlease run:\ngit -C {src} init"
                 .format(src=self.repo_dir))
コード例 #5
0
 def __init__(self, cfg, fetch=True):
     self.cfg = cfg
     self.name = cfg.opts("mechanic", "repository.name")
     self.offline = cfg.opts("system", "offline.mode")
     # If no URL is found, we consider this a local only repo (but still require that it is a git repo)
     self.url = cfg.opts("teams", "%s.url" % self.name, mandatory=False)
     self.remote = self.url is not None and self.url.strip() != ""
     root = cfg.opts("node", "root.dir")
     team_repositories = cfg.opts("mechanic", "team.repository.dir")
     self.teams_dir = os.path.join(root, team_repositories, self.name)
     if self.remote and not self.offline and fetch:
         # a normal git repo with a remote
         if not git.is_working_copy(self.teams_dir):
             git.clone(src=self.teams_dir, remote=self.url)
         else:
             try:
                 git.fetch(src=self.teams_dir)
             except exceptions.SupplyError:
                 console.warn(
                     "Could not update teams. Continuing with your locally available state.",
                     logger=logger)
     else:
         if not git.is_working_copy(self.teams_dir):
             raise exceptions.SystemSetupError(
                 "[{src}] must be a git repository.\n\nPlease run:\ngit -C {src} init"
                 .format(src=self.teams_dir))
コード例 #6
0
ファイル: git_test.py プロジェクト: ynuosoft/rally
 def test_fetch_with_error(self, run_subprocess_with_logging):
     # first call is to check the git version (0 -> succeeds), the second call is the failing checkout (1 -> fails)
     run_subprocess_with_logging.side_effect = [0, 1]
     with pytest.raises(exceptions.SupplyError) as exc:
         git.fetch("/src", remote="my-origin")
     assert exc.value.args[
         0] == "Could not fetch source tree from [my-origin]"
     run_subprocess_with_logging.assert_called_with(
         "git -C /src fetch --prune --tags my-origin")
コード例 #7
0
ファイル: track.py プロジェクト: dakrone/rally
 def __init__(self, cfg):
     self.cfg = cfg
     self.name = cfg.opts("system", "track.repository")
     # If no URL is found, we consider this a local only repo (but still require that it is a git repo)
     self.url = cfg.opts("tracks", "%s.url" % self.name, mandatory=False)
     self.remote = self.url is not None and self.url.strip() != ""
     root = cfg.opts("system", "root.dir")
     track_repositories = cfg.opts("benchmarks", "track.repository.dir")
     self.tracks_dir = "%s/%s/%s" % (root, track_repositories, self.name)
     if self.remote:
         # a normal git repo with a remote
         if not git.is_working_copy(self.tracks_dir):
             git.clone(src=self.tracks_dir, remote=self.url)
         else:
             git.fetch(src=self.tracks_dir, remote=self.url)
     else:
         if not git.is_working_copy(self.tracks_dir):
             raise exceptions.SystemSetupError("'{src}' must be a git repository.\n\nPlease run:\ngit -C {src} init"
                                               .format(src=self.tracks_dir))
コード例 #8
0
ファイル: track.py プロジェクト: joshuar/rally
 def __init__(self, cfg):
     self.cfg = cfg
     self.name = cfg.opts("system", "track.repository")
     # If no URL is found, we consider this a local only repo (but still require that it is a git repo)
     self.url = cfg.opts("tracks", "%s.url" % self.name, mandatory=False)
     self.remote = self.url is not None and self.url.strip() != ""
     root = cfg.opts("system", "root.dir")
     track_repositories = cfg.opts("benchmarks", "track.repository.dir")
     self.tracks_dir = "%s/%s/%s" % (root, track_repositories, self.name)
     if self.remote:
         # a normal git repo with a remote
         if not git.is_working_copy(self.tracks_dir):
             git.clone(src=self.tracks_dir, remote=self.url)
         else:
             git.fetch(src=self.tracks_dir, remote=self.url)
     else:
         if not git.is_working_copy(self.tracks_dir):
             raise exceptions.SystemSetupError("'{src}' must be a git repository.\n\nPlease run:\ngit -C {src} init"
                                               .format(src=self.tracks_dir))
コード例 #9
0
ファイル: repo.py プロジェクト: danielmitterdorfer/rally
 def __init__(self, remote_url, root_dir, repo_name, resource_name, offline, fetch=True):
     # If no URL is found, we consider this a local only repo (but still require that it is a git repo)
     self.url = remote_url
     self.remote = self.url is not None and self.url.strip() != ""
     self.repo_dir = os.path.join(root_dir, repo_name)
     self.resource_name = resource_name
     self.offline = offline
     if self.remote and not self.offline and fetch:
         # a normal git repo with a remote
         if not git.is_working_copy(self.repo_dir):
             git.clone(src=self.repo_dir, remote=self.url)
         else:
             try:
                 git.fetch(src=self.repo_dir)
             except exceptions.SupplyError:
                 console.warn("Could not update %s. Continuing with your locally available state." % self.resource_name, logger=logger)
     else:
         if not git.is_working_copy(self.repo_dir):
             raise exceptions.SystemSetupError("[{src}] must be a git repository.\n\nPlease run:\ngit -C {src} init"
                                               .format(src=self.repo_dir))
コード例 #10
0
ファイル: git_test.py プロジェクト: ynuosoft/rally
 def test_fetch_successful(self, run_subprocess_with_logging):
     run_subprocess_with_logging.return_value = 0
     git.fetch("/src", remote="my-origin")
     run_subprocess_with_logging.assert_called_with(
         "git -C /src fetch --prune --tags my-origin")
コード例 #11
0
ファイル: git_test.py プロジェクト: danielmitterdorfer/rally
 def test_fetch_successful(self, run_subprocess_with_logging, run_subprocess):
     run_subprocess_with_logging.return_value = 0
     run_subprocess.return_value = False
     git.fetch("/src", remote="my-origin")
     run_subprocess.assert_called_with("git -C /src fetch --prune --quiet my-origin")