https://github.com/lordcodes/swifthooks
Include Git hooks in the project and share between contributors with easy install.
https://github.com/lordcodes/swifthooks
git git-hooks swift swift-package-manager
Last synced: 5 months ago
JSON representation
Include Git hooks in the project and share between contributors with easy install.
- Host: GitHub
- URL: https://github.com/lordcodes/swifthooks
- Owner: lordcodes
- License: apache-2.0
- Created: 2022-06-26T11:57:26.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-03-11T14:55:48.000Z (over 2 years ago)
- Last Synced: 2025-10-08T14:53:50.218Z (9 months ago)
- Topics: git, git-hooks, swift, swift-package-manager
- Language: Swift
- Homepage:
- Size: 164 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
---
This is **SwiftHooks** - a CLI tool to install Git hooks that can be distributed alongside a project and shared by all the contributors.
Features • Install • Usage • Contributing
## Features
#### ☑️ Store Git hooks within a project
Provide Git hooks for all project contributors to share.
#### ☑️ Easily install into Git
Simply run a single command and a Git hook will be installed that runs your project-specific Git hooks.
#### ☑️ Easily uninstall
A command is provided to remove any installed hooks.
## Install
### ▶︎ 🖥 Standalone via Swift Package Manager
SwiftHooks can be easily installed globally using Swift Package Manager.
```terminal
git clone https://github.com/lordcodes/swifthooks-swift
cd swifthooks-swift
make install
```
This will install swifthooks into `/usr/local/bin`. If you get a permission error it may be that you don't have permission to write there in which case you just need to adjust permissions using `sudo chown -R $(whoami) /usr/local/bin`.
You can uninstall it again using `make uninstall` which simply deletes it from `/usr/local/bin`.
### ▶︎ 🍀 Mint
You can install SwiftHooks on MacOS using [Mint](https://github.com/yonaskolb/Mint) as follows:
```terminal
mint install lordcodes/swifthooks
```
### ▶︎ 📦 As a Swift package
To install SwiftHooks for use in your own Swift code, add it is a Swift Package Manager dependency within your `Package.swift` file. For help in doing this, please check out the Swift Package Manager documentation.
```swift
.package(url: "https://github.com/lordcodes/swifthooks", exact: "0.4.0")
```
## Usage
### Configure project hooks
Git hooks should be stored inside a `.git-hooks` directory, which should be relative to the working directory. Inside create a folder named according to the required Git hook and then place the scripts you wish to run in an executable form within the hook folder.
For example:
```terminal
.git-hooks/commit-msg/prepend-jira-issue-id.sh
.git-hooks/prepare-commit-msg/prepend-jira-issue-id.sh
```
Ensure the scripts are executable with `chmod a+x .git-hooks/commit-msg/prepend-jira-issue-id.sh`.
### 🖥 Via the Standalone CLI
```terminal
USAGE: swifthooks [-q|--quiet]
ARGUMENTS:
Installs Git hooks that run's hooks stored in project.
Uninstalls Git hooks that were installed.
Prints out the current version of the tool.
OPTIONS:
-q, --quiet Silence any output except errors
```
### 📦 As a Swift Package
To use SwiftHooks within your own Swift code, import and use the public API of `SwiftHooksKit`.
```swift
import SwiftHooksKit
// Configure printing
SwiftHooks.shared.printer = ConsolePrinter(quiet: false)
// Install hooks
try InstallHooksService().run()
// Uninstall hooks
try UninstallHooksService().run()
```
## Contributing or Help
If you notice any bugs or have a new feature to suggest, please check out the [contributing guide](https://github.com/lordcodes/swifthooks/blob/master/CONTRIBUTING.md). If you want to make changes, please make sure to discuss anything big before putting in the effort of creating the PR.
To reach out, please contact [@lordcodes on Twitter](https://twitter.com/lordcodes).