diff options
Diffstat (limited to 'project.py')
| -rw-r--r-- | project.py | 21 |
1 files changed, 21 insertions, 0 deletions
| @@ -2311,6 +2311,27 @@ class Project(object): | |||
| 2311 | # Enable the extension! | 2311 | # Enable the extension! |
| 2312 | self.config.SetString('extensions.%s' % (key,), value) | 2312 | self.config.SetString('extensions.%s' % (key,), value) |
| 2313 | 2313 | ||
| 2314 | def ResolveRemoteHead(self, name=None): | ||
| 2315 | """Find out what the default branch (HEAD) points to. | ||
| 2316 | |||
| 2317 | Normally this points to refs/heads/master, but projects are moving to main. | ||
| 2318 | Support whatever the server uses rather than hardcoding "master" ourselves. | ||
| 2319 | """ | ||
| 2320 | if name is None: | ||
| 2321 | name = self.remote.name | ||
| 2322 | |||
| 2323 | # The output will look like (NB: tabs are separators): | ||
| 2324 | # ref: refs/heads/master HEAD | ||
| 2325 | # 5f6803b100bb3cd0f534e96e88c91373e8ed1c44 HEAD | ||
| 2326 | output = self.bare_git.ls_remote('-q', '--symref', '--exit-code', name, 'HEAD') | ||
| 2327 | |||
| 2328 | for line in output.splitlines(): | ||
| 2329 | lhs, rhs = line.split('\t', 1) | ||
| 2330 | if rhs == 'HEAD' and lhs.startswith('ref:'): | ||
| 2331 | return lhs[4:].strip() | ||
| 2332 | |||
| 2333 | return None | ||
| 2334 | |||
| 2314 | def _CheckForImmutableRevision(self): | 2335 | def _CheckForImmutableRevision(self): |
| 2315 | try: | 2336 | try: |
| 2316 | # if revision (sha or tag) is not present then following function | 2337 | # if revision (sha or tag) is not present then following function |
