Skip to content

Commit

Permalink
[#73] adding .precommit yaml (#79)
Browse files Browse the repository at this point in the history
This pr adds a `.pre-commit-config.yaml` to the repo so others can
install a
[pre-commit](https://pre-commit.com/).

The options added are in the suggested list of the pre-commit project.
  • Loading branch information
MitchellBerend authored Sep 10, 2022
1 parent be5c9bc commit 4341cc7
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @chshersh
* @chshersh
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ updates:
include: "scope"
labels:
- "CI"
- "dependencies"
- "dependencies"
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:

- name: Unit tests
run: cargo test --verbose

- if: matrix.os != 'windows-latest'
name: "Integration test: [unix] [only-ripgrep]"
env:
Expand Down Expand Up @@ -80,7 +80,7 @@ jobs:
if [[ ! -x $SYNC_DIR/fd ]]; then echo "error on: fd"; false; fi
if [[ ! -x $SYNC_DIR/rg ]]; then echo "error on: rg"; false; fi
if [[ ! -x $SYNC_DIR/tool ]]; then echo "error on: tool"; false; fi
# disabled because of: https://github.com/alexcrichton/tar-rs/issues/295
# if [[ ! -x $SYNC_DIR/tokei ]]; then echo "error on: tokei"; false; fi
Expand Down Expand Up @@ -138,4 +138,4 @@ jobs:
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features
args: --all-features
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ jobs:
zip: windows
env:
# (required)
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ tags
TAGS

# other
.DS_Store
.DS_Store
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer

- repo: https://github.com/doublify/pre-commit-rust
rev: v1.0
hooks:
- id: fmt
args: ['--all', '--', '--check']
- id: cargo-check
- id: clippy
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ indicatif = "0.17.0"
shellexpand = "2.1.2"
tar = "0.4.38"
tempdir = "0.3.7"
toml = "0.5.9"
toml = "0.5.9"
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ tool --config=path/to/my/config.toml sync
Run `tool --help` for more details.

> :octocat: If you hit the limit for downloading assets or want to download
> assets from private repositories,
> assets from private repositories,
> [create a personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token)
> and export it as the `GITHUB_TOKEN` environment variable.
Expand All @@ -189,13 +189,13 @@ This section contains `tool-sync` comparison to existing alternatives:

1. **Manual download**. You can download GitHub releases manually without using
any extra tools.

+ **Pros**
+ No extra tools required, only your browser and unpack utility
+ **Cons**
+ Tedious manual process

2. **GitHub CLI**. You can download assets from releases using
2. **GitHub CLI**. You can download assets from releases using
[the GitHub CLI tool `gh`][gh].

```shell
Expand Down Expand Up @@ -249,6 +249,10 @@ cargo build
cargo test
```

There is a predefined `.pre-commit-config.yaml` that you can install using
[pre-commit](https://pre-commit.com/). This will make sure the tests are run
locally before committing changes.

### Adding a new tool

`tool-sync` contains [a database of common tools][db] and provides easier
Expand Down
2 changes: 1 addition & 1 deletion example-tool-sync-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ store_directory = "~/.local/bin"
[difftastic]
[exa]
[fd]
[ripgrep]
[ripgrep]
4 changes: 2 additions & 2 deletions src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ pub fn sync(config: Config) {
Put the following into the $HOME/.tool.toml file for the simplest configuration:
# ensure this directory is listed in $PATH
store_directory = "/path/to/install/directory"
store_directory = "/path/to/install/directory"
[bat]
[exa]
[fd]
Expand Down
2 changes: 1 addition & 1 deletion src/sync/configure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl ToolInfo {
tag: config_asset
.tag
.clone()
.map(|version| ToolInfoTag::Specific(version))
.map(ToolInfoTag::Specific)
.unwrap_or(ToolInfoTag::Latest),
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/full-database.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ store_directory = "full-database"
[tool-sync]

# disabled because of: https://github.com/alexcrichton/tar-rs/issues/295
# [tokei]
# [tokei]
2 changes: 1 addition & 1 deletion tests/only-ripgrep.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
store_directory = "only-ripgrep"

[ripgrep]
[ripgrep]

0 comments on commit 4341cc7

Please sign in to comment.