Creates/updates local checkout of remote repository and returns absolute path of . If is set but does not start with 'git:', it is assumed to be an up to date local checkout, and we return absolute path of without doing any git operations.
(
local,
*,
remote=None,
branch=None,
tag=None,
text=None,
depth=1,
env_extra=None,
update=True,
submodules=True,
)
| 2130 | |
| 2131 | |
| 2132 | def git_get( |
| 2133 | local, |
| 2134 | *, |
| 2135 | remote=None, |
| 2136 | branch=None, |
| 2137 | tag=None, |
| 2138 | text=None, |
| 2139 | depth=1, |
| 2140 | env_extra=None, |
| 2141 | update=True, |
| 2142 | submodules=True, |
| 2143 | ): |
| 2144 | ''' |
| 2145 | Creates/updates local checkout <local> of remote repository and returns |
| 2146 | absolute path of <local>. |
| 2147 | |
| 2148 | If <text> is set but does not start with 'git:', it is assumed to be an up |
| 2149 | to date local checkout, and we return absolute path of <text> without doing |
| 2150 | any git operations. |
| 2151 | |
| 2152 | Args: |
| 2153 | local: |
| 2154 | Local directory. Created and/or updated using `git clone` and `git |
| 2155 | fetch` etc. |
| 2156 | remote: |
| 2157 | Remote git repostitory, for example |
| 2158 | 'https://github.com/ArtifexSoftware/mupdf.git'. Can be overridden |
| 2159 | by <text>. |
| 2160 | branch: |
| 2161 | Branch to use; can be overridden by <text>. |
| 2162 | tag: |
| 2163 | Tag to use; can be overridden by <text>. |
| 2164 | text: |
| 2165 | If None or empty: |
| 2166 | Ignored. |
| 2167 | |
| 2168 | If starts with 'git:': |
| 2169 | The remaining text should be a command-line |
| 2170 | style string containing some or all of these args: |
| 2171 | --branch <branch> |
| 2172 | --tag <tag> |
| 2173 | <remote> |
| 2174 | These overrides <branch>, <tag> and <remote>. |
| 2175 | Otherwise: |
| 2176 | <text> is assumed to be a local directory, and we simply return |
| 2177 | it as an absolute path without doing any git operations. |
| 2178 | |
| 2179 | For example these all clone/update/branch master of https://foo.bar/qwerty.git to local |
| 2180 | checkout 'foo-local': |
| 2181 | |
| 2182 | git_get('foo-local', remote='https://foo.bar/qwerty.git', branch='master') |
| 2183 | git_get('foo-local', text='git:--branch master https://foo.bar/qwerty.git') |
| 2184 | git_get('foo-local', text='git:--branch master', remote='https://foo.bar/qwerty.git') |
| 2185 | git_get('foo-local', text='git:', branch='master', remote='https://foo.bar/qwerty.git') |
| 2186 | depth: |
| 2187 | Depth of local checkout when cloning and fetching, or None. |
| 2188 | env_extra: |
| 2189 | Dict of extra name=value environment variables to use whenever we |