This is a very simple Git repository linter for a Software Development Project course.
- Checks that the repository contains a README file and that it contains a LICENSE.
- Checks that the repository contains a .gitignore file.
- Checks if there are GitHub WorkFlow files (.github/workflows/).
- Checks if there are any test files in the repository. (Files with the word "test" in the path.)
- Checks the repository for secrets using Trufflehog.
- Run linter on a batch of repositories.
- Configuration using a yaml file.
docker run -it --rm -v ./repolinter:/tmp/repolinter ghcr.io/emilzackrisson/repositorylinter:latest -hOutput:
Description:
Simple CLI tool to lint git repositories
Usage:
RepositoryLinter <url-or-path> [options]
Arguments:
<url-or-path> URL or path to lint. Path can be a directory or a batch file containing URLs or paths, one per line.
Options:
--disable-cleanup Do not delete the cloned git repository
--disable-truncate Do not truncate the output. By default, the output is truncated to 10 lines per check.
--ignore-gitignore Ignore .gitignore. Includes all files in the search.
--path-to-save-to <path-to-save-to> Directory to save the repository to. If not provided, a temporary directory will be used.
--config <config> Path to configuration file.
--version Show version information
-?, -h, --help Show help and usage information
- Clone the repository
- Ensure .NET Core 9 is installed
- Ensure Git is installed
- Ensure Trufflehog is installed
- Run
dotnet restorein the root of the repository to restore dependencies - Run the program
dotnet run -- -hfor help (the "--" is only required when no commands are given.)
For more information on how to use the program, run the program with the -h or --help flag.
docker run -it --rm -v ./repolinter:/tmp/repolinter ghcr.io/emilzackrisson/repositorylinter:latest --helpThese guides use the Docker image, but the same commands can be used without Docker.
docker run -it --rm -v ./repolinter:/tmp/repolinter ghcr.io/emilzackrisson/repositorylinter:latest https://github.com/EmilZackrisson/RepositoryLinterdocker run -it --rm -v ./repolinter:/tmp/repolinter ghcr.io/emilzackrisson/repositorylinter:latest /tmp/repolinter/RepositoryLinterdocker run -it --rm -v ./repolinter:/tmp/repolinter ghcr.io/emilzackrisson/repositorylinter:latest /tmp/repolinter/batch.txtThe batch file should contain a list of repositories, one per line. Can be URL or local path. Example:
https://github.com/EmilZackrisson/RepositoryLinter
/tmp/repolinter/RepositoryLinter
The program can be configured using a yaml and the --config flag. This is optional and the program will use the default configuration if no configuration is provided.
Checks:
- Name: "License Exists" # Name of the check. (See https://github.com/EmilZackrisson/RepositoryLinter/blob/main/RepositoryLinter/LintRunner.cs)
AllowedToFail: false # Default
# Path to save the git repositories to. Default is a temp directory.
PathToSaveGitRepos: "~/RepositoryLinter"
# Truncate the output of each check to 10 lines. Default is true.
TruncateOutput: true # Default
# Clean up the cloned repositories after the program has finished. Default is true.
CleanUp: true # Defaultdocker run -it --rm -v ./repolinter:/tmp/repolinter -v ./config.yaml:/app/config.yaml ghcr.io/emilzackrisson/repositorylinter:latest https://github.com/EmilZackrisson/RepositoryLinter --config /app/config.yamlThe configuration file in ./config.yaml on the host will be used.
The configuration priority is:
- Command line arguments
- Configuration file
- Default configuration
The unit tests are using the xUnit framework.
- Clone the repository
- Install all dependencies listed in the Run without Docker section
- Run
dotnet restorein the root of the repository to restore dependencies - Run
dotnet testin the root of the repository to run tests