Metadata-Version: 2.4
Name: function-diff
Version: 0.1.1
Summary: Function-level diff tool for Python files between Git refs
Project-URL: Homepage, https://github.com/Pandiyarajk/function-diff
Project-URL: Repository, https://github.com/Pandiyarajk/function-diff
Project-URL: Issues, https://github.com/Pandiyarajk/function-diff/issues
Author-email: Pandiyaraj Karuppasamy <pandiyarajk@live.com>
License: MIT
License-File: LICENSE
Keywords: ci-cd,diff,function,git,github-actions,python
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Version Control :: Git
Requires-Python: >=3.8
Description-Content-Type: text/markdown

# Function Diff

Compare **function-level** changes in Python files between two Git refs (branches, tags, or SHAs). Reports added, removed, and modified functions/methods—useful for reviews and CI.

## Install

```bash
pip install function-diff
```

Requires **Python 3.8+** and **Git** on `PATH`.

## CLI

```bash
function-diff <base_ref> <target_ref> [options]

function-diff main feature-branch
function-diff main HEAD --include-added
function-diff main HEAD --repo-path /path/to/repo
function-diff main feature --repo-url https://github.com/user/repo.git
function-diff main HEAD --send-email   # needs EMAIL_* (see below)

function-diff --version
function-diff --help
```

If you run from a Git checkout and omit `--repo-path`, the current directory is used when it contains `.git`. Otherwise set `--repo-url` or `FUNCTION_DIFF_REPO_URL`.

## Python API

```python
from function_diff import analyze, print_report, build_html_report

report = analyze(None, "main", "feature", repo_path=".")
print_report(report, include_added=True)
html = build_html_report(report, include_added=False)
```

Email from code: `from function_diff.emailer import send_function_diff_email` (set `EMAIL_USER`, `EMAIL_PASS`, `EMAIL_TO`; optional `EMAIL_FROM`, `EMAIL_CC`, `SMTP_HOST`, `SMTP_PORT`).

## Environment variables

| Variable | When | Notes |
|----------|------|--------|
| `EMAIL_USER` | `--send-email` / `send_function_diff_email` | SMTP login |
| `EMAIL_PASS` | same | App password or SMTP secret |
| `EMAIL_TO` | same | Comma-separated recipients |
| `EMAIL_FROM` | optional | From header; default `EMAIL_USER` (use for Azure “send as”) |
| `EMAIL_CC` | optional | Comma-separated CC |
| `SMTP_HOST` | optional | Default `smtp.gmail.com` |
| `SMTP_PORT` | optional | Default `587` (STARTTLS) |
| `GITHUB_REPOSITORY` | optional | Shown in HTML email |
| `BASE_REF` / `TARGET_REF` | optional | Override CLI refs |
| `FUNCTION_DIFF_REPO_URL` | optional | Clone URL when not using `--repo-path` |
| `GH_PAT` | private HTTPS clone | Use with Git credential helper or embed in clone URL |

**Gmail:** `SMTP_HOST=smtp.gmail.com`, `SMTP_PORT=587`.  
**Azure / Microsoft 365:** often `SMTP_HOST=smtp.office365.com`, `SMTP_PORT=587`; set `EMAIL_USER` to the mailbox that authenticates and `EMAIL_FROM` to the visible sender if they differ.

## GitHub Actions (minimal)

```yaml
- uses: actions/checkout@v4
  with:
    fetch-depth: 0
- uses: actions/setup-python@v5
  with:
    python-version: "3.12"
- run: pip install function-diff
- run: |
    function-diff \
      ${{ github.event.pull_request.base.ref }} \
      ${{ github.event.pull_request.head.ref }} \
      --repo-path ${{ github.workspace }}
```

For email, pass secrets as `EMAIL_USER`, `EMAIL_PASS`, `EMAIL_TO`, etc., and add `--send-email` when appropriate.

## How it works

Changed `.py` files between the two refs are diffed at the AST level: top-level functions and class methods (as `Class.method`) are hashed; decorator or body changes count as modified.

Optional: if `zephyr-jira-linker` is on `PATH`, branch names with a Jira key can enrich the email “implementor” field.

## Examples

See [`examples/`](examples/) and `examples/usage_examples.py`.

## Maintainer docs

Build, publish, and contributing notes: **[DEVELOPMENT.md](DEVELOPMENT.md)**. Version history: **[CHANGELOG.md](CHANGELOG.md)**.

## License

MIT — see [LICENSE](LICENSE).

## Author

Pandiyaraj Karuppasamy — [pandiyarajk@live.com](mailto:pandiyarajk@live.com) · [GitHub](https://github.com/Pandiyarajk/) · [PyPI](https://pypi.org/user/pandiyarajk/)
