@@ -425,7 +425,6 @@ ensure_jq_binary() {
425
425
426
426
git_log () {
427
427
local format_value=$1
428
- local output
429
428
echo " $( git --no-pager log -1 --pretty=format:" ${format_value} " | " ${jq_binary} " -Rs .) "
430
429
}
431
430
@@ -442,6 +441,14 @@ export_coveralls_data() {
442
441
local service_pull_request=" "
443
442
local url=" unknown"
444
443
444
+ # Change directory to the target project repository.
445
+ # If input was read from stdin, presume we're in the right location already
446
+ if is_file " ${config_ston} " ; then
447
+ pushd " $( dirname ${config_ston} ) " > /dev/null
448
+ else
449
+ pushd " $( pwd) "
450
+ fi
451
+
445
452
if ! grep -q " #coverage" " ${config_ston} " ; then
446
453
return 0 # Coverage data not needed
447
454
fi
@@ -498,18 +505,36 @@ export_coveralls_data() {
498
505
499
506
ensure_jq_binary # required for git_log
500
507
508
+ local author_email=" "
509
+ local author_name=" "
510
+ local committer_email=" "
511
+ local committer_name=" "
512
+ local commit_id=" "
513
+ local commit_message=" "
514
+
515
+ author_email=" $( git_log " %ae" ) "
516
+ if [[ $? -ne 0 ]]; then
517
+ print_error " Failed to parse Git log. Not a Git repository?"
518
+ popd > /dev/null
519
+ return 0
520
+ fi
521
+ author_name=" $( git_log " %aN" ) "
522
+ committer_email=" $( git_log " %ce" ) "
523
+ committer_name=" $( git_log " %cN" ) "
524
+ commit_id=" $( git_log " %H" ) "
525
+ commit_message=" $( git_log " %s" ) "
501
526
cat > " ${SMALLTALK_CI_BUILD} /coveralls_build_data.json" << EOL
502
527
{
503
528
${optional_values}
504
529
"git": {
505
530
"branch": "${branch_name} ",
506
531
"head": {
507
- "author_email": $( git_log " %ae " ) ,
508
- "author_name": $( git_log " %aN " ) ,
509
- "committer_email": $( git_log " %ce " ) ,
510
- "committer_name": $( git_log " %cN " ) ,
511
- "id": $( git_log " %H " ) ,
512
- "message": $( git_log " %s " )
532
+ "author_email": " ${author_email} " ,
533
+ "author_name": " ${author_name} ,
534
+ "committer_email": " ${committer_email} " ,
535
+ "committer_name": " ${committer_name} " ,
536
+ "id": " ${commit_id} " ,
537
+ "message": " ${commit_message} "
513
538
},
514
539
"remotes": [
515
540
{
@@ -520,6 +545,8 @@ export_coveralls_data() {
520
545
}
521
546
}
522
547
EOL
548
+
549
+ popd > /dev/null
523
550
}
524
551
525
552
upload_coveralls_results () {
0 commit comments