Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
git_utils.NewGitCheckout Class Reference
Inheritance diagram for git_utils.NewGitCheckout:
utils.tmp_dir

Public Member Functions

def __init__ (self, repository, local=None)
 
def name (self)
 
def root (self)
 
def __enter__ (self)
 
- Public Member Functions inherited from utils.tmp_dir
def __init__ (self)
 
def __enter__ (self)
 
def __exit__ (self, t, v, tb)
 
def name (self)
 

Detailed Description

Creates a new local checkout of a Git repository.

Definition at line 103 of file git_utils.py.

Constructor & Destructor Documentation

◆ __init__()

def git_utils.NewGitCheckout.__init__ (   self,
  repository,
  local = None 
)
Set parameters for this local copy of a Git repository.

Because this is a new checkout, rather than a reference to an existing
checkout on disk, it is safe to assume that the calling thread is the
only thread manipulating the checkout.

You must use the 'with' statement to create this object:

with NewGitCheckout(*args) as checkout:
  # use checkout instance
# the checkout is automatically cleaned up here

Args:
  repository: URL of the remote repository (e.g.,
      'https://skia.googlesource.com/common') or path to a local repository
      (e.g., '/path/to/repo/.git') to check out a copy of
  local: optional path to an existing copy of the remote repo on local disk.
      If provided, the initial clone is performed with the local copy as the
      upstream, then the upstream is switched to the remote repo and the
      new copy is updated from there.

Reimplemented from utils.tmp_dir.

Definition at line 106 of file git_utils.py.

106 def __init__(self, repository, local=None):
107 """Set parameters for this local copy of a Git repository.
108
109 Because this is a new checkout, rather than a reference to an existing
110 checkout on disk, it is safe to assume that the calling thread is the
111 only thread manipulating the checkout.
112
113 You must use the 'with' statement to create this object:
114
115 with NewGitCheckout(*args) as checkout:
116 # use checkout instance
117 # the checkout is automatically cleaned up here
118
119 Args:
120 repository: URL of the remote repository (e.g.,
121 'https://skia.googlesource.com/common') or path to a local repository
122 (e.g., '/path/to/repo/.git') to check out a copy of
123 local: optional path to an existing copy of the remote repo on local disk.
124 If provided, the initial clone is performed with the local copy as the
125 upstream, then the upstream is switched to the remote repo and the
126 new copy is updated from there.
127 """
128 super(NewGitCheckout, self).__init__()
129 self._checkout_root = ''
130 self._repository = repository
131 self._local = local
132

Member Function Documentation

◆ __enter__()

def git_utils.NewGitCheckout.__enter__ (   self)
Check out a new local copy of the repository.

Uses the parameters that were passed into the constructor.

Reimplemented from utils.tmp_dir.

Definition at line 142 of file git_utils.py.

142 def __enter__(self):
143 """Check out a new local copy of the repository.
144
145 Uses the parameters that were passed into the constructor.
146 """
147 super(NewGitCheckout, self).__enter__()
148 remote = self._repository
149 if self._local:
150 remote = self._local
151 subprocess.check_call(['git', 'clone', remote])
152 repo_name = remote.split('/')[-1]
153 if repo_name.endswith('.git'):
154 repo_name = repo_name[:-len('.git')]
155 self._checkout_root = os.path.join(os.getcwd(), repo_name)
156 os.chdir(repo_name)
157 if self._local:
158 subprocess.check_call([
159 'git', 'remote', 'set-url', 'origin', self._repository])
160 subprocess.check_call(['git', 'remote', 'update'])
161 subprocess.check_call(['git', 'checkout', 'main'])
162 subprocess.check_call(['git', 'reset', '--hard', 'origin/main'])
163 return self

◆ name()

def git_utils.NewGitCheckout.name (   self)

Reimplemented from utils.tmp_dir.

Definition at line 134 of file git_utils.py.

134 def name(self):
135 return self._checkout_root
136
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

◆ root()

def git_utils.NewGitCheckout.root (   self)
Returns the root directory containing the checked-out files.

Definition at line 138 of file git_utils.py.

138 def root(self):
139 """Returns the root directory containing the checked-out files."""
140 return self.name
141
string root
Definition: scale_cpu.py:20

The documentation for this class was generated from the following file: