{"id":25019708,"url":"https://github.com/djeada/git-hooks","last_synced_at":"2025-03-30T10:11:51.982Z","repository":{"id":51793914,"uuid":"412466709","full_name":"djeada/Git-Hooks","owner":"djeada","description":"Welcome to this collection of useful Git hooks! In this repository, you will find a variety of scripts written in Bash and Python that you can use to improve your workflow and ensure that your code meets certain standards.","archived":false,"fork":false,"pushed_at":"2023-03-23T21:53:03.000Z","size":249,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-05T11:51:55.743Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/djeada.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-01T12:57:03.000Z","updated_at":"2022-12-19T20:15:46.000Z","dependencies_parsed_at":"2023-02-17T10:45:59.028Z","dependency_job_id":null,"html_url":"https://github.com/djeada/Git-Hooks","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djeada%2FGit-Hooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djeada%2FGit-Hooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djeada%2FGit-Hooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djeada%2FGit-Hooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/djeada","download_url":"https://codeload.github.com/djeada/Git-Hooks/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246301997,"owners_count":20755514,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-05T11:51:27.432Z","updated_at":"2025-03-30T10:11:51.964Z","avatar_url":"https://github.com/djeada.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Git-Hooks\nWelcome to this collection of useful Git hooks! In this repository, you will find a variety of scripts written in Bash and Python that you can use to improve your workflow and ensure that your code meets certain standards.\n\n![Capture](https://user-images.githubusercontent.com/37275728/186116675-44002347-b151-4da6-a0f5-edd5f199d73b.PNG)\n\n## Set Up for Unix, MacOS\n\n1. Download the code from the repository:\n    \n```Bash\ngit clone https://github.com/djeada/Git-Hooks.git\ncd Git-Hooks\n```\n\n2. Install modules via VENV:\n\n```Bash\nvirtualenv env\nsource env/bin/activate\npip install -r requirements.txt\n```\n\n3. Run any script from src directory:\n\n```Bash\npython src/example_script.py\n```\n\n## Understanding Hooks\n\nWhen you explore a well-structured repository, you'll come across a `hooks` folder. Git itself includes a set of hooks that can execute scripts in various scenarios, such as before pushing your code to the repository, after pulling from the remote, or before creating a new commit.\n\n## Pre-commit\n\nPre-commit scripts are executed when the `git commit` command is used. These scripts are often employed to run tasks that verify your code conforms to the coding style adopted by your development team.\n\nFor instance, Python projects may use tools like `black` and `flake8` to ensure code adheres to established standards. If your code doesn't meet these standards, the tools will prevent you from creating a new commit and modify your code accordingly.\n\nYou can then review your code, confirm everything is in order, and attempt to commit again. This time, the commit should be successful.\n\nAlthough you can run tests using pre-commit, they typically take more than a few seconds to execute. Therefore, we generally advise against running tests during pre-commit.\n\n## Implementing a Custom Hook\n\nTo use a custom hook, create a file named pre-commit in the `.git/hooks` directory. The filename is essential, as Git will only recognize your script if it's named accordingly. Edit the pre-commit file and add the commands you want Git to execute whenever you attempt to make a commit. For this repository, we use the following script:\n\n```Bash\n#!/usr/bin/env bash\nhooks/_run_all.sh\n```\n\nDon't forget to grant execution permissions to the pre-commit script!\n\n## Available scripts\n\n| Script | Description | Python | Bash |\n|:------:|:-----------:|:------:|:----:|\n| remove diacritics | Removes diacritics from every file in a given directory. | \u003ca href=\"https://github.com/djeada/Git-Hooks/blob/main/src/remove_diacritics.py\"\u003eremove_diacritics.py\u003c/a\u003e | \u003ca href=\"https://github.com/djeada/Git-Hooks/blob/main/src/remove_diacritics.sh\"\u003eremove_diacritics.sh\u003c/a\u003e |\n| remove carriage return | Removes carriage returns from every file in a given directory. | \u003ca href=\"https://github.com/djeada/Git-Hooks/blob/main/src/remove_carriage_return.py\"\u003eremove_carriage_returns.py\u003c/a\u003e | \u003ca href=\"https://github.com/djeada/Git-Hooks/blob/main/src/remove_carriage_return.sh\"\u003eremove_carriage_returns.sh\u003c/a\u003e |\n| remove trailing whitespace | Removes trailing whitespaces from every file in a given directory. | \u003ca href=\"https://github.com/djeada/Git-Hooks/blob/main/src/remove_trailing_whitespaces.py\"\u003eremove_trailing_whitespaces.py\u003c/a\u003e | \u003ca href=\"https://github.com/djeada/Git-Hooks/blob/main/src/remove_trailing_whitespaces.sh\"\u003eremove_trailing_whitespaces.sh\u003c/a\u003e |\n| last line empty | Ensures that every file a given directory ends with a newline. | \u003ca href=\"https://github.com/djeada/Git-Hooks/blob/main/src/last_line_empty.py\"\u003elast_line_empty.py\u003c/a\u003e | \u003ca href=\"https://github.com/djeada/Git-Hooks/blob/main/src/last_line_empty.sh\"\u003elast_line_empty.sh\u003c/a\u003e |\n| no binaries | Checks if there are any binaries in the staging area. | \u003ca href=\"https://github.com/djeada/Git-Hooks/blob/main/src/no_binaries.py\"\u003eno_binaries.py\u003c/a\u003e | \u003ca href=\"https://github.com/djeada/Git-Hooks/blob/main/src/no_binaries.sh\"\u003eno_binaries.sh\u003c/a\u003e |\n| correct file names | Ensures that no filename has spaces in it. | \u003ca href=\"https://github.com/djeada/Git-Hooks/blob/main/src/correct_file_names.py\"\u003ecorrect_file_names.py\u003c/a\u003e | \u003ca href=\"https://github.com/djeada/Git-Hooks/blob/main/src/correct_file_names.sh\"\u003ecorrect_file_names.sh\u003c/a\u003e \n| correct docstrings | Unify formatting in Python docstrings. | \u003ca href=\"https://github.com/djeada/Git-Hooks/blob/main/src/correct_docstrings.py\"\u003ecorrect_docstrings.py\u003c/a\u003e | \u003ca\u003ecorrect_docstrings.sh\u003c/a\u003e |\n| python formatter | Beautify and format every python file found in the current repository. | \u003ca\u003epython_format.py\u003c/a\u003e | \u003ca href=\"https://github.com/djeada/Git-Hooks/blob/main/src/python_format.sh\"\u003epython_format.sh\u003c/a\u003e |\n| cpp formatter | Beautify and format every cpp file found in the current repository. | \u003ca\u003ecpp_format.py\u003c/a\u003e | \u003ca href=\"https://github.com/djeada/Git-Hooks/blob/main/src/cpp_format.sh\"\u003ecpp_format.sh\u003c/a\u003e |\n| shell formatter | Beautify and format every shell script found in the current repository. | \u003ca\u003eshell_format.py\u003c/a\u003e | \u003ca href=\"https://github.com/djeada/Git-Hooks/blob/main/src/shell_format.sh\"\u003eshell_format.sh\u003c/a\u003e |\n\n## Refrences\n\n* https://www.git-scm.com/docs/githooks\n* https://githooks.com/\n* https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html\n\n## Contributing\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\nPlease make sure to update tests as appropriate.\n\n## License\n[MIT](https://choosealicense.com/licenses/mit/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdjeada%2Fgit-hooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdjeada%2Fgit-hooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdjeada%2Fgit-hooks/lists"}