@@ -193,16 +193,24 @@ _get_files_and_commits() {
193
193
# shellcheck disable=SC2086
194
194
html_get_files_and_commits=" $( curl -s --compressed " https://github.com/${repo_get_files_and_commits} /file-list/${type_value_get_files_and_commits} /${path_get_files_and_commits} " ) " ||
195
195
{ _print_center " normal" " Error: Cannot fetch" " update details" " =" 1>&2 && exit 1; }
196
+ # just grep the commit/ strings from html, then remove extra info with sed
196
197
commits_get_files_and_commits=" $( printf " %s\n" " ${html_get_files_and_commits} " | grep -o " commit/.*\" " | sed -e ' s/commit\///g' -e ' s/\"//g' -e ' s/>.*//g' ) "
198
+ # only grep blob because we just want files
197
199
# shellcheck disable=SC2001
198
- files_get_files_and_commits=" $( printf " %s\n" " ${html_get_files_and_commits} " | grep -oE ' ( blob|tree) /' " ${type_value_get_files_and_commits} " ' .*\"' | sed -e ' s/\"//g' -e ' s/>.*//g' ) "
200
+ files_get_files_and_commits=" $( printf " %s\n" " ${html_get_files_and_commits} " | grep -oE ' blob/' " ${type_value_get_files_and_commits} " ' .*\"' | sed -e ' s/\"//g' -e ' s/>.*//g' ) "
199
201
200
202
total_files=" $(( $(printf "% s\n" "${files_get_files_and_commits} " | wc - l)) )"
201
203
total_commits=" $(( $(printf "% s\n" "${commits_get_files_and_commits} " | wc - l)) )"
202
- if [ " $(( total_files - 2 )) " -eq " ${total_commits} " ]; then
203
- files_get_files_and_commits=" $( printf " %s\n" " ${files_get_files_and_commits} " | sed 1,2d) "
204
- elif [ " ${total_files} " -gt " ${total_commits} " ]; then
205
- files_get_files_and_commits=" $( printf " %s\n" " ${files_get_files_and_commits} " | sed 1d) "
204
+
205
+ # exit right out in case wasn't able to grab commits or files
206
+ if [ " ${total_commits} " -eq " 0" ] || [ " ${total_files} " -eq " 0" ]; then
207
+ _print_center " normal" " Error: Cannot fetch" " update details" " =" 1>&2 && exit 1
208
+ fi
209
+
210
+ # this is gonna trigger in case of non-release commit sha
211
+ if [ " ${total_commits} " -gt " ${total_files} " ]; then
212
+ # delete alternate lines ( sed '{N;P;d}' ), because duplicate for every commit
213
+ commits_get_files_and_commits=" $( printf " %s\n" " ${commits_get_files_and_commits} " | sed -e ' {N;P;d}' ) "
206
214
fi
207
215
208
216
exec 4<< EOF
@@ -213,7 +221,7 @@ $(printf "%s\n" "${commits_get_files_and_commits}")
213
221
EOF
214
222
while read -r file < & 4 && read -r commit < & 5; do
215
223
printf " %s\n" " ${file## blob\/ ${type_value_get_files_and_commits} \/ } __.__${commit} "
216
- done | grep -v tree || :
224
+ done
217
225
exec 4< & - && exec 5< & -
218
226
219
227
return 0
0 commit comments