Skip to content

Commit

Permalink
Updates script and README
Browse files Browse the repository at this point in the history
  • Loading branch information
choval committed Nov 24, 2024
1 parent dc49688 commit 6dbe9c1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/formatter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
run: |
git fetch origin main --depth=1
- name: Formatter
uses: choval/formatter
uses: ghcr.io/choval/formatter
with:
target: .
- name: Check for modified files
Expand Down
23 changes: 20 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,40 @@ docker

## Installation


To run as a CLI

```sh
curl -o ~/formatter https://raw.githubusercontent.com/choval/formatter/master/formatter
chmod +x ~/formatter
curl -o ~/formatter_tmp https://raw.githubusercontent.com/choval/formatter/master/formatter
chmod +x ~/formatter_tmp
# Move to a bin path like ~/bin or ~/local/bin or ~/.local/bin
mv ~/formatter ~/.local/bin/formatter
mv ~/formatter_tmp ~/.local/bin/formatter
```

To set as a git pre-commit hook

```sh
curl -o ~/formatter_tmp https://raw.githubusercontent.com/choval/formatter/master/formatter
chmod +x ~/formatter_tmp
# Warning: this will overwrite your existing pre-commit if its set
mv ~/formatter_tmp .git/hooks/pre-commit
```


### Update

```sh
docker pull ghcr.io/choval/formatter
```


### Uninstall

```sh
# Remove the script
rm `which formatter`
# Remove the hook
rm .git/hooks/pre-commit
docker rmi ghcr.io/choval/formatter
```

Expand Down
9 changes: 7 additions & 2 deletions formatter
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/bin/sh
export DOCKER_CLI_HINTS=false
OLDCONTEXT=`docker context show`
docker context use default > /dev/null 2>&1
if [[ "$OLDCONTEXT" != "default" ]]; then
docker context use default > /dev/null 2>&1
fi
docker run --rm -v `pwd`:/src ghcr.io/choval/formatter /src
docker context use $OLDCONTEXT > /dev/null 2>&1
if [[ "$OLDCONTEXT" != "default" ]]; then
docker context use $OLDCONTEXT > /dev/null 2>&1
fi

0 comments on commit 6dbe9c1

Please sign in to comment.