Skip to content

Commit ed4e488

Browse files
committed
refactor: simplify git configuration in your_program.sh by setting init.defaultBranch to main unconditionally
1 parent 7bae508 commit ed4e488

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

internal/test_helpers/pass_all/your_program.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ 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
15+
1416
# commit-tree stage doesn't use call this script for init
1517
# So we need to run this setup again
1618
if [ "$1" = "commit-tree" ]; then
@@ -22,13 +24,13 @@ for tmpdir in /tmp/git-*/git; do
2224
"$tmpdir" add .
2325
fi
2426

25-
if [ "$1" = "init" ]; then
26-
"$tmpdir" "$@"
27+
if [ "$1" != "init" ]; then
28+
exec "$tmpdir" "$@"
2729
# If init.defaultBranch is not set, set it to main
2830
# If not set globally, git always shows a warning
29-
if ! "$tmpdir" config --global --get init.defaultBranch >/dev/null 2>&1; then
30-
"$tmpdir" config --global init.defaultBranch main
31-
fi
31+
# if ! "$tmpdir" config --global --get init.defaultBranch >/dev/null 2>&1; then
32+
# "$tmpdir" config --global init.defaultBranch main
33+
# fi
3234
# Setup is run locally so it's only set for the current temp repo
3335
"$tmpdir" config --local user.email "hello@codecrafters.io"
3436
"$tmpdir" config --local user.name "CodeCrafters-Bot"

0 commit comments

Comments
 (0)