Skip to content

Commit e5df298

Browse files
committed
refactor: remove 'local' keyword for variable declarations
- Removed 'local' keyword from variable declarations in 'git-context' script to ensure compatibility across different shell environments - No functional changes, only variable scope adjustments - Maintained existing logic and formatting for project context, branch info, diff output, and commit guidance
1 parent a0bbe5d commit e5df298

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

git-context

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ esac
8888

8989
# Include project context if requested
9090
if [ "$PROJECT_CONTEXT" = true ]; then
91-
local project_name=$(get_project_name)
92-
local project_description=""
91+
project_name=$(get_project_name)
92+
project_description=""
9393

9494
# Try to find project description
9595
if [ -f "package.json" ]; then
@@ -133,9 +133,9 @@ fi
133133

134134
# Show branch information if requested
135135
if [ "$BRANCH_INFO" = true ]; then
136-
local current_branch=$(git branch --show-current)
137-
local upstream=$(git rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null || echo "None")
138-
local tracking_status=$(git status -sb | head -n 1)
136+
current_branch=$(git branch --show-current)
137+
upstream=$(git rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null || echo "None")
138+
tracking_status=$(git status -sb | head -n 1)
139139

140140
case $FORMAT in
141141
md)
@@ -177,8 +177,8 @@ fi
177177

178178
# Show git diff if requested
179179
if [ "$SHOW_DIFF" = true ]; then
180-
local diff_cmd="git diff"
181-
local diff_title="Current Changes (Diff)"
180+
diff_cmd="git diff"
181+
diff_title="Current Changes (Diff)"
182182

183183
if [ "$STAGED_ONLY" = true ]; then
184184
diff_cmd="git diff --staged"
@@ -199,7 +199,7 @@ if [ "$SHOW_DIFF" = true ]; then
199199
fi
200200

201201
# Get the diff
202-
local diff_output=$(eval $diff_cmd)
202+
diff_output=$(eval $diff_cmd)
203203

204204
if [ -n "$diff_output" ]; then
205205
case $FORMAT in
@@ -215,7 +215,7 @@ if [ "$SHOW_DIFF" = true ]; then
215215
echo " \"diff\": {"
216216
echo " \"title\": \"$diff_title\","
217217
# Escape special characters for JSON
218-
local diff_json=$(echo "$diff_output" | sed 's/"/\\"/g' | sed ':a;N;$!ba;s/\n/\\n/g')
218+
diff_json=$(echo "$diff_output" | sed 's/"/\\"/g' | sed ':a;N;$!ba;s/\n/\\n/g')
219219
echo " \"content\": \"$diff_json\""
220220
echo " },"
221221
;;
@@ -232,7 +232,7 @@ if [ "$SHOW_DIFF" = true ]; then
232232
fi
233233

234234
# Show summary of files changed
235-
local files_changed=$(git diff --name-status)
235+
files_changed=$(git diff --name-status)
236236
if [ "$STAGED_ONLY" = true ]; then
237237
files_changed=$(git diff --staged --name-status)
238238
fi
@@ -390,7 +390,7 @@ fi
390390
# Include commit message guidance if requested
391391
if [ "$INCLUDE_PROMPT" = true ]; then
392392
# Get the prompt content from the file or use a default
393-
local prompt_content=""
393+
prompt_content=""
394394
if [ -f "prompts/commit_prompt.txt" ]; then
395395
prompt_content=$(cat "prompts/commit_prompt.txt")
396396
else
@@ -412,7 +412,7 @@ if [ "$INCLUDE_PROMPT" = true ]; then
412412
echo ","
413413
echo " \"commit_guidance\": {"
414414
# Escape special characters for JSON
415-
local guidance_json=$(echo "$prompt_content" | sed 's/"/\\"/g' | sed 's/\\n/\\\\n/g')
415+
guidance_json=$(echo "$prompt_content" | sed 's/"/\\"/g' | sed 's/\\n/\\\\n/g')
416416
echo " \"content\": \"$guidance_json\""
417417
if [ "$CONVENTIONAL" = true ]; then
418418
echo " \"conventional\": true"
@@ -433,4 +433,4 @@ if [ "$FORMAT" = "json" ]; then
433433
echo "}"
434434
fi
435435

436-
exit 0
436+
exit 0

0 commit comments

Comments
 (0)