Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
93a4e65
change the program architecture into plug in based
bagashvilit Apr 25, 2022
9ed8866
remove extra dependencies
bagashvilit Apr 25, 2022
cb01160
fix import errors
bagashvilit Apr 25, 2022
9e88f0c
add missing import
bagashvilit Apr 25, 2022
8d0f168
load plugins from user
bagashvilit Apr 25, 2022
459adba
load plugins
bagashvilit Apr 25, 2022
0e64a75
load plugins with importlib
bagashvilit Apr 25, 2022
ce193d5
load plugins with importlib
bagashvilit Apr 25, 2022
d27082c
add plug in path to os path
bagashvilit Apr 25, 2022
8701ec5
print path to working dir
bagashvilit Apr 25, 2022
c3238e6
print path to working dir
bagashvilit Apr 25, 2022
b860803
print path to working dir
bagashvilit Apr 25, 2022
7b617c0
print path to working dir
bagashvilit Apr 25, 2022
e1522ba
print path to working dir
bagashvilit Apr 25, 2022
868e9e3
print path to working dir
bagashvilit Apr 25, 2022
932d403
print path to working dir
bagashvilit Apr 25, 2022
1b81407
register all the plug ins automatically
bagashvilit Apr 25, 2022
837a997
change name of to hookspec
bagashvilit Apr 25, 2022
7580fa1
change name of to hookspec
bagashvilit Apr 25, 2022
8365004
change name of to hookspec
bagashvilit Apr 25, 2022
ca7525b
print errors
bagashvilit Apr 25, 2022
525c212
fix the printed output
bagashvilit Apr 25, 2022
4377e03
add default hooks
bagashvilit Apr 25, 2022
5dd185d
add default hooks
bagashvilit Apr 25, 2022
d6c993c
print list of errors
bagashvilit Apr 25, 2022
28203c8
let user disable rules
bagashvilit Apr 25, 2022
d9bef8b
let user disable rules
bagashvilit Apr 25, 2022
5b95825
add check for period at the end of line
bagashvilit Apr 25, 2022
16d4836
add check for period at the end of line
bagashvilit Apr 25, 2022
59e3568
refactor entry point
bagashvilit Apr 25, 2022
edf7c5a
read commit message file
bagashvilit Apr 25, 2022
42ec5bc
add message argument in hook call
bagashvilit Apr 25, 2022
031f529
add check for blank line
bagashvilit Apr 25, 2022
490e892
display debugging info
bagashvilit Apr 25, 2022
343a265
display debugging info
bagashvilit Apr 25, 2022
aa41e54
Add docstrings
bagashvilit Apr 26, 2022
ff78a09
change precommit hook to commit message hook
bagashvilit Apr 26, 2022
38cf0d1
add docstrings
bagashvilit Apr 26, 2022
e2b88dd
add documentation to readme
bagashvilit Apr 26, 2022
658776e
fix typo in readme
bagashvilit Apr 26, 2022
e4f9575
minor fix in readme
bagashvilit Apr 26, 2022
64155ba
remove python dependency
bagashvilit May 16, 2022
713afaa
try system instead of python
bagashvilit May 16, 2022
57e7726
add tests for utils.py and default.py
bagashvilit Jun 10, 2022
45d8f5a
clarify new features in the rreadme
bagashvilit Jun 10, 2022
69e36a8
refactor create plugin manager
bagashvilit Jun 10, 2022
27474cc
test for exit code
bagashvilit Jun 10, 2022
9f052ac
check source code with linters
bagashvilit Jun 10, 2022
984906d
Check source code with linters
bagashvilit Jun 10, 2022
1659829
Remove poetry lock file
bagashvilit Jun 10, 2022
0c9cef8
Resolve dependency issues
bagashvilit Jun 10, 2022
327cca0
Resolve dependency issues
bagashvilit Jun 10, 2022
e72426c
Fix type erroe
bagashvilit Jun 10, 2022
9a69fc9
Fix type erroe
bagashvilit Jun 10, 2022
371de12
Fix linting errors
bagashvilit Jun 30, 2022
306a462
Add codecov in dependencies
bagashvilit Jun 30, 2022
5230dde
Drop support for python 3.7 and add support for 3.10
bagashvilit Jun 30, 2022
9eeec10
Put python version number in quotes
bagashvilit Jun 30, 2022
e1e9d58
Drop 3.10
bagashvilit Jun 30, 2022
0696067
Try command line options
bagashvilit Jul 1, 2022
d931367
Import list and optional from typing
bagashvilit Jul 1, 2022
f74ffeb
Return exit code 1
bagashvilit Jul 1, 2022
20d9a1d
Allow multiple user plugin files
bagashvilit Jul 1, 2022
a7c4c14
Fix failing test
bagashvilit Jul 1, 2022
9aaf901
Remove default files
bagashvilit Jul 1, 2022
7fd9737
Display kept plugins
bagashvilit Jul 1, 2022
7e1e565
Display kept plugins
bagashvilit Jul 1, 2022
8c5c309
Register plugins
bagashvilit Jul 1, 2022
6cee013
Remove tests for default plugins
bagashvilit Jul 1, 2022
0cd3e73
Add test for reading the message
bagashvilit Jul 1, 2022
0448d0a
Add test for plugin filter
bagashvilit Jul 1, 2022
0b832c5
Add tests for host.py
bagashvilit Jul 1, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
matrix:
os: [Ubuntu, MacOS, Windows]
python-version: [3.7, 3.8]
python-version: [3.8, 3.9]

steps:
- uses: actions/checkout@v1
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ share/python-wheels/
.installed.cfg
*.egg
MANIFEST

.lock
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
Expand Down
16 changes: 4 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
minimum_pre_commit_version: 1.21.0
repos:

# check with pylint
- repo: https://github.com/PyCQA/pylint
rev: pylint-2.5.3
hooks:
- id: pylint
stages: [commit]
args:
- --score=n

# check docstrings
- repo: https://github.com/PyCQA/pydocstyle
rev: 5.0.2
Expand All @@ -28,7 +19,7 @@ repos:

# format Python code with black
- repo: https://github.com/ambv/black
rev: 19.10b0
rev: 22.3.0
hooks:
- id: black
stages: [commit]
Expand All @@ -40,9 +31,10 @@ repos:
- id: reorder-python-imports
stages: [commit]

#lint the commit message with commitcan
#lint the commit message with commitcanvas
- repo: https://github.com/CommittedTeam/CommitCanvas
rev: e78450d335ccb77da98a2f21c574bc414120bc84
rev: 9f052acaab0591cf6b120199a4133a1bae268244
hooks:
- id: commitcanvas
stages: [commit-msg]

2 changes: 1 addition & 1 deletion .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
verbose: False
language: python
pass_filenames: false
stages: [prepare-commit-msg]
stages: [commit-msg]

119 changes: 80 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,67 +41,110 @@ Other features mentioned above are under development and will be added to Commit

## Installation

Currently `commitcanvas` works with `pre-commit` so please follow the steps below.
Currently `commitcanvas` works as a `pre-commit` hook ,so please follow the steps below.

Add `.pre-commit-config.yaml` to your repository.
1. Add `.pre-commit-config.yaml` file to your git repository. Such as [.pre-commit-config.yaml](./.pre-commit-config.yaml)

Add following code block inside the `.pre-commit-config.yaml`:
2. Add following code block inside your `.pre-commit-config.yaml`:

```
```

minimum_pre_commit_version: 1.21.0
repos:
minimum_pre_commit_version: 1.21.0
repos:

# check with commitcanvas.
- repo: https://github.com/CommittedTeam/CommitCanvas
rev: the revision or tag to clone at
hooks:
- id: commitcanvas
language_version: python3.7
language: python
stages: [prepare-commit-msg]
# check with commitcanvas.
- repo: https://github.com/CommittedTeam/CommitCanvas
# the revision or tag to clone at
rev: 38cf0d1f95ee3ec0e3ac6771d9ca2ab6bce70c75
hooks:
- id: commitcanvas
language_version: python3.7
language: python
stages: [commit-msg]

```
```

Install `pre-commit`, please refer the [documentation](https://pre-commit.com/#install)
3. Install `pre-commit`, please refer the [documentation](https://pre-commit.com/#install)

To use `commitcanvas` as a `prepare-commit-msg` hook, install pre-commit in `.git/hooks/prepare-commit-msg`:
4. To use `commitcanvas` as a `commit-msg` hook, install pre-commit in `.git/hooks/prepare-commit-msg` by running the following command:

`pre-commit install --hook-type prepare-commit-msg`
`pre-commit install --hook-type commit-msg`

NOTE: You need to run this command everytime you clone the repository, unless you configure `pre-commit` globaly. Please follow the [link](https://pre-commit.com/#automatically-enabling-pre-commit-on-repositories) for more information.
NOTE: You need to run this command everytime you clone the repository, unless you configure `pre-commit` globaly. Please follow the [link](https://pre-commit.com/#automatically-enabling-pre-commit-on-repositories) for more information.

## Run

Every time you make a commit `commitcanvas` will automatically check the commit message, and if there are any erros, `git commit` command will be aborted before creating a commit, and helpul tips will be dispalyed about how to improve the commit message.
Every time you make a commit `commitcanvas` will automatically check the commit message, and if there are any errors, `git commit` command will be aborted before creating a commit, and helpul tips will be dispalyed about how to improve the commit message.

If you would like to skip commitcanvas errors, please run `git commit` with `SKIP=commitcanvas`. Please see
[pre-commit](https://pre-commit.com/#temporarily-disabling-hooks) documentation for more information about
environment variables.
Here are some of the ways to customize commitcanvas:

- CommitCanvas comes with default rules for checking the style of your commit message. Please see the [default rules](commitcanvas/default.py). However since commitcanvas uses `pluggy` you can add your own rules. Please follow the steps below:

1. Inside your repository create a python file where you will write your rules, such as `commitcanvas_plugins.py`. Name of the file does not matter as long as it's not `commitcanvas.py`

2. Add the file as an argument to `--path` parameter in `args` inside `.pre-commit-config.yaml`. For example:


```

Commitcanvas will also predict and attach the conventional commit label automatically. If you would like
to edit the message as well as the predicted label please run `git commit` command with `-e` option.
minimum_pre_commit_version: 1.21.0
repos:

### Project Agnostic
# check with commitcanvas.
- repo: https://github.com/CommittedTeam/CommitCanvas
# the revision or tag to clone at
rev: 38cf0d1f95ee3ec0e3ac6771d9ca2ab6bce70c75
hooks:
- id: commitcanvas
language_version: python3.7
language: python
stages: [commit-msg]
args: ["--path","commitcanvas_plugins.py"
]

Commitcanvas can be used in project agnostic mode. In this mode commitcanvas will use deployed model that
was trained on over 300 open-source, [critical](https://github.com/ossf/criticality_score), [conventional](https://www.conventionalcommits.org/en/v1.0.0/) repositories.
```

Unless project-specific path is provided commitcnavas will use the pre-deployed model as a default
3. import `commitcanvas` in `commitcanvas_plugins.py` and add your own plugins, see the example [file](https://github.com/CommittedTeam/test-useful-tools/blob/master/commitcanvas_plugins.py). Each plugin needs to be represented as its own class. The function name has to be `rule` and must take two arguments `(self,message)`. For example, let's write a new rule that requires the commit message to have at least 2 words.

### Project Specific
```
class subject_min_word_count:
@commitcanvas.check
def rule(self,message):
min_count = 2
count = len(message.split(" "))
if count <= min_count:
return("Commit message must have more than {} words, got: {}".format(min_count,count))
```

Commitcnavas can also be used in project specific mode. In this mode commitcnavas can be trained on selected repository.
Now if you run `git commit`, your commit message will be checked by default as well as added rules.

For instance if you would like to train commitcnavas on your repository you need to provide git url and the
local path to save the trained model.
- CommitCanvas also lets you disable specific default rules. Pass their names to `disable` parameter in `args` inside `.pre-commit-config.yaml`. The names must match the class names specified in[default_rules.py](commitcanvas/default.py) and need to be separated by comma. For example:

Command to train and save the model: `commitcanvas train <url> <save>`
```

After the model is saved please add the path to `pre-commit-config.yaml` file in your repository
minimum_pre_commit_version: 1.21.0
repos:

Please see [Commitcanvas-models](https://github.com/CommittedTeam/commitcanvas-models) for more information
about the deployed models
# check with commitcanvas.
- repo: https://github.com/CommittedTeam/CommitCanvas
# the revision or tag to clone at
rev: 38cf0d1f95ee3ec0e3ac6771d9ca2ab6bce70c75
hooks:
- id: commitcanvas
language_version: python3.7
language: python
stages: [commit-msg]
args: ["--path","commitcanvas_plugins.py",
"--disable","subject_max_char_count, blank_line"
]

```

- If you would like to use an external library or package in your custom hooks please add the name of that package in `.pre-commit-config.yaml`. For example if you would like to use `pandas` and `textblob` you can add them to the `additional_dependencies: [pandas, textblob]`.

- If you would like to skip commitcanvas errors, please run `git commit` with `SKIP=commitcanvas`. Please see
[pre-commit](https://pre-commit.com/#temporarily-disabling-hooks) documentation for more information about
environment variables.

## Development info

Expand Down Expand Up @@ -162,8 +205,6 @@ Some of the existing tools that are similar to CommitCanvas:
- [commitlint](https://github.com/conventional-changelog/commitlint): "Lint commit messages"
- [cz-cli](https://github.com/commitizen/cz-cli): "The commitizen command line utility."

Popular existing tools for checking the commit message usually have features to lint the message, fix or suggest labels, add or modify the checks and help the users keep creating explicit commit history. In addition to those functionalities, in the near future, CommitCanvas will also have a feature to predict the build status and let the users see if the commit is going to break the build before pushing their changes to Github. Please see the [issues](https://github.com/CommittedTeam/CommitCanvas/issues) for more information.

## Contributing

We welcome everyone who is interested in helping improve CommitCanvas! If you are interested in being a contributor, please review our [Code of Conduct](./CODE_OF_CONDUCT.md) and [Guidelines for Contributors](./CONTRIBUTING.md) before raising an issue, or beginning a contribution.
Expand Down
2 changes: 0 additions & 2 deletions codecov.yml

This file was deleted.

11 changes: 0 additions & 11 deletions commitcanvas.egg-info/PKG-INFO

This file was deleted.

12 changes: 0 additions & 12 deletions commitcanvas.egg-info/SOURCES.txt

This file was deleted.

1 change: 0 additions & 1 deletion commitcanvas.egg-info/dependency_links.txt

This file was deleted.

3 changes: 0 additions & 3 deletions commitcanvas.egg-info/entry_points.txt

This file was deleted.

3 changes: 0 additions & 3 deletions commitcanvas.egg-info/requires.txt

This file was deleted.

1 change: 0 additions & 1 deletion commitcanvas.egg-info/top_level.txt

This file was deleted.

6 changes: 4 additions & 2 deletions commitcanvas/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
"""Empty file required by pylint."""
__version__ = "0.1.0"
"""Plug in marker."""
import pluggy

check = pluggy.HookimplMarker("commitcanvas")
41 changes: 0 additions & 41 deletions commitcanvas/__main__.py

This file was deleted.

34 changes: 0 additions & 34 deletions commitcanvas/commit_label/train_model.py

This file was deleted.

Binary file removed commitcanvas/commit_label/trained_model.pkl
Binary file not shown.
Loading