Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .githooks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ git config core.hooksPath .githooks

| Хук | Що робить |
|---|---|
| `prepare-commit-msg` | Якщо коміт робиться з сесії Claude Code (змінна `CLAUDECODE`), додає в кінець повідомлення `Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>`. Ідемпотентно; merge/squash не чіпає. Співавтора можна перевизначити: `git config claude.coauthor "Name <email>"`. |
| `prepare-commit-msg` | Якщо коміт робиться з сесії Claude Code (змінна `CLAUDECODE`), додає в кінець повідомлення повний блок атрибуції:<br>`Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>`<br>`Claude-Session: https://claude.ai/code/session_<id>` (з `CLAUDE_CODE_REMOTE_SESSION_ID`)<br>`Generated-With: Claude Code <version>` (з `CLAUDE_CODE_VERSION`).<br>Ідемпотентно; merge/squash не чіпає. Співавтора можна перевизначити: `git config claude.coauthor "Name <email>"`. |

Вимкнути назад: `git config --unset core.hooksPath`.
34 changes: 24 additions & 10 deletions .githooks/prepare-commit-msg
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
#!/bin/sh
# prepare-commit-msg — додає трейлер співавторства до коміту, коли коміт
# робиться з сесії Claude Code (у її оточенні є змінна CLAUDECODE).
# prepare-commit-msg — додає повний блок атрибуції до коміту, коли коміт
# робиться з сесії Claude Code (у її оточенні є змінна CLAUDECODE):
#
# Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
# Claude-Session: https://claude.ai/code/session_<id> (якщо відомо)
# Generated-With: Claude Code <version> (якщо відомо)
#
# Активація (один раз на клон):
# git config core.hooksPath .githooks
#
# Ідемпотентно: якщо трейлер уже є (наприклад, переданий через
# `git commit --trailer ...` або в тексті -m), другий не додається.
# Для merge/squash-комітів і rebase нічого не робить.
# Ідемпотентно: трейлер, що вже є (переданий через `git commit --trailer`
# або в тексті -m), другий раз не додається. Для merge/squash-комітів нічого
# не робить.
#
# Перевизначити співавтора: git config claude.coauthor "Name <email>"

MSG_FILE="$1"
SOURCE="$2"

# Лише для звичайних комітів (не merge, не squash, не amend через rebase)
# Лише для звичайних комітів (не merge, не squash)
case "$SOURCE" in
merge|squash) exit 0 ;;
esac
Expand All @@ -25,7 +29,17 @@ esac
COAUTHOR="$(git config --get claude.coauthor 2>/dev/null)"
[ -n "$COAUTHOR" ] || COAUTHOR="Claude Fable 5.1 <noreply@anthropic.com>"

git interpret-trailers --in-place \
--if-exists doNothing \
--trailer "Co-Authored-By: $COAUTHOR" \
"$MSG_FILE"
set -- --in-place --if-exists doNothing --trailer "Co-Authored-By: $COAUTHOR"

# Посилання на сесію: CLAUDE_CODE_REMOTE_SESSION_ID має вигляд cse_<id>,
# а публічний URL сесії — https://claude.ai/code/session_<id>
if [ -n "$CLAUDE_CODE_REMOTE_SESSION_ID" ]; then
SESSION_ID="${CLAUDE_CODE_REMOTE_SESSION_ID#cse_}"
set -- "$@" --trailer "Claude-Session: https://claude.ai/code/session_${SESSION_ID}"
fi

if [ -n "$CLAUDE_CODE_VERSION" ]; then
set -- "$@" --trailer "Generated-With: Claude Code ${CLAUDE_CODE_VERSION}"
fi

git interpret-trailers "$@" "$MSG_FILE"
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## [3.0.13] - 2026-09

### Changed — tooling
- `CLAUDE.md`: back to a single persistent working branch; PRs are merged
with a merge commit (not squash) so the branch is marked merged and the
merges are visible in the `main` graph — no branch deletion needed.

## [3.0.12] - 2026-09

### Changed — tooling
- `prepare-commit-msg` hook now writes the full attribution block instead
of a single line: `Co-Authored-By`, `Claude-Session` (URL derived from
`CLAUDE_CODE_REMOTE_SESSION_ID`) and `Generated-With: Claude Code <version>`
(from `CLAUDE_CODE_VERSION`); each trailer is added only if missing.
Documented in `.githooks/README.md`, `docs/INSTALL.md`, `CLAUDE.md`.

## [3.0.11] - 2026-09

### Changed — tooling
Expand Down
33 changes: 16 additions & 17 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,33 @@ pip install -e '.[full]' && pip install -r requirements-dev.txt
- **Кожен коміт бампає patch-версію** у двох місцях: `datamasking/_version.py`
та літерал `__version__` у `data_masking.py` (CI звіряє їх). Плюс запис у
`CHANGELOG.md` під новим `## [X.Y.Z]`.
- Трейлери в кінці повідомлення (хук додає `Co-Authored-By`, якщо
`core.hooksPath` увімкнено; інакше — вручну):
- Трейлери в кінці повідомлення — повний блок атрибуції (хук додає його
сам, якщо `core.hooksPath` увімкнено; інакше — вручну):
```
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: <URL сесії>
Claude-Session: https://claude.ai/code/session_<id>
Generated-With: Claude Code <version>
```
(`<id>` — `CLAUDE_CODE_REMOTE_SESSION_ID` без префікса `cse_`;
версія — `CLAUDE_CODE_VERSION`.)
- Ніяких ідентифікаторів моделі в коді, коментарях чи PR-описах — лише в трейлері.

## Робочий процес

1. Гілка розробки — тимчасова, одна на задачу, з фіксованим ім'ям
`claude/refactor-data-masking-lIcWN`: створюється від `origin/main`
(`git checkout -B claude/refactor-data-masking-lIcWN origin/main`), після
squash-мержу PR має зникнути з origin, щоб між задачами лишався лише
`main`. **Видалити її з цього середовища неможливо** — проксі відхиляє
`git push --delete` (як і теги), а GitHub API-інструменти видалення гілок
не мають. Тому видалення робить GitHub: у репозиторії має бути ввімкнено
Settings → General → Pull Requests → *Automatically delete head branches*
(або власник видаляє гілку вручну на сторінці Branches). Не намагатись
видаляти гілку з Claude Code — це марно. Наступна задача створює гілку
знову від актуального `main` (force-push поверх старої, якщо GitHub її
ще не прибрав, — нормально: вона містить лише вже змержену історію).
1. Гілка розробки — **постійна**: `claude/refactor-data-masking-lIcWN`.
Перед новою задачею синхронізувати з `main`
(`git fetch origin main && git checkout -B claude/refactor-data-masking-lIcWN origin/main`).
Гілку не видаляти і не пересоздавати (проксі не пропускає `push --delete`,
та й потреби немає: PR мержаться merge-комітом, тож після мержу гілка —
предок `main`, а не «побічна»).
2. Перед комітом: `python -m pytest tests/ -q -p no:cacheprovider`,
`python -m mypy datamasking/ --config-file mypy.ini` (має бути 0 помилок —
джоба blocking), `flake8 . --select=E9,F63,F7,F82`.
3. Push → PR у `main` → дочекатись **зеленого CI на всій матриці**
(Linux 3.9/3.11/3.13, Windows 3.12, core-only, package, mypy) → squash-merge
(гілку прибирає GitHub, п. 1).
(Linux 3.9/3.11/3.13, Windows 3.12, core-only, package, mypy) →
**merge-коміт (`merge_method: merge`), НЕ squash**: так GitHub позначає
гілку як merged, а в графі `main` видно кожен merge. Після мержу —
синхронізувати гілку з `main` (п. 1).
4. Стежити за CI через GitHub API за **повним SHA** (`?head_sha=<40 hex>`);
скорочений SHA API ігнорує.
5. **Теги через проксі не пушаться** — релізи створює користувач вручну
Expand Down
2 changes: 1 addition & 1 deletion data_masking.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
# Re-exports from masking package for backward compatibility
# ============================================================================

__version__ = "3.0.11"
__version__ = "3.0.13"

from datamasking.masking.constants import (
__version__, __author__, __contact__, __phone__, __license__, __year__,
Expand Down
2 changes: 1 addition & 1 deletion datamasking/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
(і не тягнучи faker під час збірки).
"""

__version__ = "3.0.11"
__version__ = "3.0.13"
13 changes: 10 additions & 3 deletions docs/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,16 @@ Enable them once per clone:
git config core.hooksPath .githooks
```

`prepare-commit-msg` appends `Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>`
to commits made from a Claude Code session (detected via the `CLAUDECODE`
environment variable); it is idempotent and leaves merge/squash commits alone.
`prepare-commit-msg` appends the attribution block to commits made from a Claude
Code session (detected via the `CLAUDECODE` environment variable):

```
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_<id>
Generated-With: Claude Code <version>
```

It is idempotent and leaves merge/squash commits alone.
Override the co-author with `git config claude.coauthor "Name <email>"`.

---
Expand Down
Loading