diff options
Diffstat (limited to 'source-builder/sb/git.py')
-rw-r--r-- | source-builder/sb/git.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/source-builder/sb/git.py b/source-builder/sb/git.py index 237e690..0aa4da9 100644 --- a/source-builder/sb/git.py +++ b/source-builder/sb/git.py @@ -226,6 +226,18 @@ class repo: hash = l1[len('commit '):] return hash + def default_branch(self): + ec, output = self._run(['remote', 'show']) + if ec == 0: + origin = output.split('\n')[0] + ec, output = self._run(['remote', 'show', origin]) + if ec == 0: + for l in output.split('\n'): + l = l.strip() + if l.startswith('HEAD branch: '): + return l[len('HEAD branch: '):] + return None + if __name__ == '__main__': import os.path import sys |