Esempio n. 1
0
 def server_url(self):
   git_output = self._check_output(['remote', '--verbose'], raise_type=Scm.LocalException)
   origin_push_line = [line.split()[1] for line in git_output.splitlines()
                                       if 'origin' in line and '(push)' in line]
   if len(origin_push_line) != 1:
     raise Scm.LocalException('Unable to find origin remote amongst: ' + git_output)
   return origin_push_line[0]
Esempio n. 2
0
  def server_url(self):
    git_output = self._check_output(['remote', '--verbose'], raise_type=Scm.LocalException)

    def origin_urls():
      for line in git_output.splitlines():
        name, url, action = line.split()
        if name == 'origin' and action == '(push)':
          yield url

    origins = list(origin_urls())
    if len(origins) != 1:
      raise Scm.LocalException("Unable to find remote named 'origin' that accepts pushes "
                               "amongst:\n{}".format(git_output))
    return origins[0]
Esempio n. 3
0
  def _get_upstream(self):
    """Return the remote and remote merge branch for the current branch"""
    if not self._remote or not self._branch:
      branch = self.branch_name
      if not branch:
        raise Scm.LocalException('Failed to determine local branch')

      def get_local_config(key):
        value = self._check_output(['config', '--local', '--get', key],
                                   raise_type=Scm.LocalException)
        return value.strip()

      self._remote = self._remote or get_local_config('branch.{}.remote'.format(branch))
      self._branch = self._branch or get_local_config('branch.{}.merge'.format(branch))
    return self._remote, self._branch
Esempio n. 4
0
    def server_url(self):
        git_output = self._check_output(["remote", "--verbose"],
                                        raise_type=Scm.LocalException)

        def origin_urls():
            for line in git_output.splitlines():
                name, url, action = line.split()
                if name == "origin" and action == "(push)":
                    yield url

        origins = list(origin_urls())
        if len(origins) != 1:
            raise Scm.LocalException(
                f"Unable to find remote named 'origin' that accepts pushes "
                "amongst:\n{git_output}")
        return origins[0]
Esempio n. 5
0
    def _get_upstream(self):
        """Return the remote and remote merge branch for the current branch."""
        if not self._remote or not self._branch:
            branch = self.branch_name
            if not branch:
                raise Scm.LocalException("Failed to determine local branch")

            def get_local_config(key):
                value = self._check_output(["config", "--local", "--get", key],
                                           raise_type=Scm.LocalException)
                return value.strip()

            self._remote = self._remote or get_local_config(
                f"branch.{branch}.remote")
            self._branch = self._branch or get_local_config(
                f"branch.{branch}.merge")
        return self._remote, self._branch