Closed pylang closed 2 years ago
@pylang I haven't used pre-commit hooks before. I'll look into them and let you know what I think.
@pylang Pre-commit looks like a pretty helpful tool. From my understanding, I would just need to create a valid .pre-commit-hooks.yaml
file for this repo and make sure the tool is interfacing properly with pre-commit. Is that your understanding as well?
Additionally, I'm trying to understand the example you included in the issue description. I haven't used the git flow tool myself, so it's a little difficult to know for sure what git commands are implicit within git flow release start 0.2.0
. It seems like your suggesting that change init
would be run in this case? If that's so, I'm hesitant to implement that. change init
only needs to be run once for a given repo, and it's really good to have users double checking this step because plenty can go wrong. Seems like automating something that only happens once doesn't have much payoff, but maybe I'm misunderstanding what you meant.
Next, I'm wondering which change commands you think would be most helpful. It looks like I can easily offer multiple versions of the command that users can choose from. I can think of 4 useful options: change
, change tag
, and change post
as individual options, as well as change all
as another option?
Lastly, when you say "+ bump versions during release" are you just referring to the git version (which change tag
is currently capable of) or are you also referring to updating the version elsewhere in the repo?
Yes, you have the right understanding on implementing hooks. See also the resources below on examples implementing the config file.
In the end, which ever commands achieved the "update changelog + bump files and tags" on releases, that would be great. This idea models standard-version
- an npm implementation of the mentioned behavior from conventional changelog. I haven't found a python equivalent, but this repo, as a hook, seems to have potential.
As to triggering change init
, I hadn't thought about that in particular.
Regarding commands, I'm not sure which commands to recommend yet. I'd have to play with change
some more.
@pylang So I added the --bump
flag which allows change
to interact with a user-created script to version bump a project. I also added a first attempt at the pre-commit-hook file. After reading the documentation, it looks like users can still pass arguments to the hook. So this one hook should let users implement any of the change
commands and features. I'm hoping that we can figure out if there's any further modifications needed.
Many thanks. I'm excited to look into this. It might take me some time to look through the CLI.
I had some trouble installing the hook.
# .pre-commit-config.yaml
- id: isort
- repo: https://github.com/adamtabrams/change.git
rev: 0.14.1
hooks:
- id: change
Seems this configuration complains of a missing .pre-commit-hooks.yaml file.
> git add .
> git commit
An error has occurred: InvalidManifestError:
...
I don't see it included the zip. That might be why it's complaining.
I then tried grabbing from the commit:
# .pre-commit-config.yaml
- id: isort
- repo: https://github.com/adamtabrams/change.git
rev: 4fcbcd7ac529fa2cd5813f596d649f69b587fb22
hooks:
- id: change
and got this error:
An error has occurred: InvalidManifestError:
==> At Hook(id='change')
==> At key: stages
=====> Expected array but got 'str'
In running change, I'm getting some errors
> git tag 0.1.0
> change init
grep: Invalid range end
grep: Invalid range end
grep: Invalid range end
grep: Invalid range end
created CHANGELOG.md
...
I've tried adding more commits, and update via change
, but the changelog only includes tags, not commits.
## [Unreleased]
## [0.3.0] - 2021-05-08
## [0.2.0] - 2021-05-08
## [0.1.0] - 2021-05-08
...
I'll look closer at the docs to see if I'm missing something.
UPDATE: I get it to work on Window GitBash, but doesn't work on Debian so far.
I can reproduce the error using the commandline in this container (click JupyterLab, then File -> New -> Terminal ).
I tried these lines.
# Error
> grep -e "^[A-z]*: " -e "^[A-z]*(.*): " \
-e "^[*-] *[A-z]*: " -e "^[*-] *[A-z]*(.*): " \
"foo"
grep: Invalid range end
grep: Invalid range end
grep: Invalid range end
grep: Invalid range end
Seems to work if I escape some range characters:
# Works
> grep -e "^[A\-z]*: " -e "^[A\-z]*(.*): " \
-e "^[*-] *[A\-z]*: " -e "^[*-] *[A\-z]*(.*): " \
"foo"
@pylang What OS and setup are you using when you get these errors?
Also, using the setup that gives you errors, would you clone the change repo and run ./run-test
I'm running a flavor of Debian. On my system I got 37 failures. The output shows similar grep errors.
I also got failures running tests on a fresh install of Ubuntu focal LTS.
Ran it on docker Ubuntu focal. It passed.
@pylang Is the version of grep in the dockerized Ubuntu different that the versions used when the tests were failing for you?
I have an earlier version of grep (3.3) on my original VM, but the grep versions are newer and the same on both Ubuntu focal LTS (VM) and Ubuntu focal (docker). They are also both using bash.
Passing - again I run the following to launch docker.
sudo docker run --rm -it ubuntu:focal
apt update -y && apt install git git config --global user.name foo git config --global user.email @.*** git clone https://github.com/adamtabrams/change.git cd change ./run-tests
Failing - all other attempts I get errors.
I've created another issue to isolate the grep bug from the main topic. The last pertinent issue was related to installing the hook.
I see it's been edited. I'll take another look.
@pylang I want to check in on this issue. Do you have any updates on the status of this?
Closing base on non-responsiveness
Topic Adding a pre-commit hook
Explaination I'd like to automate generation of changelog + bump versions during release.
Example (using git flow):
Questions Would you consider adding a hook?
Links