Simplifying Git Project Organization and Code Quality
Anto simplifies code reviews, project integration, documentation, and code quality by automating checks for commit messages, project structure, and file content with VSK/MSK files and Git hooks. It also keeps documentation accurate and up-to-date, making it a valuable tool for projects of any scale, from open source to corporate software.
Commit message validation works by defining rules (regex and max lines) in the .anto/commit.msk
file:
/*
Commits should follow the Conventional Commits structure:
[optional scope]: <description>
Allowed types:
- feat: A new feature
- fix: A bug fix
Commit messages should not contain the word 'commit' and must be a maximum of 300 characters.
*/
l 300 <
+ feat:*
+ fix:*
- commit*
For more details about .msk
files, see the VSK/MSK section.
The project structure validation is defined through rules for files and folders in the .anto/structure.vsk
file:
[app]
[src]
[main]
[java]
[anto]
[feature]
# Matches files that end with 'utils.6', must be 1 to 5 files
{*utils.6} 1..5
# Matches 'ui' directory
[ui]
# Matches 'utils' directory
[utils]
[test]
# Must have maximum 5 features
[feature-*] < 5
{*utils.6}
[build]
# Matches all files and folders recursively (useful for ignoring entire directories)
[**]
[commit]
# Matches files like 'commit.log', 'commit.txt', etc.
{commit.*}
You can generate the validation.vsk
file for your project with this command:
.anto create-validation
File content validation is based on rules defined for specific files within your project. Create directories and files (with the .msk
extension) that mirror your project structure inside the .anto
folder.
To automate this, use the following command to create your project folder and file structure:
.anto create-structure
Example of an .msk
file for MainActivity.kt
:
/*
The MainActivity.kt file should only contain navigation code and must not include any @Composable annotations.
The file should be a maximum of 300 lines to prevent overly large classes.
*/
# must have 300 lines max
l 300 <
# the class name must contain Activity
+ *Activity
# the activity shouldnot contain any composable
- @Composable*
Before getting started, ensure you have:
- Git installed.
- Removed temporary folders and files (e.g., node_modules, build).
- Remove .anto folder if exists.
- Make sure to commit all your changes :-).
In the root of your .git project run the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/MJAZ93/anto/main/build/remote-mac.sh)"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/MJAZ93/anto/main/build/remote-linux.sh)"
For windows you might need to run as administrator, if you can't run as administrator, run the command bellow and continue in the Step-By-Step installation (from the step 5. Initialize Anto with:):
powershell -Command "& { (New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/MJAZ93/anto/main/build/remote-windows.ps1') | Invoke-Expression }"
If you are checking out a project that already includes Anto, you will need to run the following command to activate it. This command will only add the commit-msg hook:
mac and linux:
./.anto/anto add-precommit
windows (navigate to .anto folder and):
.\anto.ps1 add-precommit
You can always skip the validation by adding the flag --no-verify when committing code.
Just make a commit and anto will ensure to make all validations.
You can extend the commit-msg hook by adding custom steps. For example, you can include other scripts (tests, linters) in validations.sh
(for Mac and Linux) or validation.ps1
(for Windows):
#!/bin/sh
./anto validate
# goes to the root of the project
cd ..
# Additional scripts (e.g., tests, linters)
lint
gradle test
Anto is under the Fair Code Licence.
To help Anto growth please donate using patreon or KoFi.
Anto UI is a user-friendly interface that consolidates Anto functionalities into one convenient platform. Its intuitive design makes managing tasks simple and efficient.