Returns `(sha, comment, diff, branch)`, all items are str or None if not available. directory: Root of git checkout.
( directory)
| 2063 | |
| 2064 | |
| 2065 | def git_info( directory): |
| 2066 | ''' |
| 2067 | Returns `(sha, comment, diff, branch)`, all items are str or None if not |
| 2068 | available. |
| 2069 | |
| 2070 | directory: |
| 2071 | Root of git checkout. |
| 2072 | ''' |
| 2073 | sha, comment, diff, branch = None, None, None, None |
| 2074 | e, out = run( |
| 2075 | f'cd {directory} && (PAGER= git show --pretty=oneline|head -n 1 && git diff)', |
| 2076 | capture=1, |
| 2077 | check=0 |
| 2078 | ) |
| 2079 | if not e: |
| 2080 | sha, _ = out.split(' ', 1) |
| 2081 | comment, diff = _.split('\n', 1) |
| 2082 | e, out = run( |
| 2083 | f'cd {directory} && git rev-parse --abbrev-ref HEAD', |
| 2084 | capture=1, |
| 2085 | check=0 |
| 2086 | ) |
| 2087 | if not e: |
| 2088 | branch = out.strip() |
| 2089 | log1(f'git_info(): directory={directory!r} returning branch={branch!r} sha={sha!r} comment={comment!r}') |
| 2090 | return sha, comment, diff, branch |
| 2091 | |
| 2092 | |
| 2093 | def git_items( directory, submodules=False): |