From c09e1420bd6cda77bbbfdf526b2cb61187fc3ce6 Mon Sep 17 00:00:00 2001 From: noneandundefined Date: Tue, 12 Aug 2025 08:27:28 -0400 Subject: [PATCH 1/3] [refactor] Processed file - go.sum is refactored --- .github/workflows/release.yml | 10 ++++++++-- Help/www/index.html | 8 ++++++++ go.mod | 25 ++++++++++++++----------- go.sum | 35 +++++++++++++++++++---------------- 4 files changed, 49 insertions(+), 29 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 66fdbad..198b9a4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -39,12 +39,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 @@ -205,6 +203,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 diff --git a/Help/www/index.html b/Help/www/index.html index 9439637..d12ae38 100644 --- a/Help/www/index.html +++ b/Help/www/index.html @@ -139,6 +139,14 @@

Install

echo Y | bash <(curl -fsSL https://github.com/thefuture-industries/git-auto-commit/blob/main/scripts/install-linux-auto-commit.sh?raw=true) +

+ If you're on MacOS
+ Go to the root of the project and run the command: +

+
+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

diff --git a/go.mod b/go.mod index 33b4807..3b85a9a 100644 --- a/go.mod +++ b/go.mod @@ -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 +) diff --git a/go.sum b/go.sum index 8687ec0..f760fcf 100644 --- a/go.sum +++ b/go.sum @@ -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= From e8d0ee2735194778b8c80172bd2a0900b4b1f8f7 Mon Sep 17 00:00:00 2001 From: noneandundefined Date: Tue, 12 Aug 2025 08:36:27 -0400 Subject: [PATCH 2/3] [fix] Updated build scripts --- scripts/update-linux-auto-commit.sh | 4 ++-- scripts/update-macos-auto-commit.sh | 4 ++-- scripts/update-windows-auto-commit.ps1 | 5 ++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/scripts/update-linux-auto-commit.sh b/scripts/update-linux-auto-commit.sh index 137f208..45ed42d 100644 --- a/scripts/update-linux-auto-commit.sh +++ b/scripts/update-linux-auto-commit.sh @@ -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" @@ -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 diff --git a/scripts/update-macos-auto-commit.sh b/scripts/update-macos-auto-commit.sh index f05699c..67b0e77 100644 --- a/scripts/update-macos-auto-commit.sh +++ b/scripts/update-macos-auto-commit.sh @@ -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" @@ -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 \ No newline at end of file diff --git a/scripts/update-windows-auto-commit.ps1 b/scripts/update-windows-auto-commit.ps1 index 56eb846..f5ee190 100644 --- a/scripts/update-windows-auto-commit.ps1 +++ b/scripts/update-windows-auto-commit.ps1 @@ -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" @@ -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 From d17d34bf53afd37e0bff7b1d4dbedd41ad73bbb7 Mon Sep 17 00:00:00 2001 From: noneandundefined Date: Tue, 12 Aug 2025 09:04:54 -0400 Subject: [PATCH 3/3] added script check for delete \n\r windows --- .github/workflows/release.yml | 4 + Makefile | 7 ++ infra/logger/logger.go | 2 +- pkg/file/files.go | 6 +- pkg/git/types.go | 3 +- pkg/pkgerror/types.go | 2 +- scripts/install-linux-auto-commit.sh | 146 +++++++++++++-------------- version.md | 9 -- 8 files changed, 91 insertions(+), 88 deletions(-) delete mode 100644 version.md diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 198b9a4..87b2aef 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 diff --git a/Makefile b/Makefile index 87bcde4..5582943 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 diff --git a/infra/logger/logger.go b/infra/logger/logger.go index 141fd5c..36d1e11 100644 --- a/infra/logger/logger.go +++ b/infra/logger/logger.go @@ -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) } } diff --git a/pkg/file/files.go b/pkg/file/files.go index 9fc061c..86ed490 100644 --- a/pkg/file/files.go +++ b/pkg/file/files.go @@ -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 } @@ -18,7 +18,9 @@ func GetFilesInDir(directory string) []string { } return nil - }) + }); err != nil { + return []string{} + } return files } diff --git a/pkg/git/types.go b/pkg/git/types.go index 34abff7..ce3a38b 100644 --- a/pkg/git/types.go +++ b/pkg/git/types.go @@ -7,7 +7,7 @@ type GitInterface interface { GetDiff(file string) (string, error) GetStagedCountDirectory() (string, error) GetStagedFiles() ([]string, error) - + // commit.go Commit(commitMsg string) error @@ -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"` diff --git a/pkg/pkgerror/types.go b/pkg/pkgerror/types.go index eab2b68..0efdd55 100644 --- a/pkg/pkgerror/types.go +++ b/pkg/pkgerror/types.go @@ -1 +1 @@ -package pkgerror \ No newline at end of file +package pkgerror diff --git a/scripts/install-linux-auto-commit.sh b/scripts/install-linux-auto-commit.sh index 852e4d4..7b14841 100644 --- a/scripts/install-linux-auto-commit.sh +++ b/scripts/install-linux-auto-commit.sh @@ -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 diff --git a/version.md b/version.md deleted file mode 100644 index 87fabf4..0000000 --- a/version.md +++ /dev/null @@ -1,9 +0,0 @@ -## V3 - -[ ] HTML for git auto commit -[ ] CSS for git auto commit -[ ] TSX/JSX for git auto commit -[ ] Makefile for git auto commit -[ ] .md for git auto commit -[ ] .txt for git auto commit -[ ] .json for git auto commit \ No newline at end of file