Skip to content

Commit 2e5f3ae

Browse files
committed
refactor: add conditional check for init.defaultBranch in your_program.sh to avoid unnecessary warnings
1 parent ed4e488 commit 2e5f3ae

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

internal/test_helpers/pass_all/your_program.sh

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ fi
1111
# Find git binary in /tmp locations
1212
for tmpdir in /tmp/git-*/git; do
1313
if [ -x "$tmpdir" ]; then
14-
"$tmpdir" config --global init.defaultBranch main
14+
if ! "$tmpdir" config --global --get init.defaultBranch >/dev/null 2>&1; then
15+
"$tmpdir" config --global init.defaultBranch main
16+
fi
1517

1618
# commit-tree stage doesn't use call this script for init
1719
# So we need to run this setup again
@@ -24,19 +26,7 @@ for tmpdir in /tmp/git-*/git; do
2426
"$tmpdir" add .
2527
fi
2628

27-
if [ "$1" != "init" ]; then
28-
exec "$tmpdir" "$@"
29-
# If init.defaultBranch is not set, set it to main
30-
# If not set globally, git always shows a warning
31-
# if ! "$tmpdir" config --global --get init.defaultBranch >/dev/null 2>&1; then
32-
# "$tmpdir" config --global init.defaultBranch main
33-
# fi
34-
# Setup is run locally so it's only set for the current temp repo
35-
"$tmpdir" config --local user.email "hello@codecrafters.io"
36-
"$tmpdir" config --local user.name "CodeCrafters-Bot"
37-
else
38-
exec "$tmpdir" "$@"
39-
fi
29+
exec "$tmpdir" "$@"
4030
fi
4131
done
4232

0 commit comments

Comments
 (0)