Skip to content
Open
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
38 changes: 19 additions & 19 deletions docs/cli/configuration/hooks/git-workflows.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -508,27 +508,27 @@ if echo "$commit_msg" | grep -qE "Co-authored-by:"; then
exit 0
fi

# Add factory droid co-author
# Add factory droid co-author with proper newline handling
coauthor="Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>"

# Modify command to include co-author
modified_msg="$commit_msg

$coauthor"

# Return modified command via JSON output
cat << EOF
{
"hookSpecificOutput": {
"hookEventName": "PreToolUse",
"permissionDecision": "allow",
"permissionDecisionReason": "Adding co-author to commit",
"updatedInput": {
"command": "$(echo "$command" | sed -E "s/(git commit.*-m[= ]*)[\"']([^\"']+)[\"']/\1\"$modified_msg\"/")"
modified_msg="${commit_msg}\n\n${coauthor}"

# Build new command with properly escaped message
new_command=$(echo "$command" | sed -E "s|(git commit.*-m[= ]*)[\"']([^\"']+)[\"']|\1|")
new_command="${new_command} -m \"${modified_msg}\""

# Use jq to properly construct JSON with escaped strings
jq -n \
--arg cmd "$new_command" \
'{
"hookSpecificOutput": {
"hookEventName": "PreToolUse",
"permissionDecision": "allow",
"permissionDecisionReason": "Adding co-author to commit",
"updatedInput": {
"command": $cmd
}
}
}
}
EOF
}'

exit 0
```
Expand Down
Loading