File tree Expand file tree Collapse file tree 3 files changed +25
-0
lines changed
Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,9 @@ inputs:
7070 create_branch :
7171 description : Create new branch with the name of `branch`-input in local and remote repository, if it doesn't exist yet.
7272 default : false
73+ internal_git_binary :
74+ description : Internal use only! Path to git binary used to check if git is available. (Don't change this!)
75+ default : git
7376
7477outputs :
7578 changes_detected :
Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ if "$INPUT_DISABLE_GLOBBING"; then
77fi
88
99_main () {
10+ _check_if_git_is_available
11+
1012 _switch_to_repository
1113
1214 if _git_is_dirty || " $INPUT_SKIP_DIRTY_CHECK " ; then
@@ -42,6 +44,14 @@ _main() {
4244 fi
4345}
4446
47+ _check_if_git_is_available () {
48+ if hash -- " $INPUT_INTERNAL_GIT_BINARY " 2> /dev/null; then
49+ echo " ::debug::git binary found." ;
50+ else
51+ echo " ::error ::git-auto-commit could not find git binary. Please make sure git is available."
52+ exit 1;
53+ fi
54+ }
4555
4656_switch_to_repository () {
4757 echo " INPUT_REPOSITORY value: $INPUT_REPOSITORY " ;
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ setup() {
3737 export INPUT_SKIP_CHECKOUT=false
3838 export INPUT_DISABLE_GLOBBING=false
3939 export INPUT_CREATE_BRANCH=false
40+ export INPUT_INTERNAL_GIT_BINARY=git
4041
4142 # Set GitHub environment variables used by the GitHub Action
4243 temp_github_output_file=$( mktemp -t github_output_test.XXXXX)
@@ -1041,3 +1042,14 @@ cat_github_output() {
10411042 assert_line " ::set-output name=changes_detected::false"
10421043 refute_line -e " ::set-output name=commit_hash::[0-9a-f]{40}$"
10431044}
1045+
1046+ @test " It fails hard if git is not available" {
1047+ INPUT_INTERNAL_GIT_BINARY=binary-does-not-exist
1048+
1049+ touch " ${FAKE_LOCAL_REPOSITORY} " /new-file-{1,2,3}.txt
1050+
1051+ run git_auto_commit
1052+
1053+ assert_failure;
1054+ assert_line " ::error ::git-auto-commit could not find git binary. Please make sure git is available."
1055+ }
You can’t perform that action at this time.
0 commit comments