From 9b048d334611d3d084e86a1cb28a336d1435a5ad Mon Sep 17 00:00:00 2001 From: typebrook Date: Mon, 30 Dec 2019 10:36:56 +0800 Subject: update --- scripts/upload-github-release-asset.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/upload-github-release-asset.sh b/scripts/upload-github-release-asset.sh index 6923870..0325530 100755 --- a/scripts/upload-github-release-asset.sh +++ b/scripts/upload-github-release-asset.sh @@ -62,17 +62,17 @@ eval $(echo "$response" | grep -C2 "\"name\":.\+$(basename $filename)" | grep -m if [ "$asset_id" = "" ]; then echo "No need to overwrite asset" else - if [ "$overwrite" ]; then + if [[ "$overwrite" == "true" ]] || [[ "$overwrite" == "delete" ]]; then echo "Deleting asset($asset_id)... " curl -X "DELETE" -H "Authorization: token $github_api_token" "https://api.github.com/repos/$owner/$repo/releases/assets/$asset_id" + if [[ "$overwrite" == "delete" ]]; then + exit 0 + fi else echo "File already exists on tag $tag" echo "If you want to overwrite it, set overwrite=true" exit 1 fi - if [ "$overwrite" == "delete" ]; then - exit 0 - fi fi # Upload asset -- cgit v1.2.3-70-g09d2 From f791483cb24005b7d07f2ca9f2737490b3fdb2ab Mon Sep 17 00:00:00 2001 From: typebrook Date: Mon, 30 Dec 2019 15:12:29 +0800 Subject: update --- alias | 1 - scripts/gist | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/alias b/alias index c93f31d..5a9fb00 100644 --- a/alias +++ b/alias @@ -250,7 +250,6 @@ alias cdo='cd ~/git/openmaptiles' alias cdS='cd ~/git/StreetComplete' alias cdW='cd ~/git/geoBingAnWeb' alias and='cd ~/git/geoBingAn.Android' -alias cdG='cd ~/git/git' alias cdT='cd ~/git/taiwan-topo' alias cdand='cd ~/git/sample' alias cdm='cd ~/git/sharkbig.github.io' diff --git a/scripts/gist b/scripts/gist index 9dfa31d..834d6cf 100755 --- a/scripts/gist +++ b/scripts/gist @@ -49,6 +49,9 @@ auth_header="Authorization: token $github_api_token" mkdir -p $folder index=$folder/index +# Validate settings. +[ "$TRACE" ] && set -x && echo foo + # get the list of gists _update() { curl -s -H "$auth_header" $github_api/users/$user/gists |\ -- cgit v1.2.3-70-g09d2 From 07228d5f372d171618f28a64b446759e7eeadf4a Mon Sep 17 00:00:00 2001 From: typebrook Date: Mon, 30 Dec 2019 16:18:34 +0800 Subject: update --- scripts/gist | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'scripts') diff --git a/scripts/gist b/scripts/gist index 834d6cf..b55012b 100755 --- a/scripts/gist +++ b/scripts/gist @@ -110,15 +110,19 @@ _show_detail() { # create a new gist with a file and description # TODO support folder of files _create_gist() { - FILE=$(basename $1) - - jq --arg FILE "$FILE" --arg DESC "$2" '. as $content | { - public: true, - files: { - ($FILE): {content: $content} - }, + echo -n 'description: ' + read DESC + + echo $@ | tr " " "\n" |\ + while read file; do + FILE=$(basename $file) + jq --arg FILE "$FILE" '. as $content | { ($FILE): {content: $content} }' -Rs $file + done |\ + jq -s --arg DESC "$DESC" '{ + public: true, + files: add, description: ($DESC) - }' -R -s $1 |\ + }' |\ curl -s -H "$auth_header" --data @- $github_api/gists > /dev/null && \ _update } @@ -137,7 +141,8 @@ case "$1" in cat $index ;; create | c) - _create_gist "$2" "$3" + shift; + _create_gist $@ ;; edit | e) _edit_gist "$2" "$3" -- cgit v1.2.3-70-g09d2