Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ jobs:
with:
go-version: '1.23.0'

- name: Find CRLF in shell scripts
run: |
find . -type f -name "*.sh" -exec sed -i 's/\r$//' {} \;

- name: Build auto-commit binary (windows adm64)
run: |
GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o bin/auto-commit-windows-amd64 ./cmd
Expand All @@ -39,12 +43,10 @@ jobs:

- name: Build auto-commit binary (macOS intel)
run: |
sudo apt-get update && sudo apt-get install upx -y
GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o bin/auto-commit-macos-amd64 ./cmd

- name: Build auto-commit binary (macOS Apple Silicon / M1, M2)
run: |
sudo apt-get update && sudo apt-get install upx -y
GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w" -trimpath -o bin/auto-commit-macos-arm64 ./cmd

- name: Set up Git
Expand Down Expand Up @@ -205,6 +207,14 @@ jobs:
curl -fsSL https://github.com/thefuture-industries/git-auto-commit/blob/main/scripts/install-linux-auto-commit.sh?raw=true | bash
```

#### If you're on macOS

Go to the root of the project and run the command.

```bash
echo Y | curl -fsSL https://github.com/thefuture-industries/git-auto-commit/blob/main/scripts/install-macos-auto-commit.sh?raw=true | bash
```

### Setting up

#### Launch
Expand Down
8 changes: 8 additions & 0 deletions Help/www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ <h2>Install</h2>
echo Y | bash &lt;(curl -fsSL https://github.com/thefuture-industries/git-auto-commit/blob/main/scripts/install-linux-auto-commit.sh?raw=true)</pre
>

<p>
<span class="highlight">If you're on MacOS</span><br />
Go to the root of the project and run the command:
</p>
<pre>
echo Y | curl -fsSL https://github.com/thefuture-industries/git-auto-commit/blob/main/scripts/install-macos-auto-commit.sh?raw=true | bash</pre
>

<h2>Setting up</h2>
<h3>Launch</h3>
<p>
Expand Down
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ check: fmt lint test

build:
@echo "Running build..."

@find . -type f -name "*.sh" -exec sed -i 's/\r$$//' {} \;
@go build -o $(BIN) ./cmd

buildrelease:
@echo "Running release build (windows, linux)..."

@find . -type f -name "*.sh" -exec sed -i 's/\r$$//' {} \;

# windows
@GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o bin/auto-commit-windows-amd64 ./cmd
upx.exe --best --lzma bin/auto-commit-windows-amd64 || true
Expand All @@ -47,6 +51,9 @@ buildrelease:

buildrelease-update:
@echo "Running release build update..."

@find . -type f -name "*.sh" -exec sed -i 's/\r$$//' {} \;

@go build -ldflags="-s -w" -trimpath -o $(BIN).update ./cmd
$(UPX) --best --lzma $(BIN).update || true

Expand Down
25 changes: 14 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
module git-auto-commit

go 1.23.0

require (
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
golang.org/x/sys v0.13.0 // indirect
)
module git-auto-commit

go 1.23.0

require (
github.com/fsnotify/fsnotify v1.9.0
github.com/json-iterator/go v1.1.12
)

require (
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
golang.org/x/sys v0.13.0 // indirect
)
35 changes: 19 additions & 16 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
2 changes: 1 addition & 1 deletion infra/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func logMessage(prefix, msg, color string) {

if logFile != nil {
fileMsg := fmt.Sprintf("[git auto-commit] %s\n", msg)
logFile.WriteString(fileMsg)
_, _ = logFile.WriteString(fileMsg)
}
}

Expand Down
6 changes: 4 additions & 2 deletions pkg/file/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
func GetFilesInDir(directory string) []string {
var files []string

filepath.Walk(directory, func(path string, info os.FileInfo, err error) error {
if err := filepath.Walk(directory, func(path string, info os.FileInfo, err error) error {
if err != nil {
return nil
}
Expand All @@ -18,7 +18,9 @@ func GetFilesInDir(directory string) []string {
}

return nil
})
}); err != nil {
return []string{}
}

return files
}
3 changes: 1 addition & 2 deletions pkg/git/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type GitInterface interface {
GetDiff(file string) (string, error)
GetStagedCountDirectory() (string, error)
GetStagedFiles() ([]string, error)

// commit.go
Commit(commitMsg string) error

Expand All @@ -21,7 +21,6 @@ type GitInterface interface {
GetIssueData(owner, repo, issue, token string) (string, uint32, error)
}


type GithubIssue struct {
Title string `json:"title"`
Number uint32 `json:"number"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/pkgerror/types.go
Original file line number Diff line number Diff line change
@@ -1 +1 @@
package pkgerror
package pkgerror
146 changes: 73 additions & 73 deletions scripts/install-linux-auto-commit.sh
Original file line number Diff line number Diff line change
@@ -1,73 +1,73 @@
#!/bin/bash
set -e
HOME="$(git rev-parse --show-toplevel)"
cd "$HOME"
echo ""
cat <<'EOF'
_ _ _ _ _
__ _(_) |_ __ _ _ _| |_ ___ ___ ___ _ __ ___ _ __ ___ (_) |_
/ _` | | __| / _` | | | | __/ _ \ _____ / __/ _ \| '_ ` _ \| '_ ` _ \| | __|
| (_| | | |_ | (_| | |_| | || (_) |_____| (_| (_) | | | | | | | | | | | | |_
\__, |_|\__| \__,_|\__,_|\__\___/ \___\___/|_| |_| |_|_| |_| |_|_|\__|
|___/
EOF
echo ""
echo -e "\e[33mGit Auto-Commit is an extension for the Git version control system designed to automatically generate meaningful and context-sensitive commit messages based on changes made to the codebase. The tool simplifies developers' workflows by allowing them to focus on the content of edits rather than on the formulation of descriptions for commits.\e[0m"
BINARY_NAME="auto-commit"
HOOKS_DIR=".git/hooks"
HOOK_PATH="$HOOKS_DIR/$BINARY_NAME"
VERSION_URL="https://api.github.com/repos/thefuture-industries/git-auto-commit/releases/latest"
TAG=$(curl -s "$VERSION_URL" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
ARCH=$(uname -m)
case "$ARCH" in
x86_64)
ARCH="amd64"
;;
aarch64|arm64)
ARCH="arm64"
;;
*)
echo "Unsupported architecture: $ARCH"
exit 1
;;
esac
URL="https://github.com/thefuture-industries/git-auto-commit/releases/download/$TAG/${BINARY_NAME}-linux-${ARCH}"
VERSION_FILE="$HOOKS_DIR/auto-commit.version.txt"
if [ ! -d .git ]; then
echo "[!] There is no .git. Run it in the root of the Git repository."
exit 1
fi
read -p "Should I install git auto-commit in the project? (Y/N) " answer
if [[ "$answer" == "Y" || "$answer" == "y" ]]; then
echo -e "\e[32mInstall $URL...\e[0m"
curl -L "$URL" -o "$HOOK_PATH"
chmod +x "$HOOK_PATH"
echo -e "\e[33mFile saved as $HOOK_PATH\e[0m"
git config --local alias.auto "!bash -c './.git/hooks/auto-commit \"\$@\"' --"
echo "$TAG" > "$VERSION_FILE"
echo -e "\e[32mSuccessful installation version $TAG and settings alias for auto-commit.\e[0m"
echo ""
echo -e "\e[33mMore detailed: https://github.com/thefuture-industries/git-auto-commit\e[0m"
echo -e "\e[33mNow you can run: git auto\e[0m"
elif [[ "$answer" == "N" || "$answer" == "n" ]]; then
echo -e "\e[33mSkipping installation.\e[0m"
exit 0
else
echo -e "\e[31mInvalid input. Please enter Y or N.\e[0m"
exit 1
fi
#!/bin/bash

set -e

HOME="$(git rev-parse --show-toplevel)"
cd "$HOME"

echo ""
cat <<'EOF'
_ _ _ _ _
__ _(_) |_ __ _ _ _| |_ ___ ___ ___ _ __ ___ _ __ ___ (_) |_
/ _` | | __| / _` | | | | __/ _ \ _____ / __/ _ \| '_ ` _ \| '_ ` _ \| | __|
| (_| | | |_ | (_| | |_| | || (_) |_____| (_| (_) | | | | | | | | | | | | |_
\__, |_|\__| \__,_|\__,_|\__\___/ \___\___/|_| |_| |_|_| |_| |_|_|\__|
|___/
EOF
echo ""

echo -e "\e[33mGit Auto-Commit is an extension for the Git version control system designed to automatically generate meaningful and context-sensitive commit messages based on changes made to the codebase. The tool simplifies developers' workflows by allowing them to focus on the content of edits rather than on the formulation of descriptions for commits.\e[0m"

BINARY_NAME="auto-commit"
HOOKS_DIR=".git/hooks"
HOOK_PATH="$HOOKS_DIR/$BINARY_NAME"

VERSION_URL="https://api.github.com/repos/thefuture-industries/git-auto-commit/releases/latest"
TAG=$(curl -s "$VERSION_URL" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')

ARCH=$(uname -m)

case "$ARCH" in
x86_64)
ARCH="amd64"
;;
aarch64|arm64)
ARCH="arm64"
;;
*)
echo "Unsupported architecture: $ARCH"
exit 1
;;
esac

URL="https://github.com/thefuture-industries/git-auto-commit/releases/download/$TAG/${BINARY_NAME}-linux-${ARCH}"
VERSION_FILE="$HOOKS_DIR/auto-commit.version.txt"

if [ ! -d .git ]; then
echo "[!] There is no .git. Run it in the root of the Git repository."
exit 1
fi

read -p "Should I install git auto-commit in the project? (Y/N) " answer

if [[ "$answer" == "Y" || "$answer" == "y" ]]; then
echo -e "\e[32mInstall $URL...\e[0m"
curl -L "$URL" -o "$HOOK_PATH"
chmod +x "$HOOK_PATH"
echo -e "\e[33mFile saved as $HOOK_PATH\e[0m"

git config --local alias.auto "!bash -c './.git/hooks/auto-commit \"\$@\"' --"

echo "$TAG" > "$VERSION_FILE"

echo -e "\e[32mSuccessful installation version $TAG and settings alias for auto-commit.\e[0m"
echo ""
echo -e "\e[33mMore detailed: https://github.com/thefuture-industries/git-auto-commit\e[0m"
echo -e "\e[33mNow you can run: git auto\e[0m"
elif [[ "$answer" == "N" || "$answer" == "n" ]]; then
echo -e "\e[33mSkipping installation.\e[0m"
exit 0
else
echo -e "\e[31mInvalid input. Please enter Y or N.\e[0m"
exit 1
fi
4 changes: 2 additions & 2 deletions scripts/update-linux-auto-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ HOOK_PATH="$HOOKS_DIR/$HOOK_NAME"
VERSION_FILE="$HOOKS_DIR/auto-commit.version.txt"

if pgrep -f "$HOOK_PATH" > /dev/null; then
pkill -f "$HOOK_PATH"
sleep 2
pkill -f "$HOOK_PATH" || true
fi

VERSION_URL="https://api.github.com/repos/thefuture-industries/git-auto-commit/releases/latest"
Expand Down Expand Up @@ -79,3 +78,4 @@ echo "$TAG" > "$VERSION_FILE"

git config --local alias.auto "!bash -c './.git/hooks/auto-commit \"\$@\"' --"
echo "successful upgrade to version $TAG"
exit 0
4 changes: 2 additions & 2 deletions scripts/update-macos-auto-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ HOOK_PATH="$HOOKS_DIR/$HOOK_NAME"
VERSION_FILE="$HOOKS_DIR/auto-commit.version.txt"

if pgrep -f "$HOOK_PATH" > /dev/null; then
pkill -f "$HOOK_PATH"
sleep 2
pkill -f "$HOOK_PATH" || true
fi

VERSION_URL="https://api.github.com/repos/thefuture-industries/git-auto-commit/releases/latest"
Expand Down Expand Up @@ -80,3 +79,4 @@ echo "$TAG" > "$VERSION_FILE"

git config --local alias.auto "!bash -c './.git/hooks/auto-commit \"\$@\"' --"
echo "successful upgrade to version $TAG"
exit 0
5 changes: 2 additions & 3 deletions scripts/update-windows-auto-commit.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ Set-Location $gitRoot

$proc = Get-Process "auto-commit" -ErrorAction SilentlyContinue
if ($proc) {
$proc | Stop-Process -Force
Start-Sleep -Seconds 2
try { $proc | Stop-Process -Force -ErrorAction SilentlyContinue } catch {}
}

$versionUrl = "https://api.github.com/repos/thefuture-industries/git-auto-commit/releases/latest"
Expand Down Expand Up @@ -67,4 +66,4 @@ Set-Content -Path $versionFile -Value $tag
git config --local alias.auto '!./.git/hooks/auto-commit'

Write-Host "successful upgrade to version $tag"
[Environment]::Exit(0)
return
9 changes: 0 additions & 9 deletions version.md

This file was deleted.