コード例 #1
0
ファイル: git.py プロジェクト: sikopet/pants
    def __init__(self,
                 binary='git',
                 gitdir=None,
                 worktree=None,
                 remote=None,
                 branch=None,
                 log=None):
        """Creates a git scm proxy that assumes the git repository is in the cwd by default.

    binary:    The path to the git binary to use, 'git' by default.
    gitdir:    The path to the repository's git metadata directory (typically '.git').
    worktree:  The path to the git repository working tree directory (typically '.').
    remote:    The default remote to use.
    branch:    The default remote branch to use.
    log:       A log object that supports debug, info, and warn methods.
    """
        Scm.__init__(self)

        self._gitcmd = binary
        self._worktree = os.path.realpath(worktree or os.getcwd())
        self._gitdir = os.path.realpath(gitdir) if gitdir else os.path.join(
            self._worktree, '.git')
        self._remote = remote
        self._branch = branch

        if log:
            self._log = log
        else:
            from twitter.common import log as c_log
            self._log = c_log
コード例 #2
0
ファイル: changed.py プロジェクト: jperkelens/pants
    def changed_files(self, *, scm: Scm) -> List[str]:
        """Determines the files changed according to SCM/workspace and options."""
        if self.diffspec:
            return cast(List[str], scm.changes_in(self.diffspec, relative_to=get_buildroot()))

        changes_since = self.since or scm.current_rev_identifier
        return cast(
            List[str],
            scm.changed_files(
                from_commit=changes_since, include_untracked=True, relative_to=get_buildroot()
            ),
        )
コード例 #3
0
ファイル: git.py プロジェクト: rogerswingle/pants
 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]
コード例 #4
0
ファイル: git.py プロジェクト: whoserepoisthis/pants
  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]
コード例 #5
0
ファイル: git.py プロジェクト: jcoveney/pants
  def __init__(self, binary='git', gitdir=None, worktree=None, remote=None, branch=None, log=None):
    """Creates a git scm proxy that assumes the git repository is in the cwd by default.

    binary:    The path to the git binary to use, 'git' by default.
    gitdir:    The path to the repository's git metadata directory (typically '.git').
    worktree:  The path to the git repository working tree directory (typically '.').
    remote:    The default remote to use.
    branch:    The default remote branch to use.
    log:       A log object that supports debug, info, and warn methods.
    """
    Scm.__init__(self)

    self._gitcmd = binary
    self._worktree = os.path.realpath(worktree or os.getcwd())
    self._gitdir = os.path.realpath(gitdir) if gitdir else os.path.join(self._worktree, '.git')
    self._remote = remote
    self._branch = branch

    if log:
      self._log = log
    else:
      from twitter.common import log as c_log
      self._log = c_log
コード例 #6
0
ファイル: git.py プロジェクト: rogerswingle/pants
  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
コード例 #7
0
ファイル: git.py プロジェクト: wisechengyi/pants
    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]
コード例 #8
0
ファイル: git.py プロジェクト: wisechengyi/pants
    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