Skip to content

Commit 7505439

Browse files
authored
Fixes gh-10 : Tests fail on git version v2.26.2 (#11)
1 parent 1fff8f7 commit 7505439

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

_tests.sh

+11-9
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ function testcase_header() {
3030

3131
function eval_testcase() {
3232
# expect to be in repo to test against
33-
if [[ -s "${root_folder}/${test}/git-test.log" ]]; then
34-
echo "INFO: ${root_folder}/${test}/git-test.log is not empty - use it"
35-
else
33+
if ! [[ -s "${root_folder}/${test}/git-test.log" ]]; then
3634
git log --graph --all --oneline --decorate --format="%d %s" > "${root_folder}/${test}/git-test.log"
35+
else
36+
[[ ${debug:-} == true ]] && echo "Test $test : INFO: ${root_folder}/${test}/git-test.log is already available - use it"
3737
fi
3838
cd "${root_folder}/${test}"
3939
if diff -w git-test.log git-reference.log ; then
4040
if [[ ${verbose:-} == true ]] ; then
4141
cat git-test.log
42-
echo "INFO: Test $test : OK"
42+
echo "Test $test : OK"
4343
echo
4444
else
45-
echo "INFO: Test $test : OK : ${testcase_synopsis}"
45+
echo "Test $test : OK : ${testcase_synopsis}"
4646
fi
4747
else
4848
echo "ERROR: Test $test failed: ${testcase_synopsis}"
@@ -52,10 +52,12 @@ function eval_testcase() {
5252
}
5353

5454
function generate_base_repo() {
55-
rm -rf "$local_tester_repo/" "$remote_tester_repo/" "$clone_tester_repo/"
56-
git init --bare -b ${default_branch:-main} $remote_tester_repo
57-
git -C $remote_tester_repo symbolic-ref HEAD refs/heads/${default_branch:-main}
58-
git artifact init --url=$(pwd)/$remote_tester_repo --path $local_tester_repo -b ${default_branch:-main}
55+
rm -rf "${local_tester_repo:?}/" "${remote_tester_repo:?}/" "${clone_tester_repo:?}/"
56+
git init --bare -b "${default_branch:-main}" $remote_tester_repo || {
57+
git init --bare $remote_tester_repo
58+
git -C $remote_tester_repo symbolic-ref HEAD refs/heads/${default_branch:-main}
59+
}
60+
git artifact init --url="$(pwd)/$remote_tester_repo" --path $local_tester_repo -b ${default_branch:-main}
5961
cd $local_tester_repo
6062
touch test.txt
6163
git artifact add-n-push -t v1.0

git-artifact

+9-2
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,10 @@ cmd_init() {
139139
local _base_branch=
140140
set_base_branch _base_branch
141141

142-
git init -b ${_base_branch} "$_dir"
142+
git init -b "${_base_branch}" "$_dir" || {
143+
git init "$_dir"
144+
git -C "$_dir" switch -C "${_base_branch}"
145+
}
143146
cd "$_dir"
144147
git_local_config
145148
git remote add origin "$arg_remoteurl"
@@ -151,7 +154,11 @@ cmd_init() {
151154
echo ""
152155
echo ".. based on the tool: https://github.com/Praqma/git-artifact.git"
153156
} > README.md
154-
git add .
157+
git add . || {
158+
pwd
159+
echo "ERROR: git add failed"
160+
exit 1
161+
}
155162
git commit -m "First commit of git artifact"
156163
git push origin "HEAD:refs/heads/${_base_branch}" -f
157164

0 commit comments

Comments
 (0)