-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 777050e
Showing
34 changed files
with
1,987 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM alpine:latest | ||
RUN apk add git cargo go npm \ | ||
&& go install github.com/evilmartians/lefthook@latest \ | ||
&& npm install -g prettier | ||
ENV PATH=${PATH}:/root/go/bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "fixit", | ||
"build": { "dockerfile": "Dockerfile" }, | ||
"postAttachCommand": "lefthook install", | ||
"customizations": { | ||
"vscode": { | ||
"extensions": ["rust-lang.rust-analyzer", "esbenp.prettier-vscode"] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
on: | ||
push: | ||
|
||
name: Tests | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install Rust toolchain | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: stable | ||
components: rustfmt, clippy | ||
override: true | ||
|
||
- name: Install Prettier | ||
run: npm install -g prettier | ||
|
||
- name: Run cargo fmt | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: fmt | ||
args: --check | ||
|
||
- name: Run Prettier | ||
run: prettier --check "**/*.{md,json,prettierrc}" | ||
|
||
- name: Run cargo clippy | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: clippy | ||
args: -- -D warnings | ||
|
||
- name: Run tests | ||
uses: actions-rs/cargo@v1 | ||
env: | ||
RUST_BACKTRACE: 1 | ||
with: | ||
command: test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"tabWidth": 2, | ||
"printWidth": 80, | ||
"proseWrap": "always" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Contributing guidelines | ||
|
||
## Setting up development environment | ||
|
||
The quickest way to start contributing is to use GitHub Codespaces (see | ||
README.md). | ||
|
||
You can just use a devcontainer included with this project. | ||
|
||
If you do not want to use the devcontainer, you will need the following | ||
dependencies: | ||
|
||
- The Rust toolchain. | ||
- Prettier for markdown formatting. | ||
- lefthook for git pre-commit hooks (optional but advised). | ||
|
||
## Markdown formatting | ||
|
||
All markdown files should be formatted with: | ||
|
||
prettier --prose-wrap always | ||
|
||
## Adding new rules | ||
|
||
A rule is a function that attempts to fix a command. To add a rule named | ||
`rule_name` you need to add a file named `src/rules/rule_name.rs`. This file | ||
should contain a `pub` function named `rule_name` with the following signature: | ||
|
||
```rust | ||
/// # Arguments | ||
/// | ||
/// - `cmd` - tokenized command, e.g. (["git", "commit", "-m", "initial commit"]) | ||
/// - `error` - the output of the command. | ||
fn rule_name(cmd: &[String], error: &str) -> T | ||
``` | ||
|
||
Where `T` is any type implementing `IntoIterator<Item = Vec<String>>`. Normally, | ||
this would be `Option<Vec<String>>` or `Vec<Vec<String>>`. `Vec<String>` | ||
contains a command, e.g. `["git", "commit", "--amend"]`. | ||
|
||
Then the name should be added to `src/rules/mod.rs` as an argument to the | ||
`define_rules` macro. | ||
|
||
## Adding shell support | ||
|
||
Shells support should be added to `src/cmd/init.rs`. The code here is pretty | ||
self-explanatory. | ||
|
||
A couple notes on variables that go into generating the fix function: | ||
|
||
- `executable` - the name of `fixit` executable. | ||
- `name` - the name of the generated function. | ||
|
||
All shell support functions should generally follow this pseudocode: | ||
|
||
``` | ||
function {name} | ||
last_command = get_last_command() | ||
fixed_command = {executable} fix $last_command | ||
if $fixed_command != "" | ||
run($fixed_command) | ||
add_to_history($fixed_command) | ||
end | ||
end | ||
``` | ||
|
||
## Adding support for terminal emulators/multiplexers | ||
|
||
See `src/get_text`. There is no specific guideline for this. |
Oops, something went wrong.