示例#1
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))
示例#2
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))
示例#3
0
 def _update(self, revision):
     if self.has_remote() and revision == "latest":
         self.logger.info("Fetching latest sources for %s from origin.",
                          self.name)
         git.pull(self.src_dir)
     elif revision == "current":
         self.logger.info("Skip fetching sources for %s.", self.name)
     elif self.has_remote() and revision.startswith("@"):
         # convert timestamp annotated for Rally to something git understands -> we strip leading and trailing " and the @.
         git_ts_revision = revision[1:]
         self.logger.info(
             "Fetching from remote and checking out revision with timestamp [%s] for %s.",
             git_ts_revision, self.name)
         git.pull_ts(self.src_dir, git_ts_revision)
     elif self.has_remote():  # assume a git commit hash
         self.logger.info(
             "Fetching from remote and checking out revision [%s] for %s.",
             revision, self.name)
         git.pull_revision(self.src_dir, revision)
     else:
         self.logger.info("Checking out local revision [%s] for %s.",
                          revision, self.name)
         git.checkout(self.src_dir, revision)
     if git.is_working_copy(self.src_dir):
         git_revision = git.head_revision(self.src_dir)
         self.logger.info(
             "User-specified revision [%s] for [%s] results in git revision [%s]",
             revision, self.name, git_revision)
     else:
         self.logger.info(
             "Skipping git revision resolution for %s (%s is not a git repository).",
             self.name, self.src_dir)
示例#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 version():
    release = __version__
    try:
        if git.is_working_copy(io.normalize_path("%s/.." % rally_root_path())):
            revision = git.head_revision(rally_root_path())
            return "%s (git revision: %s)" % (release, revision.strip())
    except BaseException:
        pass
    # cannot determine head revision so user has probably installed Rally via pip instead of git clone
    return release
示例#6
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))
示例#7
0
文件: rally.py 项目: elastic/rally
def version():
    release = __version__
    try:
        if git.is_working_copy(io.normalize_path("%s/.." % rally_root_path())):
            revision = git.head_revision(rally_root_path())
            return "%s (git revision: %s)" % (release, revision.strip())
    except BaseException:
        pass
    # cannot determine head revision so user has probably installed Rally via pip instead of git clone
    return release
示例#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
 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
文件: version.py 项目: ynuosoft/rally
def revision():
    """
    :return: The current git revision if Rally is installed in development mode or ``None``.
    """
    # noinspection PyBroadException
    try:
        if git.is_working_copy(io.normalize_path("%s/.." % paths.rally_root())):
            raw_revision = git.head_revision(paths.rally_root())
            return raw_revision.strip()
    except BaseException:
        pass
    return None
示例#11
0
文件: config.py 项目: elastic/rally
    def _guess_es_src_dir(self):
        current_dir = os.getcwd()
        # try sibling elasticsearch directory (assuming that Rally is checked out alongside Elasticsearch)
        #
        # Note that if the current directory is the elasticsearch project directory, it will also be detected. We just cannot check
        # the current directory directly, otherwise any directory that is a git working copy will be detected as Elasticsearch project
        # directory.
        sibling_es_dir = os.path.abspath(os.path.join(current_dir, os.pardir, "elasticsearch"))
        child_es_dir = os.path.abspath(os.path.join(current_dir, "elasticsearch"))

        for candidate in [sibling_es_dir, child_es_dir]:
            if git.is_working_copy(candidate):
                return candidate
        return None
示例#12
0
    def _guess_es_src_dir(self):
        current_dir = os.getcwd()
        # try sibling elasticsearch directory (assuming that Rally is checked out alongside Elasticsearch)
        #
        # Note that if the current directory is the elasticsearch project directory, it will also be detected. We just cannot check
        # the current directory directly, otherwise any directory that is a git working copy will be detected as Elasticsearch project
        # directory.
        sibling_es_dir = os.path.abspath(os.path.join(current_dir, os.pardir, "elasticsearch"))
        child_es_dir = os.path.abspath(os.path.join(current_dir, "elasticsearch"))

        for candidate in [sibling_es_dir, child_es_dir]:
            if git.is_working_copy(candidate):
                return candidate
        return None
示例#13
0
文件: version.py 项目: reece15/rally
def version():
    """
    :return: The release version string and an optional suffix for the current git revision if Rally is installed in development mode.
    """
    release = __version__
    # noinspection PyBroadException
    try:
        if git.is_working_copy(io.normalize_path("%s/.." %
                                                 paths.rally_root())):
            revision = git.head_revision(paths.rally_root())
            return "%s (git revision: %s)" % (release, revision.strip())
    except BaseException:
        pass
    # cannot determine head revision so user has probably installed Rally via pip instead of git clone
    return release
示例#14
0
 def test_is_git_working_copy(self):
     test_dir = os.path.dirname(os.path.dirname(__file__))
     # this test is assuming that nobody stripped the git repo info in their Rally working copy
     self.assertFalse(git.is_working_copy(test_dir))
     self.assertTrue(git.is_working_copy(os.path.dirname(test_dir)))
示例#15
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)
示例#16
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)
示例#17
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)
示例#18
0
 def test_is_git_working_copy(self):
     test_dir = os.path.dirname(os.path.dirname(__file__))
     # this test is assuming that nobody stripped the git repo info in their Rally working copy
     self.assertFalse(git.is_working_copy(test_dir))
     self.assertTrue(git.is_working_copy(os.path.dirname(test_dir)))