mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-11-18 12:41:09 +08:00
* Make the git wrappers independent of the session's environment Tag mode's wrappers for git add, rm, commit and push now take their settings from files the action writes, and always work on the repository the action checked out. Git settings passed through the environment no longer reach them, so a workflow that relies on one, such as GIT_SSH_COMMAND, needs its own allow rule. Co-authored-by: mhegazy <[email protected]> * Keep narrow deny rules and other folders covered with the git wrappers A narrower deny rule such as git add -A now carries over to the wrapper. Global git config refuses a repository found in a plain folder for the session, since the settings no longer sit in the environment. The add wrapper also takes --chmod, and the wrappers use the home directory the action recorded. Co-authored-by: mhegazy <[email protected]> --------- Co-authored-by: Claude <[email protected]>
56 lines
1.3 KiB
Bash
Executable File
56 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Wrapper around `git commit` that only allows a literal message. Without it, an
|
|
# allow rule for `git commit` also permits flags that make git read a file into
|
|
# the commit, such as -F .git/config, which a later push would then publish.
|
|
#
|
|
# Usage:
|
|
# git-commit.sh -m "<message>" [-m "<message>"] [-a] [--allow-empty] [-- <paths>]
|
|
|
|
source "$(dirname "${BASH_SOURCE[0]}")/git-env.sh"
|
|
|
|
has_message=false
|
|
expect_message=false
|
|
paths_only=false
|
|
|
|
for arg in "$@"; do
|
|
if [[ "$expect_message" == true ]]; then
|
|
expect_message=false
|
|
has_message=true
|
|
continue
|
|
fi
|
|
if [[ "$paths_only" == true ]]; then
|
|
continue
|
|
fi
|
|
case "$arg" in
|
|
-m | --message | -am)
|
|
expect_message=true
|
|
;;
|
|
--message=*)
|
|
has_message=true
|
|
;;
|
|
-a | --all | --allow-empty | -q | --quiet | -s | --signoff)
|
|
;;
|
|
--)
|
|
paths_only=true
|
|
;;
|
|
-*)
|
|
echo "Error: only -m with a literal message and basic commit flags are allowed (got: $arg)" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
if [[ "$expect_message" == true ]]; then
|
|
echo "Error: -m needs a message" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ "$has_message" != true ]]; then
|
|
echo "Error: a message is required, with -m" >&2
|
|
exit 1
|
|
fi
|
|
|
|
exec git "${git_args[@]}" commit "$@"
|