Skip to content

Commit

Permalink
selfupdate is broken #174 : switch to commits strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
xonixx committed Dec 13, 2024
1 parent 54b167b commit b53285a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion makesure
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ function selfUpdate(tmp,err,newVer,line,sha){
err=dl("https://github.com/xonixx/makesure/commits/main",tmp)
if(!err){
while(getline line<tmp){
if(match(line,/\/xonixx\/makesure\/commits\/[0-9a-z]+/)){
if(match(line,/\/xonixx\/makesure\/commit\/[0-9a-z]+/)){
sha=substr(line=substr(line,RSTART,RLENGTH),25)
break}}
if(!sha)err="unable to get the latest commit"
Expand Down
2 changes: 1 addition & 1 deletion makesure.awk
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ function selfUpdate( tmp, err, newVer,line,sha) {
err = dl("https://github.com/xonixx/makesure/commits/main", tmp)
if (!err) {
while (getline line < tmp) {
if (match(line, /\/xonixx\/makesure\/commits\/[0-9a-z]+/)) {
if (match(line, /\/xonixx\/makesure\/commit\/[0-9a-z]+/)) {
sha = substr(line = substr(line, RSTART, RLENGTH), 25)
break
}
Expand Down
2 changes: 1 addition & 1 deletion makesure_candidate
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ function selfUpdate(tmp,err,newVer,line,sha){
err=dl("https://github.com/xonixx/makesure/commits/main",tmp)
if(!err){
while(getline line<tmp){
if(match(line,/\/xonixx\/makesure\/commits\/[0-9a-z]+/)){
if(match(line,/\/xonixx\/makesure\/commit\/[0-9a-z]+/)){
sha=substr(line=substr(line,RSTART,RLENGTH),25)
break}}
if(!sha)err="unable to get the latest commit"
Expand Down
3 changes: 3 additions & 0 deletions tests/200_update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
export PATH="$D"
export NEXT_VERSION=XXX
"$D/$MAKESURE" --version
echo 'selfupdate 1'
"$D/$MAKESURE" --selfupdate
echo 'selfupdate 2'
"$D/$MAKESURE" --selfupdate
"$D/$MAKESURE" --version
rm -r "$D"
Expand Down Expand Up @@ -74,6 +76,7 @@ exec awk -v CURL="'$(command -v curl)$'" -v a1="$1" -v a2="$2" -v a3="$3" \'
BEGIN {
sub(/-q/,"-s",a1)
sub(/-O/,"-o",a3)
#print(CURL " " a1 " " a2 " " a3)
system(CURL " " a1 " " a2 " " a3)
}\'
' > "$D/$cmd"
Expand Down
5 changes: 5 additions & 0 deletions tests/200_update.tush
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ $ ./$MAKESURE -f tests/200_update.sh test_err
| goal 'makesure_prepared' ...
| goal 'test_err' ...
| XXX
| selfupdate 1
| goal 'test_err' failed
@ wget/curl not found
@ Please use manual update: https://makesure.dev/Installation.html
Expand All @@ -13,9 +14,11 @@ $ ./$MAKESURE -f tests/200_update.sh test_wget | awk '{ sub(/[0-9][0-9.]+/,"YYY"
| goal 'wget_prepared' ...
| goal 'test_wget' ...
| XXX
| selfupdate 1
| running wget
| running wget
| updated XXX -> YYY
| selfupdate 2
| running wget
| running wget
| you have latest version YYY installed
Expand All @@ -26,9 +29,11 @@ $ ./$MAKESURE -f tests/200_update.sh test_curl | awk '{ sub(/[0-9][0-9.]+/,"YYY"
| goal 'curl_prepared' ...
| goal 'test_curl' ...
| XXX
| selfupdate 1
| running curl
| running curl
| updated XXX -> YYY
| selfupdate 2
| running curl
| running curl
| you have latest version YYY installed
Expand Down

0 comments on commit b53285a

Please sign in to comment.