示例#1
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)
示例#2
0
 def test_pull_ts(self, run_subprocess_with_logging, run_subprocess):
     run_subprocess_with_logging.return_value = 0
     run_subprocess.return_value = False
     git.pull_ts("/src", "20160101T110000Z")
     run_subprocess.assert_called_with(
             "git -C /src fetch --prune --quiet origin && git -C /src checkout "
             "--quiet `git -C /src rev-list -n 1 --before=\"20160101T110000Z\" --date=iso8601 origin/master`")
示例#3
0
 def test_pull_ts(self, run_subprocess_with_logging, run_subprocess):
     run_subprocess_with_logging.return_value = 0
     run_subprocess.return_value = False
     git.pull_ts("/src", "20160101T110000Z")
     run_subprocess.assert_called_with(
             "git -C /src fetch --quiet origin && git -C /src checkout "
             "--quiet `git -C /src rev-list -n 1 --before=\"20160101T110000Z\" --date=iso8601 origin/master`")
示例#4
0
 def test_pull_ts(self, run_subprocess_with_logging, run_subprocess):
     run_subprocess_with_logging.return_value = 0
     run_subprocess.side_effect = [False, False]
     git.pull_ts("/src", "20160101T110000Z")
     run_subprocess.has_calls([
         mock.call("git -C /src fetch --prune --tags --quiet origin"),
         mock.call("git -C /src checkout --quiet `git -C /src rev-list -n 1 --before=\"20160101T110000Z\" "
                   "--date=iso8601 origin/master`"),
     ])
示例#5
0
 def _update(self, revision):
     if revision == "latest":
         logger.info("Fetching latest sources from origin.")
         git.pull(self.src_dir)
     elif revision == "current":
         logger.info("Skip fetching sources")
     elif revision.startswith("@"):
         # convert timestamp annotated for Rally to something git understands -> we strip leading and trailing " and the @.
         git.pull_ts(self.src_dir, revision[1:])
     else:  # assume a git commit hash
         git.pull_revision(self.src_dir, revision)
     git_revision = git.head_revision(self.src_dir)
     logger.info("Specified revision [%s] on command line results in git revision [%s]" % (revision, git_revision))
示例#6
0
 def _update(self, revision):
     if revision == "latest":
         logger.info("Fetching latest sources for %s from origin." % self.name)
         git.pull(self.src_dir)
     elif revision == "current":
         logger.info("Skip fetching sources for %s." % self.name)
     elif revision.startswith("@"):
         # convert timestamp annotated for Rally to something git understands -> we strip leading and trailing " and the @.
         git.pull_ts(self.src_dir, revision[1:])
     else:  # assume a git commit hash
         git.pull_revision(self.src_dir, revision)
     git_revision = git.head_revision(self.src_dir)
     logger.info("Specified revision [%s] for [%s] on command line results in git revision [%s]" % (revision, self.name, git_revision))
示例#7
0
    def test_pull_ts(self, run_subprocess_with_logging,
                     run_subprocess_with_output, run_subprocess):
        run_subprocess_with_logging.return_value = 0
        run_subprocess_with_output.return_value = ["3694a07"]
        run_subprocess.side_effect = [False, False]
        git.pull_ts("/src", "20160101T110000Z")

        run_subprocess_with_output.assert_called_with(
            'git -C /src rev-list -n 1 --before="20160101T110000Z" --date=iso8601 origin/master'
        )
        run_subprocess.has_calls([
            mock.call("git -C /src fetch --prune --tags --quiet origin"),
            mock.call("git -C /src checkout 3694a07"),
        ])