diff --git a/README.md b/README.md index 5982e55..d9993d9 100644 --- a/README.md +++ b/README.md @@ -34,16 +34,20 @@ Add this pre-commit hook to your `.pre-commit-config.yaml` (create it, if you do ```yaml repos: - repo: https://github.com/LiquidFun/aoc_tiles - rev: 0.4.0 + rev: 0.5.0 hooks: - id: aoc-tiles args: - - --auto-add-tiles-to-git + - --auto-add-tiles-to-git=amend ``` There are a lot more flags, see [config.py](./aoc_tiles/config.py) for all of them. Auto add tiles is recommended as it will automatically add the tiles to your git repository, otherwise you might -forget it and the tiles will not be updated. +forget it and the tiles will not be updated. Note that this will amend your just created commit. If you do not want +this, remove that flag. + +Now install the hook with `pre-commit install --hook-type post-commit` and you are done! +The **--hook-type** flag is important, otherwise the hook will not run. ### Set-up diff --git a/aoc_tiles/make_tiles.py b/aoc_tiles/make_tiles.py index ba2f4f2..b113615 100644 --- a/aoc_tiles/make_tiles.py +++ b/aoc_tiles/make_tiles.py @@ -170,8 +170,6 @@ def _ensure_is_not_running(self): def make_tiles(self): self._ensure_is_not_running() - with open(self.config.running_lock_path, "w") as file: - file.write("") print("Running AoC-Tiles") solve_data = self.compose_solve_data() logger.info("Found {} years with solutions", len(solve_data.year_to_data)) @@ -183,9 +181,14 @@ def make_tiles(self): self.solution_finder.git_add(self.config.image_dir) if self.config.auto_add_tiles_to_git in ["amend"]: - self.solution_finder.git_commit_amend() + with open(self.config.running_lock_path, "w") as file: + file.write("") + try: + self.solution_finder.git_commit_amend() + finally: + print("Could not amend commit. Maybe there is nothing to amend?") + self.config.running_lock_path.unlink() - self.config.running_lock_path.unlink() # Currently max_workers=1 until bug is fixed where README is written simultaneously # with ThreadPoolExecutor(max_workers=1) as executor: diff --git a/poetry.lock b/poetry.lock index 30a830b..66e6365 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2,13 +2,13 @@ [[package]] name = "certifi" -version = "2023.7.22" +version = "2023.11.17" description = "Python package for providing Mozilla's CA Bundle." optional = false python-versions = ">=3.6" files = [ - {file = "certifi-2023.7.22-py3-none-any.whl", hash = "sha256:92d6037539857d8206b8f6ae472e8b77db8058fec5937a1ef3f54304089edbb9"}, - {file = "certifi-2023.7.22.tar.gz", hash = "sha256:539cc1d13202e33ca466e88b2807e29f4c13049d6d87031a3c110744495cb082"}, + {file = "certifi-2023.11.17-py3-none-any.whl", hash = "sha256:e036ab49d5b79556f99cfc2d9320b34cfbe5be05c5871b51de9329f0603b0474"}, + {file = "certifi-2023.11.17.tar.gz", hash = "sha256:9b469f3a900bf28dc19b8cfbf8019bf47f7fdd1a65a1d4ffb98fc14166beb4d1"}, ] [[package]] @@ -154,13 +154,13 @@ test = ["black", "coverage[toml]", "ddt (>=1.1.1,!=1.4.3)", "mock", "mypy", "pre [[package]] name = "idna" -version = "3.4" +version = "3.6" description = "Internationalized Domain Names in Applications (IDNA)" optional = false python-versions = ">=3.5" files = [ - {file = "idna-3.4-py3-none-any.whl", hash = "sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2"}, - {file = "idna-3.4.tar.gz", hash = "sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4"}, + {file = "idna-3.6-py3-none-any.whl", hash = "sha256:c05567e9c24a6b9faaa835c4821bad0590fbb9d5779e7caa6e1cc4978e7eb24f"}, + {file = "idna-3.6.tar.gz", hash = "sha256:9ecdbbd083b06798ae1e86adcbfe8ab1479cf864e4ee30fe4e46a003d12491ca"}, ] [[package]] @@ -285,17 +285,18 @@ tests = ["check-manifest", "coverage", "defusedxml", "markdown2", "olefile", "pa [[package]] name = "pygments" -version = "2.16.1" +version = "2.17.2" description = "Pygments is a syntax highlighting package written in Python." optional = false python-versions = ">=3.7" files = [ - {file = "Pygments-2.16.1-py3-none-any.whl", hash = "sha256:13fc09fa63bc8d8671a6d247e1eb303c4b343eaee81d861f3404db2935653692"}, - {file = "Pygments-2.16.1.tar.gz", hash = "sha256:1daff0494820c69bc8941e407aa20f577374ee88364ee10a98fdbe0aece96e29"}, + {file = "pygments-2.17.2-py3-none-any.whl", hash = "sha256:b27c2826c47d0f3219f29554824c30c5e8945175d888647acd804ddd04af846c"}, + {file = "pygments-2.17.2.tar.gz", hash = "sha256:da46cec9fd2de5be3a8a784f434e4c4ab670b4ff54d605c4c2717e9d49c4c367"}, ] [package.extras] plugins = ["importlib-metadata"] +windows-terminal = ["colorama (>=0.4.6)"] [[package]] name = "pyyaml" @@ -409,13 +410,13 @@ files = [ [[package]] name = "typing-extensions" -version = "4.8.0" +version = "4.9.0" description = "Backported and Experimental Type Hints for Python 3.8+" optional = false python-versions = ">=3.8" files = [ - {file = "typing_extensions-4.8.0-py3-none-any.whl", hash = "sha256:8f92fc8806f9a6b641eaa5318da32b44d401efaac0f6678c9bc448ba3605faa0"}, - {file = "typing_extensions-4.8.0.tar.gz", hash = "sha256:df8e4339e9cb77357558cbdbceca33c303714cf861d1eef15e1070055ae8b7ef"}, + {file = "typing_extensions-4.9.0-py3-none-any.whl", hash = "sha256:af72aea155e91adfc61c3ae9e0e342dbc0cba726d6cba4b6c72c1f34e47291cd"}, + {file = "typing_extensions-4.9.0.tar.gz", hash = "sha256:23478f88c37f27d76ac8aee6c905017a143b0b1b886c3c9f66bc2fd94f9f5783"}, ] [[package]] diff --git a/pyproject.toml b/pyproject.toml index d6540ce..dafcb7d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "aoc-tiles" -version = "0.4.1" +version = "0.5.0" description = "Fancy Advent of Code README tiles showing the completion status of the challenges per day" authors = ["Brutenis Gliwa, "] license = "Apache-2.0"