Metadata-Version: 2.5
Name: githead
Version: 2.0.0
Summary: Simple utility for getting the current git commit hash (HEAD)
Project-URL: Issues, https://github.com/Zaczero/pkgs/issues
Project-URL: Repository, https://github.com/Zaczero/pkgs/tree/main/githead
Author-email: Kamil Monicz <kamil@monicz.dev>
License-Expression: 0BSD
License-File: LICENSE.md
Keywords: commit,git,git-commit,hash,head,vcs,version-control
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Zero-Clause BSD (0BSD)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.11
Description-Content-Type: text/markdown

# githead

[![PyPI - Python Version](https://shields.monicz.dev/pypi/pyversions/githead)](https://pypi.org/p/githead)

Read a checkout's Git HEAD from Python without launching Git. Python 3.11+.

## Installation

```sh
pip install githead
```

<a id="first-result"></a>

## Read a checkout's HEAD

Run from a checkout with a `.git` directory and a loose HEAD reference:

```py
from githead import githead

print(githead())
```

## githead reference

`githead(git_dir=".git")` accepts the metadata directory, not the working-tree
root. It returns the stripped contents of a detached `HEAD` or its loose
reference file.

This is a small file reader, not a general Git interface: packed refs, reftable,
unborn branches, and `.git` files used by worktrees or submodules are unsupported.
Missing files raise `FileNotFoundError`; references outside `git_dir` raise
`ValueError`. Other file-reading errors propagate.

[Full reference](https://raw.githubusercontent.com/Zaczero/pkgs/githead/2.0.0/githead/githead/__init__.py) ·
[Issues and questions](https://github.com/Zaczero/pkgs/issues) ·
[Private security reports](https://github.com/Zaczero/pkgs/security/advisories/new) ·
[Premium support](https://monicz.dev/#get-in-touch)
