Skip to content

Commit

Permalink
Revert "feat/hook templates (#5)" (#6)
Browse files Browse the repository at this point in the history
This reverts commit 3c894d0.
  • Loading branch information
iton0 authored Nov 20, 2024
1 parent 3c894d0 commit 51b8b0f
Show file tree
Hide file tree
Showing 39 changed files with 237 additions and 1,319 deletions.
3 changes: 3 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ updates:
directory: "/"
schedule:
interval: "weekly"
day: "friday"
time: "12:00"
timezone: "America/New_York"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
Expand Down
34 changes: 9 additions & 25 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

# Step 2: Set up Go environment
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
# Step 2: Run your build script
- name: Run build script
run: |
rm -rf ./bin
chmod +x ./scripts/build
./scripts/build
# Step 3: Use release-please to create a release
- name: Create release
Expand All @@ -30,29 +31,12 @@ jobs:
with:
release-type: go

# Step 4: Update the version in the build and perform multi-platform builds
- name: Build for multiple platforms
if: ${{ steps.release.outputs.release_created }}
run: |
VERSION="${{ steps.release.outputs.version }}"
echo "Updating version to ${VERSION}"
mkdir -p bin
# Build for Linux
GOOS=linux GOARCH=amd64 go build -o bin/hkup-linux -ldflags="-s -w -X cmd.version=${VERSION}" .
# Build for Darwin/macOS
GOOS=darwin GOARCH=amd64 go build -o bin/hkup-darwin -ldflags="-s -w -X cmd.version=${VERSION}" .
# Build for Windows (optional, uncomment if needed)
# GOOS=windows GOARCH=amd64 go build -o bin/hkup.exe -ldflags="-s -w -X cmd.version=${VERSION}" .
# Step 5: Upload Release Artifacts if a release was created
# Step 4: Upload Release Artifacts if a release was created
- name: Upload Release Artifacts
if: ${{ steps.release.outputs.release_created }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload ${{ steps.release.outputs.tag_name }} \
bin/*
./bin/*
3 changes: 3 additions & 0 deletions .hkup/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
if git diff --cached --name-only | grep -q '\.go$'; then
echo "Formatting Go files..."
gofmt -w .
echo ""

# Add formatted files to the staging area
git add .
else
echo "No Go files changed. Skipping formatting."
echo ""
Expand Down
84 changes: 32 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# HkUp
> Your CLI tool with benefits built by [iton0](https://github.com/iton0) in [Go](https://go.dev/)!
Your CLI tool with benefits built by [iton0](https://github.com/iton0) in [Go](https://go.dev/)!

[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/iton0/hkup-cli)](https://github.com/iton0/hkup-cli/releases/latest)
[![godoc](https://godoc.org/github.com/iton0/hkup-cli?status.svg)](http://godoc.org/github.com/iton0/hkup-cli)
Expand All @@ -11,16 +11,9 @@
## Introduction
Git hooks automate and implement processes in your workflow, increasing code quality and consistency.

Common use cases include:
- Commit Message Validation
- Environment Configuration
- Formatting
- Linting
- Testing
However, many developers avoid git hooks due to a lack of awareness and the perceived complexity of setup, discouraging them from using this feature.

However, many developers avoid Git hooks due to a lack of awareness and the perceived complexity of setup, discouraging them from using this feature.

**HkUp** simplifies the management of Git hooks, allowing you to focus on the logic and usage of your hooks instead.
**HkUp** simplifies the management of git hooks, allowing you to focus on the logic and usage of your hooks instead.

## Installation
External Dependencies:
Expand All @@ -34,9 +27,10 @@ Run the script below (supports Linux and macOS):
curl -sSL https://raw.githubusercontent.com/iton0/hkup-cli/main/scripts/install | sh
```
> [!Tip]
> To update HkUp, simply rerun the script above. It will automatically replace your current version with the latest release.
> To update HkUp, rerun the above script.
> It will replace the current version.
### Uninstalling HkUp
#### Uninstalling hkup

```sh
# Locates and deletes the HkUp binary
Expand All @@ -46,63 +40,49 @@ sh -c 'rm "$(command -v 'hkup')"'
</details>

## Usage Quickstart
This section provides basic information about core usage. For detailed usage information run `hkup --help`.
This section provides basic information about core usage. For detailed options run `hkup --help`.

### Initializing hkup
#### Initializing hkup
Run the following command in your git repository to initialize HkUp:
```sh
hkup init
```

This creates a **.hkup** directory and sets the local **core.hooksPath** variable. If the directory already exists, it will simply update the path variable. The path is relative, ensuring that moving your repository won’t affect hook sourcing.
This command creates a **.hkup** folder and sets the local **core.hooksPath** variable. If the folder already exists, it will simply update the path variable. The path is relative, ensuring that moving your repository won’t affect hook sourcing.

### Adding & Removing hooks
#### Adding & Removing hooks
Add or remove hooks easily with:
```sh
hkup add <hook-name>

hkup remove <hook-name>
```

### Templates
A **template** is a pre-configured, reusable Git hook that simplifies and automates the process of setting up hooks in a Git repository. With **HkUp**, you can create, copy, edit, or remove templates, allowing for consistent and easy application of hooks without needing to rewrite scripts each time.
#### Info & Docs
There are two commands that will help you with both HkUp and git hooks:

The templates are stored in the HkUp config templates directory that can either be found at **$XDG_CONFIG_HOME/hkup/templates** or **$HOME/.config/hkup/templates** depending on your system.
**`hkup list {hook|lang}`**
Outputs list of either available hooks or supported languages.

#### Naming Convention
Template files follow the naming convention:
`<template-name>#<hook-name>`
Where:
- `<template-name>` is the name of the template.
- `<hook-name>` is the specific Git hook (e.g., pre-commit, post-merge).
**`hkup doc <hook-name>`**
Opens your browser with Git documentation for the specified git hook, helping you understand its usage.

**Create a template**:
```sh
hkup template create
# OR
hkup template create <hook-name>
```
## Future TODOs
- [ ] make an update subcommand
- [ ] store custom git hooks as templates for future use (via add template subcmd)
- Allow users to create, store, and share templates for common hooks. Users can fetch these templates over the network.
- [ ] branch-specific hooks
- [ ] logo maybe?

**Copy a template** into current working directory:
```sh
hkup template copy <template-name>
```
## Contributing
HkUp welcomes contributions to enhance this CLI application! Before submitting a pull request (PR) for a new feature, please follow these steps:

**Edit a template**:
```sh
hkup template edit <template-name>
```
>[!CAUTION]
> Editing a template will not update its copies.
1. **Create an Issue**:
If you have an idea for a new feature, please create a new issue in the repository using the **feature_request** template. Provide a clear description of the feature and its potential benefits. Please note that issues submitted without using the template may be closed without warning.

**Remove a template**:
```sh
hkup template remove <template-name>
```
2. **Wait for Approval**:
Once you submit your issue, I’ll review it and provide feedback. If I approve the feature request, I will let you know that you're free to proceed with your PR.

3. **Submit Your PR**:
After receiving approval, you can create your PR. Be sure to reference the issue in your PR description.

## Roadmap to v1.0.0
1. windows support
2. wrapper for git init & clone and gh repo create & clone
3. HkUp logo (may or may not keep this one)
4. better test coverage
5. Allow users to create, store, and share templates. Users can fetch these templates over internet (may need to make another repo for this).
Please note that PRs submitted without prior approval through an issue may be closed without merging. This process helps us manage feature requests effectively and ensures that contributions align with the project’s goals.
3 changes: 2 additions & 1 deletion cmd/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ var (
)

func init() {
addCmd.Flags().StringVar(&logic.LangFlg, "lang", "", "supported languages for git hooks")
addCmd.Flags().StringVar(&logic.Lang, "lang", "", "supported languages for git hooks")
rootCmd.AddCommand(addCmd)
}
17 changes: 0 additions & 17 deletions cmd/config/get.go

This file was deleted.

9 changes: 0 additions & 9 deletions cmd/config/main.go

This file was deleted.

19 changes: 0 additions & 19 deletions cmd/config/root.go

This file was deleted.

17 changes: 0 additions & 17 deletions cmd/config/set.go

This file was deleted.

4 changes: 3 additions & 1 deletion cmd/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ var (
}
)

func init() {}
func init() {
rootCmd.AddCommand(docCmd)
}
7 changes: 4 additions & 3 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ var (
initCmd = &cobra.Command{
Use: "init",
Short: "Initialize hkup",
Long: "Create an empty hkup directory or reinitialize an existing one",
Long: "Create an empty hkup folder or reinitialize an existing one",
Args: cobra.NoArgs,
RunE: logic.Init,
}
)

func init() {
initCmd.Flags().StringVar(&logic.GitDirFlg, "gitdir", "", "specified path to git directory")
initCmd.Flags().StringVar(&logic.WorkTreeFlg, "worktree", "", "specified path to working tree")
initCmd.Flags().StringVar(&logic.GitDir, "gitdir", "", "specified path to git directory")
initCmd.Flags().StringVar(&logic.WorkTree, "worktree", "", "specified path to working tree")
initCmd.MarkFlagsRequiredTogether("gitdir", "worktree")
rootCmd.AddCommand(initCmd)
}
4 changes: 3 additions & 1 deletion cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ var (
}
)

func init() {}
func init() {
rootCmd.AddCommand(listCmd)
}
4 changes: 3 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/*
Package cmd initializes all commands (including root command) for the HkUp CLI.
Additionally, the package holds all tests for commands.
*/
package cmd

// NOTE: This file is for documentation purposes and should be kept empty.
// Note: This file should be kept empty.
4 changes: 3 additions & 1 deletion cmd/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ var (
}
)

func init() {}
func init() {
rootCmd.AddCommand(removeCmd)
}
24 changes: 4 additions & 20 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,39 +1,23 @@
package cmd

import (
"github.com/iton0/hkup-cli/cmd/config"
"github.com/iton0/hkup-cli/cmd/template"
"github.com/spf13/cobra"
)

var (
// version holds the centralized version of HkUp.
// It is updated to the latest release version at build time of the binaries.
//
// INFO: look at the .github/workflows/release-please.yml to view how version
// is updated.
version = "dev"

rootCmd = &cobra.Command{
Use: "hkup",
Short: "hkup CLI",
Long: `hkup is a management tool for git hooks`,
Version: version,
Args: cobra.MinimumNArgs(1),
Version: "0.2.1",
}
)

func init() {
rootCmd.AddCommand(initCmd)
rootCmd.AddCommand(addCmd)
rootCmd.AddCommand(removeCmd)
rootCmd.AddCommand(template.RootCmd)
rootCmd.AddCommand(config.RootCmd)
rootCmd.AddCommand(docCmd)
rootCmd.AddCommand(listCmd)
}
func init() {}

// Execute serves as a wrapper for the Cobra API's Execute function,
// allowing it to be called from the [github.com/iton0/hkup-cli] package.
// allowing it to be called from the main package.
func Execute() {
rootCmd.Execute()
}
17 changes: 0 additions & 17 deletions cmd/template/copy.go

This file was deleted.

Loading

0 comments on commit 51b8b0f

Please sign in to comment.