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
2 changes: 1 addition & 1 deletion define.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "time"
const (
MAX_LINE_LENGTH uint16 = 1024
MAX_COMMIT_LENGTH uint16 = 300
MAX_COMMIT_LENGTH_WATCHER uint16 = 45
MAX_COMMIT_LENGTH_WATCHER uint16 = 25
COMMIT_TIME time.Duration = 15 * time.Second

GITHUB_API_REPO_URL string = "https://api.github.com/repos/thefuture-industries/git-auto-commit"
Expand Down
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func main() {

WatchCommit(path)
} else if len(os.Args) > 1 && (os.Args[1] == "-v" || os.Args[1] == "--version") {
GetVersion()
GetVersion(true)
} else if len(os.Args) > 1 && (os.Args[1] == "-u" || os.Args[1] == "--update") {
AutoCommitUpdate()
} else {
Expand All @@ -28,6 +28,8 @@ func main() {
}

func AutoCommit() {
GetVersion(false)

files, err := GetStagedFiles()
if err != nil {
ErrorLogger(fmt.Errorf("error getting staged files: %s", err.Error()))
Expand Down
6 changes: 4 additions & 2 deletions version.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"
)

func GetVersion() {
func GetVersion(isCurrent bool) {
root, err := GetGitRoot()
if err != nil {
ErrorLogger(fmt.Errorf("could not get git root: %w", err))
Expand All @@ -23,7 +23,9 @@ func GetVersion() {
return
}

fmt.Println("[git auto-commit] current version:", strings.TrimSpace(string(version)))
if isCurrent {
fmt.Println("[git auto-commit] current version:", strings.TrimSpace(string(version)))
}

resp, err := http.Get(GITHUB_API_REPO_URL + "/releases/latest")
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
)

func WatchCommit(path string) {
GetVersion(false)

watcher, err := fsnotify.NewWatcher()
if err != nil {
ErrorLogger(err)
Expand Down