A git wrapper (docker/git-coauthor -> /usr/local/lib/codecraft/bin/git) adds
--trailer "$CODECRAFT_COMMIT_TRAILER" right after the commit subcommand; the
agent shell puts it first on PATH and sets the trailer in the script itself
(works inside the sandbox, which clears the environment). Default text:
"Co-Authored-By: {model} ({provider}) via CodeCraft" (server.commit_trailer,
Settings -> General; empty = off). Git skips duplicates (amend, model wrote it).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
22 lines
890 B
Bash
Executable File
22 lines
890 B
Bash
Executable File
#!/bin/bash
|
|
# git for the shells of CodeCraft agents: `git commit` gets the co-author trailer from
|
|
# $CODECRAFT_COMMIT_TRAILER (model, provider, CodeCraft). Everything else goes to the real
|
|
# git unchanged. Git itself skips the trailer when the message already ends with it.
|
|
real=${CODECRAFT_REAL_GIT:-/usr/bin/git}
|
|
[[ -n $CODECRAFT_COMMIT_TRAILER ]] || exec "$real" "$@"
|
|
# The subcommand comes after git's global options (-C dir, -c key=value, --git-dir=…).
|
|
i=1
|
|
while (( i <= $# )); do
|
|
case ${!i} in
|
|
-C | -c | --git-dir | --work-tree | --namespace | --exec-path | --config-env) i=$((i + 2)) ;;
|
|
--) break ;;
|
|
-*) i=$((i + 1)) ;;
|
|
*) break ;;
|
|
esac
|
|
done
|
|
if (( i <= $# )) && [[ ${!i} == commit ]]; then
|
|
# Right after "commit", so it stays an option even before "-- <paths>".
|
|
exec "$real" "${@:1:i}" --trailer "$CODECRAFT_COMMIT_TRAILER" "${@:i+1}"
|
|
fi
|
|
exec "$real" "$@"
|