@@ -25,7 +25,7 @@ if [ -z $IDF_TARGET ]; then
25
25
fi
26
26
27
27
# Owner of the target ESP32 Arduino repository
28
- AR_USER=" espressif "
28
+ AR_USER=" $GITHUB_REPOSITORY_OWNER "
29
29
30
30
# The full name of the repository
31
31
AR_REPO=" $AR_USER /arduino-esp32"
@@ -99,12 +99,55 @@ if [[ "$AR_OS" == "macos" ]]; then
99
99
export SSTAT=" stat -f %z"
100
100
fi
101
101
102
+ function github_get_libs_idf(){ # github_get_libs_idf <repo-path> <branch-name> <message-prefix>
103
+ local repo_path=" $1 "
104
+ local branch_name=" $2 "
105
+ local message_prefix=" $3 "
106
+ message_prefix=$( echo $message_prefix | sed ' s/[]\/$*.^|[]/\\&/g' ) # Escape special characters
107
+ local page=1
108
+ local version_found=" "
109
+ local libs_version=" "
110
+
111
+ while [[ " $libs_version " == " " && " $page " -le 3 ]]; do
112
+ # Get the latest commit message that matches the prefix and extract the hash from the last commit message
113
+ version_found=` curl -s -k -H " Authorization: token $GITHUB_TOKEN " -H " Accept: application/vnd.github.v3.raw+json" " https://api.github.com/repos/$repo_path /commits?sha=$branch_name &per_page=100&page=$page " | \
114
+ jq -r --arg prefix " $message_prefix " ' [ .[] | select(.commit.message | test($prefix + " [a-f0-9]{8}")) ][0] | .commit.message' | \
115
+ grep -Eo " $message_prefix [a-f0-9]{8}" | \
116
+ awk ' END {print $NF}' `
117
+ if [[ " $version_found " != " " && " $version_found " != " null" ]]; then
118
+ libs_version=$version_found
119
+ else
120
+ page=$(( page+ 1 ))
121
+ fi
122
+ done
123
+
124
+ if [ ! " $libs_version " == " " ] && [ ! " $libs_version " == " null" ]; then echo $libs_version ; else echo " " ; fi
125
+ }
126
+
102
127
function github_commit_exists(){ # github_commit_exists <repo-path> <branch-name> <commit-message>
103
128
local repo_path=" $1 "
104
129
local branch_name=" $2 "
105
130
local commit_message=" $3 "
106
- local commits_found=` curl -s -k -H " Authorization: token $GITHUB_TOKEN " -H " Accept: application/vnd.github.v3.raw+json" " https://api.github.com/repos/$repo_path /commits?sha=$branch_name " | jq -r ' .[].commit.message' | grep " $commit_message " | wc -l`
107
- if [ ! " $commits_found " == " " ] && [ ! " $commits_found " == " null" ] && [ ! " $commits_found " == " 0" ]; then echo $commits_found ; else echo 0; fi
131
+ local page=1
132
+ local commits_found=0
133
+
134
+ while [ " $page " -le 3 ]; do
135
+ local response=` curl -s -k -H " Authorization: token $GITHUB_TOKEN " -H " Accept: application/vnd.github.v3.raw+json" " https://api.github.com/repos/$repo_path /commits?sha=$branch_name &per_page=100&page=$page " `
136
+
137
+ if [[ -z " $response " || " $response " == " []" ]]; then
138
+ break
139
+ fi
140
+
141
+ local commits=` echo " $response " | jq -r ' .[].commit.message' | grep " $commit_message " | wc -l`
142
+ if [ " $commits " -gt 0 ]; then
143
+ commits_found=1
144
+ break
145
+ fi
146
+
147
+ page=$(( page+ 1 ))
148
+ done
149
+
150
+ echo $commits_found
108
151
}
109
152
110
153
function github_last_commit(){ # github_last_commit <repo-path> <branch-name>
0 commit comments