diff options
Diffstat (limited to 'scripts/gist')
-rwxr-xr-x | scripts/gist | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/scripts/gist b/scripts/gist index 1e65892..895d5c0 100755 --- a/scripts/gist +++ b/scripts/gist | |||
@@ -165,10 +165,10 @@ _sync_repos() { | |||
165 | | while read url blob_code_remote; do | 165 | | while read url blob_code_remote; do |
166 | local repo=$folder/$(echo $url | sed 's#.*/##') | 166 | local repo=$folder/$(echo $url | sed 's#.*/##') |
167 | local blob_code_local=$(cd $repo && git ls-tree master | cut -d' ' -f3 | cut -c-7 | sort | paste -sd '-') | 167 | local blob_code_local=$(cd $repo && git ls-tree master | cut -d' ' -f3 | cut -c-7 | sort | paste -sd '-') |
168 | cd $repo && \ | 168 | cd $repo \ |
169 | [[ $blob_code_local != $blob_code_remote ]] && \ | 169 | && [[ $blob_code_local != $blob_code_remote ]] \ |
170 | [[ $(git rev-parse origin/master) == $(git rev-parse master) ]] && \ | 170 | &&[[ $(git rev-parse origin/master) == $(git rev-parse master) ]] \ |
171 | git pull | 171 | && git pull |
172 | done | 172 | done |
173 | echo Everything is fine! | 173 | echo Everything is fine! |
174 | } | 174 | } |
@@ -189,8 +189,8 @@ _goto_gist() { | |||
189 | 189 | ||
190 | if [[ ! -d $folder/$GIST_ID ]]; then | 190 | if [[ ! -d $folder/$GIST_ID ]]; then |
191 | echo 'Cloning gist as repo...' | 191 | echo 'Cloning gist as repo...' |
192 | git clone git@github.com:$GIST_ID.git $folder/$GIST_ID && \ | 192 | git clone git@github.com:$GIST_ID.git $folder/$GIST_ID \ |
193 | echo 'Repo is cloned' || \ | 193 | && echo 'Repo is cloned' || \ |
194 | echo 'Failed to clone the gist' | 194 | echo 'Failed to clone the gist' |
195 | fi | 195 | fi |
196 | 196 | ||
@@ -203,8 +203,8 @@ _goto_gist() { | |||
203 | _delete_gist() { | 203 | _delete_gist() { |
204 | for i in "$@"; do | 204 | for i in "$@"; do |
205 | _gist_id "$i" | 205 | _gist_id "$i" |
206 | curl -X DELETE -s -H "$auth_header" $github_api/gists/$GIST_ID && \ | 206 | curl -X DELETE -s -H "$auth_header" $github_api/gists/$GIST_ID \ |
207 | echo "$i" deleted | 207 | && echo "$i" deleted |
208 | done | 208 | done |
209 | _update | 209 | _update |
210 | } | 210 | } |
@@ -254,7 +254,6 @@ _new_file() { | |||
254 | } | 254 | } |
255 | 255 | ||
256 | # create a new gist with files | 256 | # create a new gist with files |
257 | # FIXME error handling if gist is not created, file doesn't exist | ||
258 | # TODO support secret gist | 257 | # TODO support secret gist |
259 | _create_gist() { | 258 | _create_gist() { |
260 | _set_gist "$@" | 259 | _set_gist "$@" |
@@ -287,8 +286,8 @@ _edit_gist() { | |||
287 | echo -n 'Type new description: ' | 286 | echo -n 'Type new description: ' |
288 | read DESC < /dev/tty | 287 | read DESC < /dev/tty |
289 | jq -n --arg DESC "$DESC" '{ description: ($DESC) }' \ | 288 | jq -n --arg DESC "$DESC" '{ description: ($DESC) }' \ |
290 | | curl -X PATCH -H "$auth_header" --data @- $github_api/gists/$GIST_ID > /dev/null && \ | 289 | | curl -X PATCH -H "$auth_header" --data @- $github_api/gists/$GIST_ID > /dev/null \ |
291 | _update | 290 | && _update |
292 | } | 291 | } |
293 | 292 | ||
294 | _help_message() { | 293 | _help_message() { |