Skip to content

Commit

Permalink
[bashful] gist install crash was corrupting the registry file (#11)
Browse files Browse the repository at this point in the history
Releases as v3.1.3

When `getGistVersion` returns an empty string, this corrupts the entire registry file. So half of the pkgman features don't work anymore.

This PR not only fixes why `getGistVersion` was breaking, it makes it so that it defaults to an empty string so that it does not corrupt the file.
  • Loading branch information
kyle-west authored Aug 6, 2020
1 parent c25dc4f commit cd9dc94
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ on: [push]
jobs:
build:

runs-on: macOS-latest
runs-on: macos-latest

strategy:
matrix:
node-version: [10.x]
node-version: [ '12' ]

steps:
- uses: actions/checkout@v1
Expand Down
7 changes: 4 additions & 3 deletions bin/bashful
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ source ~/.bashful.filesys/bashful.rc

# USAGE: getGistVersion https://gist.github.com/kyle-west/e3f91dc5817849ca4a316098911b7e7d
getGistVersion () {
curl -s `echo "$1" | sed -e 's#.git$##g'` | grep 'class="Counter"' | sed -e 's/[^0-9]*//g'
# parse out the content of: <span class="Counter " title="2">2</span>
curl -s `echo "$1" | sed -e 's#.git$##g'` | grep 'class="Counter' | cut -d">" -f2 | sed -e 's/[^0-9]*//g'
}

getLatestRelease () {
Expand All @@ -24,11 +25,11 @@ manifest.listInstalledGists () {
echo;
}
manifest.addGist () {
obj=`echo "{ \"name\": \"$1\", \"gistUrl\": \"$2\", \"revision\": $3 }"`
obj=`echo "{ \"name\": \"$1\", \"gistUrl\": \"$2\", \"revision\": \"$3\" }"`
data=$(json "$__bash_suite_filesys/installation-manifest.json" "
// remove old references, and then add the new
\$.fromGists = \$.fromGists.filter(x => x.name !== '$1');
\$.fromGists.push({ name: '$1', gistUrl: '$2', revision: $3 });
\$.fromGists.push({ name: '$1', gistUrl: '$2', revision: '$3' });
console.log(JSON.stringify(\$))
")
echo "$data" > "$__bash_suite_filesys/installation-manifest.json"
Expand Down
9 changes: 7 additions & 2 deletions docs/bashful.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,14 @@ executable files.
bashful gist install <url-to-github-gist | program name in registry>
```

That will install your gist program as an executable. To see what packages are known by the registry, run `bashful gist info`.
That will install your gist program as an executable.

To combine another registry with the main bashful registry, run the following command:

## Gist Registries

To see what packages are known by the registry, run `bashful gist info`.

To combine add an additional registry to you local copy of `bashful`, run the following command:

```sh
bashful gist add <url to gist hosting additional registry>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bashful",
"version": "3.1.2",
"version": "3.1.3",
"description": "Install my custom suite of terminal tools for Bash in OSX",
"main": "install.sh",
"scripts": {
Expand Down
10 changes: 5 additions & 5 deletions test/snapshots/bashful_test.sh.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ Bashful Tools Installed from Gists:
┌─────────┬────────────┬──────────────────────────────────────────────────────────────────────────┬──────────┐
│ (index) │ name │ gistUrl │ revision │
├─────────┼────────────┼──────────────────────────────────────────────────────────────────────────┼──────────┤
│ 0 │ 'killport' │ 'https://gist.github.com/kyle-west/5735c708e395b7c65d439325df88ea32.git' │ 2
│ 1 │ 'prune' │ 'https://gist.github.com/kyle-west/6ffc7ec0d1c377c99f44c5388356391f.git' │ 1
│ 0 │ 'killport' │ 'https://gist.github.com/kyle-west/5735c708e395b7c65d439325df88ea32.git' │ '2'
│ 1 │ 'prune' │ 'https://gist.github.com/kyle-west/6ffc7ec0d1c377c99f44c5388356391f.git' │ '2'
└─────────┴────────────┴──────────────────────────────────────────────────────────────────────────┴──────────┘

----------------------------------------------------------------
Expand Down Expand Up @@ -155,9 +155,9 @@ Bashful Tools Installed from Gists:
┌─────────┬────────────┬──────────────────────────────────────────────────────────────────────────┬──────────┐
│ (index) │ name │ gistUrl │ revision │
├─────────┼────────────┼──────────────────────────────────────────────────────────────────────────┼──────────┤
│ 0 │ 'killport' │ 'https://gist.github.com/kyle-west/5735c708e395b7c65d439325df88ea32.git' │ 2
│ 1 │ 'prune' │ 'https://gist.github.com/kyle-west/6ffc7ec0d1c377c99f44c5388356391f.git' │ 1
│ 2 │ 'bacon' │ 'https://gist.github.com/kyle-west/e3f91dc5817849ca4a316098911b7e7d.git' │ 2
│ 0 │ 'killport' │ 'https://gist.github.com/kyle-west/5735c708e395b7c65d439325df88ea32.git' │ '2'
│ 1 │ 'prune' │ 'https://gist.github.com/kyle-west/6ffc7ec0d1c377c99f44c5388356391f.git' │ '2'
│ 2 │ 'bacon' │ 'https://gist.github.com/kyle-west/e3f91dc5817849ca4a316098911b7e7d.git' │ '2'
└─────────┴────────────┴──────────────────────────────────────────────────────────────────────────┴──────────┘

----------------------------------------------------------------
Expand Down
6 changes: 4 additions & 2 deletions test/snapshots/json_test.sh.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ ________________________________________________________________________________
________________________________________________________________________________________________
RUNNING > 'json package.json $'
................................................................
{ name: 'test',
{
name: 'test',
version: '1.2.3',
description: 'See if the json program works well',
list: [ 'item1', 'item2', 'item3', 'item4' ] }
list: [ 'item1', 'item2', 'item3', 'item4' ]
}
................................................................
________________________________________________________________________________________________
________________________________________________________________________________________________
Expand Down

0 comments on commit cd9dc94

Please sign in to comment.