示例#1
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))
示例#2
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))
示例#3
0
    def test_clone_successful(self, run_subprocess_with_logging, ensure_dir):
        run_subprocess_with_logging.return_value = 0
        src = "/src"
        remote = "http://github.com/some/project"

        git.clone(src, remote)

        ensure_dir.assert_called_with(src)
        run_subprocess_with_logging.assert_called_with("git clone http://github.com/some/project /src")
示例#4
0
 def _try_init(self, may_skip_init=False):
     if not git.is_working_copy(self.src_dir):
         if self.has_remote():
             self.logger.info("Downloading sources for %s from %s to %s.", self.name, self.remote_url, self.src_dir)
             git.clone(self.src_dir, self.remote_url)
         elif os.path.isdir(self.src_dir) and may_skip_init:
             self.logger.info("Skipping repository initialization for %s.", self.name)
         else:
             exceptions.SystemSetupError("A remote repository URL is mandatory for %s" % self.name)
示例#5
0
    def test_clone_successful(self, run_subprocess, ensure_dir):
        run_subprocess.return_value = False
        src = "/src"
        remote = "http://github.com/some/project"

        git.clone(src, remote)

        ensure_dir.assert_called_with(src)
        run_subprocess.assert_called_with("git clone http://github.com/some/project /src")
示例#6
0
    def test_clone_with_error(self, run_subprocess_with_logging, ensure_dir):
        run_subprocess_with_logging.return_value = 128
        src = "/src"
        remote = "http://github.com/some/project"

        with self.assertRaises(exceptions.SupplyError) as ctx:
            git.clone(src, remote)
        self.assertEqual("Could not clone from [http://github.com/some/project] to [/src]", ctx.exception.args[0])

        ensure_dir.assert_called_with(src)
        run_subprocess_with_logging.assert_called_with("git clone http://github.com/some/project /src")
示例#7
0
文件: git_test.py 项目: joshuar/rally
    def test_clone_with_error(self, run_subprocess, ensure_dir):
        run_subprocess.return_value = True
        src = "/src"
        remote = "http://github.com/some/project"

        with self.assertRaises(exceptions.SupplyError) as ctx:
            git.clone(src, remote)
        self.assertEqual("Could not clone from 'http://github.com/some/project' to '/src'", ctx.exception.args[0])

        ensure_dir.assert_called_with(src)
        run_subprocess.assert_called_with("git clone http://github.com/some/project /src")
示例#8
0
    def test_clone_with_error(self, run_subprocess_with_logging, ensure_dir):
        run_subprocess_with_logging.return_value = 128
        src = "/src"
        remote = "http://github.com/some/project"

        with pytest.raises(exceptions.SupplyError) as exc:
            git.clone(src, remote)
        assert exc.value.args[
            0] == "Could not clone from [http://github.com/some/project] to [/src]"

        ensure_dir.assert_called_with(src)
        run_subprocess_with_logging.assert_called_with(
            "git clone http://github.com/some/project /src")
示例#9
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))
示例#10
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))
示例#11
0
 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))
示例#12
0
 def _try_init(self):
     if not git.is_working_copy(self.src_dir):
         console.println("Downloading sources from %s to %s." %
                         (self.remote_url, self.src_dir))
         git.clone(self.src_dir, self.remote_url)
示例#13
0
 def _try_init(self):
     if not git.is_working_copy(self.src_dir):
         console.println("Downloading sources for %s from %s to %s." % (self.name, self.remote_url, self.src_dir))
         git.clone(self.src_dir, self.remote_url)
示例#14
0
文件: supplier.py 项目: joshuar/rally
 def _try_init(self):
     if not git.is_working_copy(self.src_dir):
         print("Downloading sources from %s to %s." % (self.remote_url, self.src_dir))
         git.clone(self.src_dir, self.remote_url)