From 4970d62dc2ed7f6cc55da6e8547e9b6ba98de85e Mon Sep 17 00:00:00 2001 From: nassersaazi Date: Thu, 27 Jul 2023 21:31:32 +0300 Subject: [PATCH 1/6] Add contribution guide --- CONTRIBUTING.md | 200 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 200 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..61c1f7c --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,200 @@ +# Contributing + +## Where to start + +All contributions, bug reports, bug fixes, documentation improvements, enhancements, and ideas are welcome. + +The best place to start is to check the [issues](https://github.com/rust-practice/cargo-leet) +for something that interests you. + +## Bug Reports + +* Explain what is currently happening and what you expect instead. + +## Working on the code + +### Fork the project + +In order to work on the project you will need your own fork. To do this click the "Fork" button on +this project. + +Once the project is forked clone it to your local machine: + +```sh +git clone git@github.com:your-user-name/cargo-leet +cd cargo-leet +git remote add upstream git@github.com:rust-practice/cargo-leet.git +``` + +This creates the directory cargo-leet and connects your repository to the upstream (main project) repository. + +### Creating a branch + +You want your main branch to reflect only production-ready code, so create a feature branch for +making your changes. For example: + +```sh +git checkout -b my-new-feature +``` + +This changes your working directory to the my-new-feature branch. Keep any changes in this branch +specific to one bug or feature so the purpose is clear. You can have many my-new-features and switch +in between them using the git checkout command. + +When creating this branch, make sure your main branch is up to date with the latest upstream +main version. To update your local main branch, you can do: + +```sh +git checkout main +git pull upstream main --ff-only +``` + +### Code linting, formatting, and tests + +You can run linting on your code at any time with: + +```sh +cargo clippy +``` + +To format the code run: + +```sh +cargo fmt +``` + +To run the tests: + +```sh +cargo test +``` + +To ensure the code compiles run: + +```sh +cargo check +``` + +Be sure to run all these checks before submitting your pull request. + +## Committing your code + +Once you have made changes to the code on your branch you can see which files have changed by running: + +```sh +git status +``` + +If new files were created that and are not tracked by git they can be added by running: + +```sh +git add . +``` + +Now you can commit your changes in your local repository: + +```sh +git commit -am 'Some short helpful message to describe your changes' +``` + +## Push your changes + +Once your changes are ready and all linting/tests are passing you can push your changes to your forked repositry: + +```sh +git push origin my-new-feature +``` + +origin is the default name of your remote repositry on GitHub. You can see all of your remote repositories by running: + +```sh +git remote -v +``` + +## Making a Pull Request + +After pushing your code to origin it is now on GitHub but not yet part of the cargo-leet project. +When you’re ready to ask for a code review, file a pull request. Before you do, once again make sure +that you have followed all the guidelines outlined in this document regarding code style, tests, and +documentation. You should also double check your branch changes against the branch it was based on by: + +1. Navigating to your repository on GitHub +1. Click on Branches +1. Click on the Compare button for your feature branch +1. Select the base and compare branches, if necessary. This will be main and my-new-feature, respectively. + +### Make the pull request + +If everything looks good, you are ready to make a pull request. This is how you let the maintainers +of the cargo-leet project know you have code ready to be reviewed. To submit the pull request: + +1. Navigate to your repository on GitHub +1. Click on the Pull Request button for your feature branch +1. You can then click on Commits and Files Changed to make sure everything looks okay one last time +1. Write a description of your changes in the Conversation tab +1. Click Send Pull Request + +This request then goes to the repository maintainers, and they will review the code. + +### Updating your pull request + +Changes to your code may be needed based on the review of your pull request. If this is the case you +can make them in your branch, add a new commit to that branch, push it to GitHub, and the pull +request will be automatically updated. Pushing them to GitHub again is done by: + +```sh +git push origin my-new-feature +``` + +This will automatically update your pull request with the latest code and restart the Continuous +Integration tests. + +Another reason you might need to update your pull request is to solve conflicts with changes that +have been merged into the main branch since you opened your pull request. + +To do this, you need to rebase your branch: + +```sh +git checkout my-new-feature +git fetch upstream +git rebase upstream/main +``` + +There may be some merge conficts that need to be resolved. After the feature branch has been update +locally, you can now update your pull request by pushing to the branch on GitHub: + +```sh +git push origin my-new-feature +``` + +If you rebased and get an error when pushing your changes you can resolve it with: + +```sh +git push origin my-new-feature --force +``` + +## Delete your merged branch (optional) + +Once your feature branch is accepted into upstream, you’ll probably want to get rid of the branch. +First, merge upstream main into your main branch so git knows it is safe to delete your branch: + +```sh +git fetch upstream +git checkout main +git merge upstream/main +``` + +Then you can do: + +```sh +git branch -d my-new-feature +``` + +Make sure you use a lower-case -d, or else git won’t warn you if your feature branch has not actually been merged. + +The branch will still exist on GitHub, so to delete it there do: + +```sh +git push origin --delete my-new-feature +``` + From 885d92a5c2d17ff9e50db6a574ad8637c80f601f Mon Sep 17 00:00:00 2001 From: One <43485962+c-git@users.noreply.github.com> Date: Thu, 11 Jan 2024 10:16:22 -0500 Subject: [PATCH 2/6] Make updates to contribution guide in preparation for publishing --- CONTRIBUTING.md | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 61c1f7c..eeb733f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,10 +6,11 @@ All contributions, bug reports, bug fixes, documentation improvements, enhanceme The best place to start is to check the [issues](https://github.com/rust-practice/cargo-leet) for something that interests you. +There are also other thing in [discussion](https://github.com/rust-practice/cargo-leet/discussions) feel free to pick from there as well. ## Bug Reports -* Explain what is currently happening and what you expect instead. +Please see the [issue templates](https://github.com/rust-practice/cargo-leet/issues/new/choose) that describe the types of information that we are looking for but no worries just fill it the best you can and we'll go from there. ## Working on the code @@ -18,16 +19,18 @@ for something that interests you. In order to work on the project you will need your own fork. To do this click the "Fork" button on this project. -Once the project is forked clone it to your local machine: +Once the project is forked you can work on it directly in github codespaces without needing to install anything by clicking the green button near the top and switching to code spaces. +According to [github docs](https://docs.github.com/en/codespaces/overview#billing-for-codespaces) by default you can only use it up to the free amount so you don't need to worry about charges. +Feel free to check some [notes collected](https://c-git.github.io/github/codespaces/) on how to use codespaces with rust (You don't need trunk for this project). + +Alternatively you can clone it to your local machine. The following commands creates the directory cargo-leet and connects your repository to the upstream (main project) repository. ```sh -git clone git@github.com:your-user-name/cargo-leet +git clone https://github.com/your-user-name/cargo-leet.git cd cargo-leet git remote add upstream git@github.com:rust-practice/cargo-leet.git ``` -This creates the directory cargo-leet and connects your repository to the upstream (main project) repository. - ### Creating a branch You want your main branch to reflect only production-ready code, so create a feature branch for @@ -65,8 +68,10 @@ cargo fmt To run the tests: +Note the follow is overridden in `.cargo/config.toml` to run with all features enabled + ```sh -cargo test +cargo t ``` To ensure the code compiles run: @@ -75,7 +80,7 @@ To ensure the code compiles run: cargo check ``` -Be sure to run all these checks before submitting your pull request. +Please run the tests before submitting your pull request. ## Committing your code @@ -99,13 +104,13 @@ git commit -am 'Some short helpful message to describe your changes' ## Push your changes -Once your changes are ready and all linting/tests are passing you can push your changes to your forked repositry: +Once your changes are ready and all linting/tests are passing you can push your changes to your forked repository: ```sh git push origin my-new-feature ``` -origin is the default name of your remote repositry on GitHub. You can see all of your remote repositories by running: +origin is the default name of your remote repository on GitHub. You can see all of your remote repositories by running: ```sh git remote -v @@ -138,19 +143,17 @@ This request then goes to the repository maintainers, and they will review the c ### Updating your pull request -Changes to your code may be needed based on the review of your pull request. If this is the case you -can make them in your branch, add a new commit to that branch, push it to GitHub, and the pull -request will be automatically updated. Pushing them to GitHub again is done by: +Changes to your code may be needed based on the review of your pull request. +If this is the case you can make them in your branch, add a new commit to that branch, push it to GitHub, and the pull request will be automatically updated. +Pushing them to GitHub again is done by: ```sh git push origin my-new-feature ``` -This will automatically update your pull request with the latest code and restart the Continuous -Integration tests. +This will automatically update your pull request with the latest code and restart the Continuous Integration tests. -Another reason you might need to update your pull request is to solve conflicts with changes that -have been merged into the main branch since you opened your pull request. +Another reason you might need to update your pull request is to solve conflicts with changes that have been merged into the main branch since you opened your pull request. To do this, you need to rebase your branch: @@ -160,8 +163,8 @@ git fetch upstream git rebase upstream/main ``` -There may be some merge conficts that need to be resolved. After the feature branch has been update -locally, you can now update your pull request by pushing to the branch on GitHub: +There may be some merge conflicts that need to be resolved. +After the feature branch has been update locally, you can now update your pull request by pushing to the branch on GitHub: ```sh git push origin my-new-feature @@ -197,4 +200,3 @@ The branch will still exist on GitHub, so to delete it there do: ```sh git push origin --delete my-new-feature ``` - From e22474fb5f1eff9c9b040152d1a93ab23fe3ce76 Mon Sep 17 00:00:00 2001 From: One <43485962+c-git@users.noreply.github.com> Date: Thu, 11 Jan 2024 10:20:49 -0500 Subject: [PATCH 3/6] Ask contributors to use develop instead of main --- CONTRIBUTING.md | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index eeb733f..35a85a4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -33,8 +33,10 @@ git remote add upstream git@github.com:rust-practice/cargo-leet.git ### Creating a branch -You want your main branch to reflect only production-ready code, so create a feature branch for -making your changes. For example: +You want your main branch to reflect only production-ready code. +Please base your branch on the develop branch which is the default in cargo-leet repo so create a feature branch for +making your changes. +For example: ```sh git checkout -b my-new-feature @@ -44,12 +46,12 @@ This changes your working directory to the my-new-feature branch. Keep any chang specific to one bug or feature so the purpose is clear. You can have many my-new-features and switch in between them using the git checkout command. -When creating this branch, make sure your main branch is up to date with the latest upstream -main version. To update your local main branch, you can do: +When creating this branch, make sure your develop branch is up to date with the latest upstream +develop version. To update your local develop branch, you can do: ```sh -git checkout main -git pull upstream main --ff-only +git checkout develop +git pull upstream develop --ff-only ``` ### Code linting, formatting, and tests @@ -126,7 +128,7 @@ documentation. You should also double check your branch changes against the bran 1. Navigating to your repository on GitHub 1. Click on Branches 1. Click on the Compare button for your feature branch -1. Select the base and compare branches, if necessary. This will be main and my-new-feature, respectively. +1. Select the base and compare branches, if necessary. This will be develop and my-new-feature, respectively. ### Make the pull request @@ -153,14 +155,14 @@ git push origin my-new-feature This will automatically update your pull request with the latest code and restart the Continuous Integration tests. -Another reason you might need to update your pull request is to solve conflicts with changes that have been merged into the main branch since you opened your pull request. +Another reason you might need to update your pull request is to solve conflicts with changes that have been merged into the develop branch since you opened your pull request. To do this, you need to rebase your branch: ```sh git checkout my-new-feature git fetch upstream -git rebase upstream/main +git rebase upstream/develop ``` There may be some merge conflicts that need to be resolved. @@ -179,12 +181,12 @@ git push origin my-new-feature --force ## Delete your merged branch (optional) Once your feature branch is accepted into upstream, you’ll probably want to get rid of the branch. -First, merge upstream main into your main branch so git knows it is safe to delete your branch: +First, merge upstream develop into your develop branch so git knows it is safe to delete your branch: ```sh git fetch upstream -git checkout main -git merge upstream/main +git checkout develop +git merge upstream/develop ``` Then you can do: From b796e7952e751c516ae3c2c1ddd1a22c6ff200f6 Mon Sep 17 00:00:00 2001 From: One <43485962+c-git@users.noreply.github.com> Date: Thu, 11 Jan 2024 10:21:59 -0500 Subject: [PATCH 4/6] Remove cargo check as it's just duplicated work --- CONTRIBUTING.md | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 35a85a4..bc59284 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -70,19 +70,13 @@ cargo fmt To run the tests: -Note the follow is overridden in `.cargo/config.toml` to run with all features enabled +Note the following is overridden in `.cargo/config.toml` to run with all features enabled ```sh cargo t ``` -To ensure the code compiles run: - -```sh -cargo check -``` - -Please run the tests before submitting your pull request. +Please run these checks before submitting your pull request. ## Committing your code From 707c623f39bb5eb74b8d7bf1f1d52e7dfac4fc33 Mon Sep 17 00:00:00 2001 From: One <43485962+c-git@users.noreply.github.com> Date: Thu, 11 Jan 2024 10:33:31 -0500 Subject: [PATCH 5/6] use dprint to format files --- .github/ISSUE_TEMPLATE/bug_report.md | 12 +++++++++++- .github/ISSUE_TEMPLATE/missing_type.md | 5 ++++- .vscode/settings.json | 16 +++++++-------- README.md | 27 +++++++++++++------------- 4 files changed, 36 insertions(+), 24 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index eb0238e..4ca595c 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -8,26 +8,36 @@ assignees: '' --- **Describe the bug** + **Leetcode problem** + **To Reproduce** + + `` **Error Message** + + ``` ``` **Expected behavior** + **Environment Info:** + - - Cargo Version: + +- Cargo Version: **Additional context** + diff --git a/.github/ISSUE_TEMPLATE/missing_type.md b/.github/ISSUE_TEMPLATE/missing_type.md index 04ba8e9..a82784c 100644 --- a/.github/ISSUE_TEMPLATE/missing_type.md +++ b/.github/ISSUE_TEMPLATE/missing_type.md @@ -8,9 +8,12 @@ assignees: '' --- **Leetcode problem** + **Error Message** + + +``` ``` -``` \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 4ecd8e5..2e460b9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,9 +1,9 @@ { - "cSpell.words": [ - "Vecbool", - "Veci" - ], - "editor.formatOnSave": true, - "files.autoSave": "onFocusChange", - "rust-analyzer.cargo.features": "all", // Sets the features used by rust analyzer -} \ No newline at end of file + "cSpell.words": [ + "Vecbool", + "Veci" + ], + "editor.formatOnSave": true, + "files.autoSave": "onFocusChange", + "rust-analyzer.cargo.features": "all" // Sets the features used by rust analyzer +} diff --git a/README.md b/README.md index 5ef2350..8903ecc 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,25 @@ ## cargo-leet - A leetcode local development assistant - A program that given the link or slug to a leetcode problem, - creates a local file where you can develop and test your solution before post it back to leetcode. +A program that given the link or slug to a leetcode problem, +creates a local file where you can develop and test your solution before post it back to leetcode. - ## ScreenShots +## ScreenShots - ### `cargo leet` - ![ScreenShot](assets/help_scr_shot_top.png) +### `cargo leet` - ### `cargo leet generate --help` - ![ScreenShot](assets/help_scr_shot_generate.png) +![ScreenShot](assets/help_scr_shot_top.png) - ## Using Library Support +### `cargo leet generate --help` - Using the library to "mimic" leetcode environment. Add library as a dependency as below. Then add use statements as necessary (automatically added if tool is used to generate the file). +![ScreenShot](assets/help_scr_shot_generate.png) - ```toml - cargo-leet = { git = "https://github.com/rust-practice/cargo-leet.git", branch = "develop" } - ``` +## Using Library Support +Using the library to "mimic" leetcode environment. Add library as a dependency as below. Then add use statements as necessary (automatically added if tool is used to generate the file). + +```toml +cargo-leet = { git = "https://github.com/rust-practice/cargo-leet.git", branch = "develop" } +``` ## Tool Installation @@ -64,8 +65,6 @@ or using alias from `.cargo/config.toml` cargo g ``` - - ## Tool Uninstallation ```sh From 8f4853a0730c279bc33fe4ecd2f263c49825560d Mon Sep 17 00:00:00 2001 From: One <43485962+c-git@users.noreply.github.com> Date: Sat, 13 Jan 2024 15:18:43 -0500 Subject: [PATCH 6/6] Clarify statement in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8903ecc..d6980e4 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ creates a local file where you can develop and test your solution before post it ## Using Library Support -Using the library to "mimic" leetcode environment. Add library as a dependency as below. Then add use statements as necessary (automatically added if tool is used to generate the file). +Using the library to "mimic" leetcode environment. Add library as a dependency as below. Then add use statements as necessary. The use statements are automatically added if tool is used to generate the file for the problem. ```toml cargo-leet = { git = "https://github.com/rust-practice/cargo-leet.git", branch = "develop" }