From ee50a1ce0e64864feed8c6628161a3afe5c9d9b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:02:40 +0500 Subject: [PATCH 001/207] added function TestAutoCommit_NoStagedFiles | included 'testing' in auto_commit_test.go | the 'LGPL-2' file has been changed --- LGPL-2.1 => LGPL-2 | 0 tests/auto_commit_test.go | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+) rename LGPL-2.1 => LGPL-2 (100%) create mode 100644 tests/auto_commit_test.go diff --git a/LGPL-2.1 b/LGPL-2 similarity index 100% rename from LGPL-2.1 rename to LGPL-2 diff --git a/tests/auto_commit_test.go b/tests/auto_commit_test.go new file mode 100644 index 0000000..234ae23 --- /dev/null +++ b/tests/auto_commit_test.go @@ -0,0 +1,20 @@ +package tests + +import ( + "testing" +) + +var ( + getStagedFilesMock func() ([]string, error) + parserMock func([]string) (string, error) + commitMock func(string) error + errorLoggerMock func(error) + infoLoggerMock func(string) + getVersionMock func(bool) +) + +func TestAutoCommit_NoStagedFiles(t *testing.T) { + getStagedFilesMock = func() ([]string, error) { return []string{}, nil } + + main.AutoCommit() +} From d52b91feb6a9742576062d5838befee4ae3a96bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:03:02 +0500 Subject: [PATCH 002/207] changed the 'v2.12.x' branch --- tests/auto_commit_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto_commit_test.go b/tests/auto_commit_test.go index 234ae23..705887c 100644 --- a/tests/auto_commit_test.go +++ b/tests/auto_commit_test.go @@ -15,6 +15,7 @@ var ( func TestAutoCommit_NoStagedFiles(t *testing.T) { getStagedFilesMock = func() ([]string, error) { return []string{}, nil } + parserMock main.AutoCommit() } From d40f6400615fad75f0ff08c5da594cd000d6a332 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:03:19 +0500 Subject: [PATCH 003/207] changed the 'v2.12.x' branch --- tests/auto_commit_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto_commit_test.go b/tests/auto_commit_test.go index 705887c..679fff0 100644 --- a/tests/auto_commit_test.go +++ b/tests/auto_commit_test.go @@ -15,7 +15,7 @@ var ( func TestAutoCommit_NoStagedFiles(t *testing.T) { getStagedFilesMock = func() ([]string, error) { return []string{}, nil } - parserMock + parserMock = func(files []string) (string, error) main.AutoCommit() } From be44d79e938d5489c87167a611a144e97d901b89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:03:34 +0500 Subject: [PATCH 004/207] changed the 'v2.12.x' branch --- tests/auto_commit_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/auto_commit_test.go b/tests/auto_commit_test.go index 679fff0..75eafa8 100644 --- a/tests/auto_commit_test.go +++ b/tests/auto_commit_test.go @@ -15,7 +15,8 @@ var ( func TestAutoCommit_NoStagedFiles(t *testing.T) { getStagedFilesMock = func() ([]string, error) { return []string{}, nil } - parserMock = func(files []string) (string, error) + parserMock = func(files []string) (string, error) { return "", nil } + commitMock = func(string) error main.AutoCommit() } From 3a8c057fa476957f6adc09b8e237a38f8cadc0d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:03:50 +0500 Subject: [PATCH 005/207] changed the 'v2.12.x' branch --- tests/auto_commit_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto_commit_test.go b/tests/auto_commit_test.go index 75eafa8..7fec548 100644 --- a/tests/auto_commit_test.go +++ b/tests/auto_commit_test.go @@ -16,7 +16,7 @@ var ( func TestAutoCommit_NoStagedFiles(t *testing.T) { getStagedFilesMock = func() ([]string, error) { return []string{}, nil } parserMock = func(files []string) (string, error) { return "", nil } - commitMock = func(string) error + commitMock = func(msg string) error { return nil } main.AutoCommit() } From b944e598993cba91402904fa35457fdf75601d56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:04:06 +0500 Subject: [PATCH 006/207] changed the 'v2.12.x' branch --- tests/auto_commit_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto_commit_test.go b/tests/auto_commit_test.go index 7fec548..90b37a3 100644 --- a/tests/auto_commit_test.go +++ b/tests/auto_commit_test.go @@ -17,6 +17,7 @@ func TestAutoCommit_NoStagedFiles(t *testing.T) { getStagedFilesMock = func() ([]string, error) { return []string{}, nil } parserMock = func(files []string) (string, error) { return "", nil } commitMock = func(msg string) error { return nil } + errorLoggerMock = func(err string) { t.Errorf()} main.AutoCommit() } From df47c719a26d803e73464f7d320ea24c1bd6397c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:04:23 +0500 Subject: [PATCH 007/207] changed the 'v2.12.x' branch --- tests/auto_commit_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto_commit_test.go b/tests/auto_commit_test.go index 90b37a3..d046e5b 100644 --- a/tests/auto_commit_test.go +++ b/tests/auto_commit_test.go @@ -17,7 +17,7 @@ func TestAutoCommit_NoStagedFiles(t *testing.T) { getStagedFilesMock = func() ([]string, error) { return []string{}, nil } parserMock = func(files []string) (string, error) { return "", nil } commitMock = func(msg string) error { return nil } - errorLoggerMock = func(err string) { t.Errorf()} + errorLoggerMock = func(err error) { t.Errorf("unexpected error: %v", err) } main.AutoCommit() } From f51e05e1541bacb037d0e236f325f95b64b80960 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:04:39 +0500 Subject: [PATCH 008/207] changed the 'v2.12.x' branch --- tests/auto_commit_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto_commit_test.go b/tests/auto_commit_test.go index d046e5b..56478e9 100644 --- a/tests/auto_commit_test.go +++ b/tests/auto_commit_test.go @@ -18,6 +18,7 @@ func TestAutoCommit_NoStagedFiles(t *testing.T) { parserMock = func(files []string) (string, error) { return "", nil } commitMock = func(msg string) error { return nil } errorLoggerMock = func(err error) { t.Errorf("unexpected error: %v", err) } + infoLoggerMock = main.AutoCommit() } From e0bcf618e0dc8a646f50cd7bff0a4c462ae5e31f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:04:55 +0500 Subject: [PATCH 009/207] changed the 'v2.12.x' branch --- tests/auto_commit_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto_commit_test.go b/tests/auto_commit_test.go index 56478e9..2fbd235 100644 --- a/tests/auto_commit_test.go +++ b/tests/auto_commit_test.go @@ -18,7 +18,7 @@ func TestAutoCommit_NoStagedFiles(t *testing.T) { parserMock = func(files []string) (string, error) { return "", nil } commitMock = func(msg string) error { return nil } errorLoggerMock = func(err error) { t.Errorf("unexpected error: %v", err) } - infoLoggerMock = + infoLoggerMock = func(msg string) { calledInfo = msg } main.AutoCommit() } From def8157c6620e018989b9c4dfa7b3620d59e172c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:05:11 +0500 Subject: [PATCH 010/207] added variable calledInfo --- tests/auto_commit_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto_commit_test.go b/tests/auto_commit_test.go index 2fbd235..d6e4c88 100644 --- a/tests/auto_commit_test.go +++ b/tests/auto_commit_test.go @@ -14,6 +14,8 @@ var ( ) func TestAutoCommit_NoStagedFiles(t *testing.T) { + calledInfo := "" + getStagedFilesMock = func() ([]string, error) { return []string{}, nil } parserMock = func(files []string) (string, error) { return "", nil } commitMock = func(msg string) error { return nil } From a8aadb89fc0bda0bef917480430741253c2c1916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:05:27 +0500 Subject: [PATCH 011/207] added condition logic: calledInfo --- tests/auto_commit_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/auto_commit_test.go b/tests/auto_commit_test.go index d6e4c88..e4a6e35 100644 --- a/tests/auto_commit_test.go +++ b/tests/auto_commit_test.go @@ -15,12 +15,15 @@ var ( func TestAutoCommit_NoStagedFiles(t *testing.T) { calledInfo := "" - + getStagedFilesMock = func() ([]string, error) { return []string{}, nil } parserMock = func(files []string) (string, error) { return "", nil } commitMock = func(msg string) error { return nil } errorLoggerMock = func(err error) { t.Errorf("unexpected error: %v", err) } infoLoggerMock = func(msg string) { calledInfo = msg } + getVersionMock = func(show bool) {} main.AutoCommit() + + if calledInfo } From cd9bc2eed4d3486c184dca21c9f629c77259b2a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:05:43 +0500 Subject: [PATCH 012/207] changed the 'v2.12.x' branch --- tests/auto_commit_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/auto_commit_test.go b/tests/auto_commit_test.go index e4a6e35..d41c763 100644 --- a/tests/auto_commit_test.go +++ b/tests/auto_commit_test.go @@ -25,5 +25,7 @@ func TestAutoCommit_NoStagedFiles(t *testing.T) { main.AutoCommit() - if calledInfo + if calledInfo != "No files staged for commit." { + t.Errorf("") + } } From c54b7ebd80a1c1151763218221af9bdbe3e56493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:05:59 +0500 Subject: [PATCH 013/207] changed the 'v2.12.x' branch --- tests/auto_commit_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/auto_commit_test.go b/tests/auto_commit_test.go index d41c763..8f078a2 100644 --- a/tests/auto_commit_test.go +++ b/tests/auto_commit_test.go @@ -2,6 +2,7 @@ package tests import ( "testing" + "git-auto-commit" ) var ( @@ -26,6 +27,6 @@ func TestAutoCommit_NoStagedFiles(t *testing.T) { main.AutoCommit() if calledInfo != "No files staged for commit." { - t.Errorf("") + t.Errorf("expected info log 'No files staged for commit.', got '%s'", calledInfo) } } From 3fce71ebc28bbaded16c8a653a9d7c4b5411a1f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:06:49 +0500 Subject: [PATCH 014/207] changed the 'v2.12.x' branch --- tests/auto_commit_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto_commit_test.go b/tests/auto_commit_test.go index 8f078a2..fe35495 100644 --- a/tests/auto_commit_test.go +++ b/tests/auto_commit_test.go @@ -2,7 +2,7 @@ package tests import ( "testing" - "git-auto-commit" + main "git-auto-commit" ) var ( From 15df2100bff1db1ef0acb23fa01dd526bc3f557a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:07:15 +0500 Subject: [PATCH 015/207] changed the 'v2.12.x' branch --- tests/auto_commit_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto_commit_test.go b/tests/auto_commit_test.go index fe35495..8f078a2 100644 --- a/tests/auto_commit_test.go +++ b/tests/auto_commit_test.go @@ -2,7 +2,7 @@ package tests import ( "testing" - main "git-auto-commit" + "git-auto-commit" ) var ( From a030644e9cb09a5b40a1c0b7ca4c75643d2ca668 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:08:00 +0500 Subject: [PATCH 016/207] changed the 'v2.12.x' branch --- tests/auto_commit_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto_commit_test.go b/tests/auto_commit_test.go index 8f078a2..f555a18 100644 --- a/tests/auto_commit_test.go +++ b/tests/auto_commit_test.go @@ -2,7 +2,7 @@ package tests import ( "testing" - "git-auto-commit" + "main" ) var ( From 5214e2061688f625f30a2878f9b21a8adc3d5844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:13:56 +0500 Subject: [PATCH 017/207] added variable calledInfo | added function TestAutoCommit_NoStagedFiles | if calledInfo is not equal to No files staged for commit." | included 'testing' in auto_commit_test.go --- tests/auto_commit_test.go => auto_commit_test.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) rename tests/auto_commit_test.go => auto_commit_test.go (95%) diff --git a/tests/auto_commit_test.go b/auto_commit_test.go similarity index 95% rename from tests/auto_commit_test.go rename to auto_commit_test.go index f555a18..57fd7fd 100644 --- a/tests/auto_commit_test.go +++ b/auto_commit_test.go @@ -1,8 +1,7 @@ -package tests +package main import ( "testing" - "main" ) var ( @@ -24,7 +23,7 @@ func TestAutoCommit_NoStagedFiles(t *testing.T) { infoLoggerMock = func(msg string) { calledInfo = msg } getVersionMock = func(show bool) {} - main.AutoCommit() + AutoCommit() if calledInfo != "No files staged for commit." { t.Errorf("expected info log 'No files staged for commit.', got '%s'", calledInfo) From cce254548403e183b9351e686a0a9de12913f16a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:14:42 +0500 Subject: [PATCH 018/207] changed the 'v2.12.x' branch --- auto_commit_test.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/auto_commit_test.go b/auto_commit_test.go index 57fd7fd..ce7e54f 100644 --- a/auto_commit_test.go +++ b/auto_commit_test.go @@ -14,14 +14,12 @@ var ( ) func TestAutoCommit_NoStagedFiles(t *testing.T) { - calledInfo := "" - - getStagedFilesMock = func() ([]string, error) { return []string{}, nil } - parserMock = func(files []string) (string, error) { return "", nil } - commitMock = func(msg string) error { return nil } - errorLoggerMock = func(err error) { t.Errorf("unexpected error: %v", err) } - infoLoggerMock = func(msg string) { calledInfo = msg } - getVersionMock = func(show bool) {} + GetStagedFiles = func() ([]string, error) { return getStagedFilesMock() } + Parser = func(files []string) (string, error) { return parserMock(files) } + Commit = func(msg string) error { return commitMock(msg) } + ErrorLogger = func(err error) { errorLoggerMock(err) } + InfoLogger = func(msg string) { infoLoggerMock(msg) } + GetVersion = func(show bool) { getVersionMock(show) } AutoCommit() From 1b7b5dce11a6aea459ce55cf1daa09839f0b6146 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:15:36 +0500 Subject: [PATCH 019/207] if msg is not equal to No files staged for commit." --- auto_commit_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/auto_commit_test.go b/auto_commit_test.go index ce7e54f..5316fe9 100644 --- a/auto_commit_test.go +++ b/auto_commit_test.go @@ -21,7 +21,12 @@ func TestAutoCommit_NoStagedFiles(t *testing.T) { InfoLogger = func(msg string) { infoLoggerMock(msg) } GetVersion = func(show bool) { getVersionMock(show) } - AutoCommit() + getStagedFilesMock = func() ([]string, error) { return []string{}, nil } + infoLoggerMock = func(msg string) { + if msg != "No files staged for commit." { + t.Errorf("unexpected info log: %s", msg) + } + } if calledInfo != "No files staged for commit." { t.Errorf("expected info log 'No files staged for commit.', got '%s'", calledInfo) From 029a0407a8fded6c875cd1e2758965b2a21c1a02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:15:52 +0500 Subject: [PATCH 020/207] changed the 'v2.12.x' branch --- auto_commit_test.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/auto_commit_test.go b/auto_commit_test.go index 5316fe9..2971ff0 100644 --- a/auto_commit_test.go +++ b/auto_commit_test.go @@ -28,7 +28,6 @@ func TestAutoCommit_NoStagedFiles(t *testing.T) { } } - if calledInfo != "No files staged for commit." { - t.Errorf("expected info log 'No files staged for commit.', got '%s'", calledInfo) - } + errorLoggerMock = func(err error) { t.Errorf("unexpected error: %v", err) } + AutoCommit() } From 443f0a597b213c2581139b3be729e97ce10ee847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:16:47 +0500 Subject: [PATCH 021/207] changed the 'v2.12.x' branch --- auto_commit_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/auto_commit_test.go b/auto_commit_test.go index 2971ff0..0ec5d48 100644 --- a/auto_commit_test.go +++ b/auto_commit_test.go @@ -21,6 +21,8 @@ func TestAutoCommit_NoStagedFiles(t *testing.T) { InfoLogger = func(msg string) { infoLoggerMock(msg) } GetVersion = func(show bool) { getVersionMock(show) } + GetStagedFiles() + getStagedFilesMock = func() ([]string, error) { return []string{}, nil } infoLoggerMock = func(msg string) { if msg != "No files staged for commit." { From 61ae439b49bd111af406446a06f0f8d2255257a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:17:05 +0500 Subject: [PATCH 022/207] changed the 'v2.12.x' branch --- diff.go | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/diff.go b/diff.go index ba71fba..871442a 100644 --- a/diff.go +++ b/diff.go @@ -41,7 +41,35 @@ func GetDiff(file string) (string, error) { return buf.String(), nil } -func GetStagedFiles() ([]string, error) { +// func GetStagedFiles() ([]string, error) { +// cmd := exec.Command("git", "diff", "--cached", "--name-only") + +// stdout, err := cmd.StdoutPipe() +// if err != nil { +// return nil, err +// } + +// if err := cmd.Start(); err != nil { +// return nil, err +// } + +// var files []string +// scanner := bufio.NewScanner(stdout) +// for scanner.Scan() { +// files = append(files, scanner.Text()) +// } + +// if err := scanner.Err(); err != nil { +// return nil, err +// } + +// if err := cmd.Wait(); err != nil { +// return nil, err +// } + +// return files, nil +// } +var GetStagedFiles = func () ([]string, error) { cmd := exec.Command("git", "diff", "--cached", "--name-only") stdout, err := cmd.StdoutPipe() From 7a7dbd606275514b5cb05f21d1010bfa11dd00b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:17:23 +0500 Subject: [PATCH 023/207] changed the 'v2.12.x' branch --- auto_commit_test.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/auto_commit_test.go b/auto_commit_test.go index 0ec5d48..2971ff0 100644 --- a/auto_commit_test.go +++ b/auto_commit_test.go @@ -21,8 +21,6 @@ func TestAutoCommit_NoStagedFiles(t *testing.T) { InfoLogger = func(msg string) { infoLoggerMock(msg) } GetVersion = func(show bool) { getVersionMock(show) } - GetStagedFiles() - getStagedFilesMock = func() ([]string, error) { return []string{}, nil } infoLoggerMock = func(msg string) { if msg != "No files staged for commit." { From 2ad96b3ac544a6bdaba422b3b71606b1d3381c4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:18:30 +0500 Subject: [PATCH 024/207] changed the 'v2.12.x' branch --- auto_commit_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/auto_commit_test.go b/auto_commit_test.go index 2971ff0..a79fb60 100644 --- a/auto_commit_test.go +++ b/auto_commit_test.go @@ -21,6 +21,8 @@ func TestAutoCommit_NoStagedFiles(t *testing.T) { InfoLogger = func(msg string) { infoLoggerMock(msg) } GetVersion = func(show bool) { getVersionMock(show) } + Зфкыук() + getStagedFilesMock = func() ([]string, error) { return []string{}, nil } infoLoggerMock = func(msg string) { if msg != "No files staged for commit." { From bf95b222344f28477dc694a07efb97f4e7500479 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:18:47 +0500 Subject: [PATCH 025/207] changed the 'v2.12.x' branch --- auto_commit_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/auto_commit_test.go b/auto_commit_test.go index a79fb60..e6b6254 100644 --- a/auto_commit_test.go +++ b/auto_commit_test.go @@ -21,7 +21,11 @@ func TestAutoCommit_NoStagedFiles(t *testing.T) { InfoLogger = func(msg string) { infoLoggerMock(msg) } GetVersion = func(show bool) { getVersionMock(show) } - Зфкыук() + Parser() + Commit() + ErrorLogger() + InfoLogger() + GetVersion() getStagedFilesMock = func() ([]string, error) { return []string{}, nil } infoLoggerMock = func(msg string) { From b02e6131eee896b90296088ff137760b93984bf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:19:05 +0500 Subject: [PATCH 026/207] renamed function appendMsg -> AppendMsg --- parser.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/parser.go b/parser.go index b070413..a5ddade 100644 --- a/parser.go +++ b/parser.go @@ -7,7 +7,7 @@ import ( "sync" ) -func appendMsg(commitMsg, addition string) string { +func AppendMsg(commitMsg, addition string) string { var builder strings.Builder builder.Reset() @@ -21,7 +21,7 @@ func appendMsg(commitMsg, addition string) string { return builder.String() } -func Parser(files []string) (string, error) { +var Parser = func(files []string) (string, error) { var ( payloadMsg string mu sync.Mutex @@ -54,7 +54,7 @@ func Parser(files []string) (string, error) { lang := DetectLanguage(file) if lang == "" { mu.Lock() - payloadMsg = appendMsg(payloadMsg, fmt.Sprintf("the '%s' file has been changed", filepath.Base(file))) + payloadMsg = AppendMsg(payloadMsg, fmt.Sprintf("the '%s' file has been changed", filepath.Base(file))) mu.Unlock() continue // README.md, etc. } From c434ceee431cd3d5f61313af055553194cd2407a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:19:22 +0500 Subject: [PATCH 027/207] changed value in variable nextMsg --- commit.go | 2 +- parser.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/commit.go b/commit.go index 74d3b7b..9cdfc61 100644 --- a/commit.go +++ b/commit.go @@ -6,7 +6,7 @@ import ( "os/exec" ) -func Commit(commitMsg string) error { +var Commit = func(commitMsg string) error { GitLogger(fmt.Sprintf("commit is: %s", commitMsg)) cmd := exec.Command("git", "commit", "-m", commitMsg) diff --git a/parser.go b/parser.go index a5ddade..a027065 100644 --- a/parser.go +++ b/parser.go @@ -79,7 +79,7 @@ var Parser = func(files []string) (string, error) { if len(fileChanges) > 0 { mu.Lock() for _, change := range fileChanges { - nextMsg := appendMsg(payloadMsg, change) + nextMsg := AppendMsg(payloadMsg, change) if len(nextMsg) > int(MAX_COMMIT_LENGTH) { if len(payloadMsg) == 0 { if len(change) > int(MAX_COMMIT_LENGTH) { @@ -126,9 +126,9 @@ var Parser = func(files []string) (string, error) { } if formattedByRemote != "" { - payloadMsg = appendMsg(payloadMsg, formattedByRemote) + payloadMsg = AppendMsg(payloadMsg, formattedByRemote) } else { - payloadMsg = appendMsg(payloadMsg, formattedByBranch) + payloadMsg = AppendMsg(payloadMsg, formattedByBranch) } } From fbf86976d689524ce4bf27079fc8fced15ec60a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:19:41 +0500 Subject: [PATCH 028/207] changed the 'v2.12.x' branch --- logger.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/logger.go b/logger.go index 73a9efe..51a06d2 100644 --- a/logger.go +++ b/logger.go @@ -13,7 +13,7 @@ func InfoLogger(msg string) { fmt.Println(builder.String()) } -func GitLogger(msg string) { +var GitLogger = func GitLogger(msg string) { var builder strings.Builder builder.Reset() builder.WriteString("\033[0;34m[git auto-commit] ") @@ -22,7 +22,7 @@ func GitLogger(msg string) { fmt.Print(builder.String()) } -func ErrorLogger(err error) { +var ErrorLogger = func(err error) { var builder strings.Builder builder.Reset() builder.WriteString("\033[0;31m[git auto-commit] ") From 44a2422a2231356bd9c95072113b1982a70b53cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:19:58 +0500 Subject: [PATCH 029/207] changed the 'v2.12.x' branch --- logger.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/logger.go b/logger.go index 51a06d2..d9e0ab4 100644 --- a/logger.go +++ b/logger.go @@ -5,7 +5,7 @@ import ( "strings" ) -func InfoLogger(msg string) { +var InfoLogger = func(msg string) { var builder strings.Builder builder.Reset() builder.WriteString("[git auto-commit] ") @@ -13,7 +13,7 @@ func InfoLogger(msg string) { fmt.Println(builder.String()) } -var GitLogger = func GitLogger(msg string) { +var GitLogger = func(msg string) { var builder strings.Builder builder.Reset() builder.WriteString("\033[0;34m[git auto-commit] ") From 5cdc9501fbd7807c27dcc1bb131e9b69e8688aac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:20:14 +0500 Subject: [PATCH 030/207] changed the 'v2.12.x' branch --- auto_commit_test.go | 6 ------ version.go | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/auto_commit_test.go b/auto_commit_test.go index e6b6254..2971ff0 100644 --- a/auto_commit_test.go +++ b/auto_commit_test.go @@ -21,12 +21,6 @@ func TestAutoCommit_NoStagedFiles(t *testing.T) { InfoLogger = func(msg string) { infoLoggerMock(msg) } GetVersion = func(show bool) { getVersionMock(show) } - Parser() - Commit() - ErrorLogger() - InfoLogger() - GetVersion() - getStagedFilesMock = func() ([]string, error) { return []string{}, nil } infoLoggerMock = func(msg string) { if msg != "No files staged for commit." { diff --git a/version.go b/version.go index f13c0d5..d8296e4 100644 --- a/version.go +++ b/version.go @@ -8,7 +8,7 @@ import ( "strings" ) -func GetVersion(isCurrent bool) { +var GetVersion = func(isCurrent bool) { root, err := GetGitRoot() if err != nil { ErrorLogger(fmt.Errorf("could not get git root: %w", err)) From 803b29af690b016522e1e9ae97e052eade7718e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:21:28 +0500 Subject: [PATCH 031/207] added variable calledInfo --- auto_commit_test.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/auto_commit_test.go b/auto_commit_test.go index 2971ff0..aa50c4f 100644 --- a/auto_commit_test.go +++ b/auto_commit_test.go @@ -14,12 +14,13 @@ var ( ) func TestAutoCommit_NoStagedFiles(t *testing.T) { - GetStagedFiles = func() ([]string, error) { return getStagedFilesMock() } - Parser = func(files []string) (string, error) { return parserMock(files) } - Commit = func(msg string) error { return commitMock(msg) } - ErrorLogger = func(err error) { errorLoggerMock(err) } - InfoLogger = func(msg string) { infoLoggerMock(msg) } - GetVersion = func(show bool) { getVersionMock(show) } + GetStagedFiles = func() ([]string, error) { return []string{}, nil } + Parser = func(files []string) (string, error) { return "", nil } + Commit = func(msg string) error { return nil } + ErrorLogger = func(err error) { t.Errorf("unexpected error: %v", err) } + calledInfo := "" + InfoLogger = func(msg string) { calledInfo = msg } + GetVersion = func(show bool) {} getStagedFilesMock = func() ([]string, error) { return []string{}, nil } infoLoggerMock = func(msg string) { From b20d2f5009773eb96cfb97eee4fab0e82e396fc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:21:45 +0500 Subject: [PATCH 032/207] added variable calledInfo --- auto_commit_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/auto_commit_test.go b/auto_commit_test.go index aa50c4f..949f7a4 100644 --- a/auto_commit_test.go +++ b/auto_commit_test.go @@ -14,11 +14,12 @@ var ( ) func TestAutoCommit_NoStagedFiles(t *testing.T) { + calledInfo := "" + GetStagedFiles = func() ([]string, error) { return []string{}, nil } Parser = func(files []string) (string, error) { return "", nil } Commit = func(msg string) error { return nil } ErrorLogger = func(err error) { t.Errorf("unexpected error: %v", err) } - calledInfo := "" InfoLogger = func(msg string) { calledInfo = msg } GetVersion = func(show bool) {} From 979f3388498dfa4c2ccbd14b42c31a7b9a5b314f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:22:00 +0500 Subject: [PATCH 033/207] changed the 'v2.12.x' branch --- auto_commit_test.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/auto_commit_test.go b/auto_commit_test.go index 949f7a4..0b2e50e 100644 --- a/auto_commit_test.go +++ b/auto_commit_test.go @@ -15,7 +15,7 @@ var ( func TestAutoCommit_NoStagedFiles(t *testing.T) { calledInfo := "" - + GetStagedFiles = func() ([]string, error) { return []string{}, nil } Parser = func(files []string) (string, error) { return "", nil } Commit = func(msg string) error { return nil } @@ -23,13 +23,9 @@ func TestAutoCommit_NoStagedFiles(t *testing.T) { InfoLogger = func(msg string) { calledInfo = msg } GetVersion = func(show bool) {} - getStagedFilesMock = func() ([]string, error) { return []string{}, nil } - infoLoggerMock = func(msg string) { - if msg != "No files staged for commit." { - t.Errorf("unexpected info log: %s", msg) - } - } - - errorLoggerMock = func(err error) { t.Errorf("unexpected error: %v", err) } AutoCommit() + + if calledInfo != "No files staged for commit." { + t.Errorf("expected info log 'No files staged for commit.', got '%s'", calledInfo) + } } From 1f76696287957b6ba3513bc49c85b1a8f5e64c99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:22:43 +0500 Subject: [PATCH 034/207] changed the 'v2.12.x' branch --- auto_commit_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/auto_commit_test.go b/auto_commit_test.go index 0b2e50e..99f680d 100644 --- a/auto_commit_test.go +++ b/auto_commit_test.go @@ -4,14 +4,14 @@ import ( "testing" ) -var ( - getStagedFilesMock func() ([]string, error) - parserMock func([]string) (string, error) - commitMock func(string) error - errorLoggerMock func(error) - infoLoggerMock func(string) - getVersionMock func(bool) -) +// var ( +// getStagedFilesMock func() ([]string, error) +// parserMock func([]string) (string, error) +// commitMock func(string) error +// errorLoggerMock func(error) +// infoLoggerMock func(string) +// getVersionMock func(bool) +// ) func TestAutoCommit_NoStagedFiles(t *testing.T) { calledInfo := "" From 1587f6c9d6e76f82d8925bd0f1f3504a30150af3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:24:07 +0500 Subject: [PATCH 035/207] changed the 'v2.12.x' branch --- auto_commit_test.go | 9 --------- 1 file changed, 9 deletions(-) diff --git a/auto_commit_test.go b/auto_commit_test.go index 99f680d..c560702 100644 --- a/auto_commit_test.go +++ b/auto_commit_test.go @@ -4,15 +4,6 @@ import ( "testing" ) -// var ( -// getStagedFilesMock func() ([]string, error) -// parserMock func([]string) (string, error) -// commitMock func(string) error -// errorLoggerMock func(error) -// infoLoggerMock func(string) -// getVersionMock func(bool) -// ) - func TestAutoCommit_NoStagedFiles(t *testing.T) { calledInfo := "" From 2a2e57369c59a84356f306626238c5c38ba6ed8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:24:25 +0500 Subject: [PATCH 036/207] added function TestAutoCommit_ErrorGettingFiles | if err is equal to nil || err.Error() != "error getting staged files: fail" --- auto_commit_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/auto_commit_test.go b/auto_commit_test.go index c560702..f5d1786 100644 --- a/auto_commit_test.go +++ b/auto_commit_test.go @@ -20,3 +20,14 @@ func TestAutoCommit_NoStagedFiles(t *testing.T) { t.Errorf("expected info log 'No files staged for commit.', got '%s'", calledInfo) } } + +func TestAutoCommit_ErrorGettingFiles(t *testing.T) { + getStagedFilesMock = func() ([]string, error) { return nil, errors.New("fail") } + errorLoggerMock = func(err error) { + if err == nil || err.Error() != "error getting staged files: fail" { + t.Errorf("unexpected error: %v", err) + } + } + infoLoggerMock = func(msg string) {} + AutoCommit() +} From 68a2aa54604396ce1770d5385ff5db6fa1e32dd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:24:43 +0500 Subject: [PATCH 037/207] changed the 'v2.12.x' branch --- auto_commit_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto_commit_test.go b/auto_commit_test.go index f5d1786..3fb0429 100644 --- a/auto_commit_test.go +++ b/auto_commit_test.go @@ -22,7 +22,7 @@ func TestAutoCommit_NoStagedFiles(t *testing.T) { } func TestAutoCommit_ErrorGettingFiles(t *testing.T) { - getStagedFilesMock = func() ([]string, error) { return nil, errors.New("fail") } + GetStagedFiles = func() ([]string, error) { return nil, errors.New("fail") } errorLoggerMock = func(err error) { if err == nil || err.Error() != "error getting staged files: fail" { t.Errorf("unexpected error: %v", err) From 9594ba28820d23e0f8a3d5de069da29781b4d9ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:25:00 +0500 Subject: [PATCH 038/207] changed the 'v2.12.x' branch --- auto_commit_test.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/auto_commit_test.go b/auto_commit_test.go index 3fb0429..0d153a2 100644 --- a/auto_commit_test.go +++ b/auto_commit_test.go @@ -1,6 +1,7 @@ package main import ( + "errors" "testing" ) @@ -8,17 +9,17 @@ func TestAutoCommit_NoStagedFiles(t *testing.T) { calledInfo := "" GetStagedFiles = func() ([]string, error) { return []string{}, nil } - Parser = func(files []string) (string, error) { return "", nil } - Commit = func(msg string) error { return nil } - ErrorLogger = func(err error) { t.Errorf("unexpected error: %v", err) } - InfoLogger = func(msg string) { calledInfo = msg } - GetVersion = func(show bool) {} + Parser = func(files []string) (string, error) { return "", nil } + Commit = func(msg string) error { return nil } + ErrorLogger = func(err error) { t.Errorf("unexpected error: %v", err) } + InfoLogger = func(msg string) { calledInfo = msg } + GetVersion = func(show bool) {} AutoCommit() - if calledInfo != "No files staged for commit." { - t.Errorf("expected info log 'No files staged for commit.', got '%s'", calledInfo) - } + if calledInfo != "No files staged for commit." { + t.Errorf("expected info log 'No files staged for commit.', got '%s'", calledInfo) + } } func TestAutoCommit_ErrorGettingFiles(t *testing.T) { From a0437edbab889d4eb215cdf79f457b7c6085d23b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:25:17 +0500 Subject: [PATCH 039/207] changed the 'v2.12.x' branch --- auto_commit_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/auto_commit_test.go b/auto_commit_test.go index 0d153a2..cf44177 100644 --- a/auto_commit_test.go +++ b/auto_commit_test.go @@ -24,11 +24,12 @@ func TestAutoCommit_NoStagedFiles(t *testing.T) { func TestAutoCommit_ErrorGettingFiles(t *testing.T) { GetStagedFiles = func() ([]string, error) { return nil, errors.New("fail") } - errorLoggerMock = func(err error) { + ErrorLogger = func(err error) { if err == nil || err.Error() != "error getting staged files: fail" { t.Errorf("unexpected error: %v", err) } } - infoLoggerMock = func(msg string) {} + + InfoLogger = func(msg string) {} AutoCommit() } From 20b4522897ae12468070e1b1e9b7a85d95e5a1bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:25:33 +0500 Subject: [PATCH 040/207] added variable calledInfo --- auto_commit_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/auto_commit_test.go b/auto_commit_test.go index cf44177..d6bd862 100644 --- a/auto_commit_test.go +++ b/auto_commit_test.go @@ -23,6 +23,8 @@ func TestAutoCommit_NoStagedFiles(t *testing.T) { } func TestAutoCommit_ErrorGettingFiles(t *testing.T) { + calledInfo := "" + GetStagedFiles = func() ([]string, error) { return nil, errors.New("fail") } ErrorLogger = func(err error) { if err == nil || err.Error() != "error getting staged files: fail" { @@ -30,6 +32,6 @@ func TestAutoCommit_ErrorGettingFiles(t *testing.T) { } } - InfoLogger = func(msg string) {} + InfoLogger = func(msg string) { calledInfo = msg } AutoCommit() } From 5d946a6a42db70a7a7d50ce708d7d1f0edc67d76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:26:13 +0500 Subject: [PATCH 041/207] changed the 'v2.12.x' branch --- auto_commit_test.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/auto_commit_test.go b/auto_commit_test.go index d6bd862..6a7623f 100644 --- a/auto_commit_test.go +++ b/auto_commit_test.go @@ -26,11 +26,10 @@ func TestAutoCommit_ErrorGettingFiles(t *testing.T) { calledInfo := "" GetStagedFiles = func() ([]string, error) { return nil, errors.New("fail") } - ErrorLogger = func(err error) { - if err == nil || err.Error() != "error getting staged files: fail" { - t.Errorf("unexpected error: %v", err) - } - } + Parser = func(files []string) (string, error) { return "", nil } + Commit = func(msg string) error { return nil } + InfoLogger = func(msg string) {} + GetVersion = func(show bool) {} InfoLogger = func(msg string) { calledInfo = msg } AutoCommit() From b645178800f3309e071a661f5eb9a7c2296b4dce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:26:30 +0500 Subject: [PATCH 042/207] added variable calledError --- auto_commit_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/auto_commit_test.go b/auto_commit_test.go index 6a7623f..1e83950 100644 --- a/auto_commit_test.go +++ b/auto_commit_test.go @@ -23,14 +23,15 @@ func TestAutoCommit_NoStagedFiles(t *testing.T) { } func TestAutoCommit_ErrorGettingFiles(t *testing.T) { - calledInfo := "" - GetStagedFiles = func() ([]string, error) { return nil, errors.New("fail") } Parser = func(files []string) (string, error) { return "", nil } Commit = func(msg string) error { return nil } InfoLogger = func(msg string) {} GetVersion = func(show bool) {} + var calledError string + + InfoLogger = func(msg string) { calledInfo = msg } AutoCommit() } From 9af377ca38352551cb2470c0fa863bc395e7f6ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:27:17 +0500 Subject: [PATCH 043/207] added variables: calledErr, expected | if calledErr is not equal to expected --- auto_commit_test.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/auto_commit_test.go b/auto_commit_test.go index 1e83950..8ae8345 100644 --- a/auto_commit_test.go +++ b/auto_commit_test.go @@ -29,9 +29,15 @@ func TestAutoCommit_ErrorGettingFiles(t *testing.T) { InfoLogger = func(msg string) {} GetVersion = func(show bool) {} - var calledError string - + var calledErr string + ErrorLogger = func(err error) { calledErr = err.Error() } + + InfoLogger = func(msg string) { calledErr = msg } - InfoLogger = func(msg string) { calledInfo = msg } AutoCommit() + + expected := "error getting staged files: fail" + if calledErr != expected { + t.Errorf("ex") + } } From eabaeb71d94dbddd2ca7a9209c599f92d8ae3e4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:27:34 +0500 Subject: [PATCH 044/207] changed the 'v2.12.x' branch --- auto_commit_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto_commit_test.go b/auto_commit_test.go index 8ae8345..7dc012c 100644 --- a/auto_commit_test.go +++ b/auto_commit_test.go @@ -38,6 +38,6 @@ func TestAutoCommit_ErrorGettingFiles(t *testing.T) { expected := "error getting staged files: fail" if calledErr != expected { - t.Errorf("ex") + t.Errorf("expected error log '%s', got '%s'", expected, calledErr) } } From 68d717e7c715be0f7d2f43b19b39bbe20970588d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:28:04 +0500 Subject: [PATCH 045/207] added functions: TestAutoCommit_NoStagedFiles, TestAutoCommit_ErrorGettingFiles | deleted functions: TestAutoCommit_NoStagedFiles, TestAutoCommit_ErrorGettingFiles --- auto_commit_test.go | 82 ++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/auto_commit_test.go b/auto_commit_test.go index 7dc012c..69f62f9 100644 --- a/auto_commit_test.go +++ b/auto_commit_test.go @@ -1,43 +1,43 @@ package main -import ( - "errors" - "testing" -) - -func TestAutoCommit_NoStagedFiles(t *testing.T) { - calledInfo := "" - - GetStagedFiles = func() ([]string, error) { return []string{}, nil } - Parser = func(files []string) (string, error) { return "", nil } - Commit = func(msg string) error { return nil } - ErrorLogger = func(err error) { t.Errorf("unexpected error: %v", err) } - InfoLogger = func(msg string) { calledInfo = msg } - GetVersion = func(show bool) {} - - AutoCommit() - - if calledInfo != "No files staged for commit." { - t.Errorf("expected info log 'No files staged for commit.', got '%s'", calledInfo) - } -} - -func TestAutoCommit_ErrorGettingFiles(t *testing.T) { - GetStagedFiles = func() ([]string, error) { return nil, errors.New("fail") } - Parser = func(files []string) (string, error) { return "", nil } - Commit = func(msg string) error { return nil } - InfoLogger = func(msg string) {} - GetVersion = func(show bool) {} - - var calledErr string - ErrorLogger = func(err error) { calledErr = err.Error() } - - InfoLogger = func(msg string) { calledErr = msg } - - AutoCommit() - - expected := "error getting staged files: fail" - if calledErr != expected { - t.Errorf("expected error log '%s', got '%s'", expected, calledErr) - } -} +// import ( +// "errors" +// "testing" +// ) + +// func TestAutoCommit_NoStagedFiles(t *testing.T) { +// calledInfo := "" + +// GetStagedFiles = func() ([]string, error) { return []string{}, nil } +// Parser = func(files []string) (string, error) { return "", nil } +// Commit = func(msg string) error { return nil } +// ErrorLogger = func(err error) { t.Errorf("unexpected error: %v", err) } +// InfoLogger = func(msg string) { calledInfo = msg } +// GetVersion = func(show bool) {} + +// AutoCommit() + +// if calledInfo != "No files staged for commit." { +// t.Errorf("expected info log 'No files staged for commit.', got '%s'", calledInfo) +// } +// } + +// func TestAutoCommit_ErrorGettingFiles(t *testing.T) { +// GetStagedFiles = func() ([]string, error) { return nil, errors.New("fail") } +// Parser = func(files []string) (string, error) { return "", nil } +// Commit = func(msg string) error { return nil } +// InfoLogger = func(msg string) {} +// GetVersion = func(show bool) {} + +// var calledErr string +// ErrorLogger = func(err error) { calledErr = err.Error() } + +// InfoLogger = func(msg string) { calledErr = msg } + +// AutoCommit() + +// expected := "error getting staged files: fail" +// if calledErr != expected { +// t.Errorf("expected error log '%s', got '%s'", expected, calledErr) +// } +// } From 408ff15089b8b12c7314781073f4914c86d1b5ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:28:44 +0500 Subject: [PATCH 046/207] the 'Makefile' file has been changed --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index cca3d06..d5d2d5c 100644 --- a/Makefile +++ b/Makefile @@ -27,8 +27,8 @@ buildrelease-update: @go build -ldflags="-s -w" -trimpath -o bin/auto-commit.update . @upx.exe --best --lzma bin/auto-commit.update -test: - @go test -v ./... +# test: +# @go test -v ./... run: build @./bin/auto-commit From fb8c944f1c49c39531fc8bebe3f653a8a5a42025 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:29:00 +0500 Subject: [PATCH 047/207] the 'Makefile' file has been changed --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index d5d2d5c..cca3d06 100644 --- a/Makefile +++ b/Makefile @@ -27,8 +27,8 @@ buildrelease-update: @go build -ldflags="-s -w" -trimpath -o bin/auto-commit.update . @upx.exe --best --lzma bin/auto-commit.update -# test: -# @go test -v ./... +test: + @go test -v ./... run: build @./bin/auto-commit From 84000027cb57431fced8b400f075b7c74454ad50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:29:16 +0500 Subject: [PATCH 048/207] added variables: calledInfo, calledErr, expected | added functions: TestAutoCommit_NoStagedFiles, TestAutoCommit_ErrorGettingFiles | deleted functions: TestAutoCommit_NoStagedFiles, TestAutoCommit_ErrorGettingFiles --- auto_commit_test.go | 82 ++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/auto_commit_test.go b/auto_commit_test.go index 69f62f9..7dc012c 100644 --- a/auto_commit_test.go +++ b/auto_commit_test.go @@ -1,43 +1,43 @@ package main -// import ( -// "errors" -// "testing" -// ) - -// func TestAutoCommit_NoStagedFiles(t *testing.T) { -// calledInfo := "" - -// GetStagedFiles = func() ([]string, error) { return []string{}, nil } -// Parser = func(files []string) (string, error) { return "", nil } -// Commit = func(msg string) error { return nil } -// ErrorLogger = func(err error) { t.Errorf("unexpected error: %v", err) } -// InfoLogger = func(msg string) { calledInfo = msg } -// GetVersion = func(show bool) {} - -// AutoCommit() - -// if calledInfo != "No files staged for commit." { -// t.Errorf("expected info log 'No files staged for commit.', got '%s'", calledInfo) -// } -// } - -// func TestAutoCommit_ErrorGettingFiles(t *testing.T) { -// GetStagedFiles = func() ([]string, error) { return nil, errors.New("fail") } -// Parser = func(files []string) (string, error) { return "", nil } -// Commit = func(msg string) error { return nil } -// InfoLogger = func(msg string) {} -// GetVersion = func(show bool) {} - -// var calledErr string -// ErrorLogger = func(err error) { calledErr = err.Error() } - -// InfoLogger = func(msg string) { calledErr = msg } - -// AutoCommit() - -// expected := "error getting staged files: fail" -// if calledErr != expected { -// t.Errorf("expected error log '%s', got '%s'", expected, calledErr) -// } -// } +import ( + "errors" + "testing" +) + +func TestAutoCommit_NoStagedFiles(t *testing.T) { + calledInfo := "" + + GetStagedFiles = func() ([]string, error) { return []string{}, nil } + Parser = func(files []string) (string, error) { return "", nil } + Commit = func(msg string) error { return nil } + ErrorLogger = func(err error) { t.Errorf("unexpected error: %v", err) } + InfoLogger = func(msg string) { calledInfo = msg } + GetVersion = func(show bool) {} + + AutoCommit() + + if calledInfo != "No files staged for commit." { + t.Errorf("expected info log 'No files staged for commit.', got '%s'", calledInfo) + } +} + +func TestAutoCommit_ErrorGettingFiles(t *testing.T) { + GetStagedFiles = func() ([]string, error) { return nil, errors.New("fail") } + Parser = func(files []string) (string, error) { return "", nil } + Commit = func(msg string) error { return nil } + InfoLogger = func(msg string) {} + GetVersion = func(show bool) {} + + var calledErr string + ErrorLogger = func(err error) { calledErr = err.Error() } + + InfoLogger = func(msg string) { calledErr = msg } + + AutoCommit() + + expected := "error getting staged files: fail" + if calledErr != expected { + t.Errorf("expected error log '%s', got '%s'", expected, calledErr) + } +} From eeb300fd5d3853d45cec398b05a4427721773193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:33:08 +0500 Subject: [PATCH 049/207] added variables: calledInfo, calledErr, expected | added functions: TestAutoCommit_NoStagedFiles, TestAutoCommit_ErrorGettingFiles | if calledInfo is not equal to No files staged for commit."; if calledErr is not equal to expected | included 'errors', 'testing' in auto-commit_test.go --- auto_commit_test.go => auto-commit_test.go | 0 auto-function_test.go | 8 ++++++++ 2 files changed, 8 insertions(+) rename auto_commit_test.go => auto-commit_test.go (100%) create mode 100644 auto-function_test.go diff --git a/auto_commit_test.go b/auto-commit_test.go similarity index 100% rename from auto_commit_test.go rename to auto-commit_test.go diff --git a/auto-function_test.go b/auto-function_test.go new file mode 100644 index 0000000..706eced --- /dev/null +++ b/auto-function_test.go @@ -0,0 +1,8 @@ +package main + +import "testing" + +func TestParser_AddedGoFunction(t *testing.T) { + GetDiff = + GetDiff() +} From b61440049aa7b2faca9204138e870685adf28f3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:33:26 +0500 Subject: [PATCH 050/207] changed the 'v2.12.x' branch --- auto-function_test.go | 3 +-- diff.go | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/auto-function_test.go b/auto-function_test.go index 706eced..f8f5326 100644 --- a/auto-function_test.go +++ b/auto-function_test.go @@ -3,6 +3,5 @@ package main import "testing" func TestParser_AddedGoFunction(t *testing.T) { - GetDiff = - GetDiff() + GetDiff = func(file string) } diff --git a/diff.go b/diff.go index 871442a..4bf7a71 100644 --- a/diff.go +++ b/diff.go @@ -14,7 +14,7 @@ var diffBufferPool = sync.Pool{ }, } -func GetDiff(file string) (string, error) { +var GetDiff = func(file string) (string, error) { var builder strings.Builder builder.Reset() From 432181421bc2a40851c1a4dfc32d0cd6d35dcaef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:33:43 +0500 Subject: [PATCH 051/207] added function TestParser --- auto-function_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/auto-function_test.go b/auto-function_test.go index f8f5326..96009c1 100644 --- a/auto-function_test.go +++ b/auto-function_test.go @@ -3,5 +3,7 @@ package main import "testing" func TestParser_AddedGoFunction(t *testing.T) { - GetDiff = func(file string) + GetDiff = func(file string) (string, error) { + return "+func TestParser() {}", nil + } } From d3aca6f97238046914f0d701b5fdf1dcba33cd23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:33:59 +0500 Subject: [PATCH 052/207] changed the 'v2.12.x' branch --- auto-function_test.go | 2 ++ detected.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/auto-function_test.go b/auto-function_test.go index 96009c1..7335f54 100644 --- a/auto-function_test.go +++ b/auto-function_test.go @@ -6,4 +6,6 @@ func TestParser_AddedGoFunction(t *testing.T) { GetDiff = func(file string) (string, error) { return "+func TestParser() {}", nil } + + DetectLanguage = } diff --git a/detected.go b/detected.go index 67158b8..c58e1c3 100644 --- a/detected.go +++ b/detected.go @@ -5,7 +5,7 @@ import ( "strings" ) -func DetectLanguage(filename string) string { +var DetectLanguage = func(filename string) string { ext := strings.ToLower(filepath.Ext(filename)) switch ext { From 08039023c499c4a4c3412c4bf51656bd987e0466 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:34:17 +0500 Subject: [PATCH 053/207] changed the 'v2.12.x' branch --- auto-function_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/auto-function_test.go b/auto-function_test.go index 7335f54..e5423a3 100644 --- a/auto-function_test.go +++ b/auto-function_test.go @@ -7,5 +7,7 @@ func TestParser_AddedGoFunction(t *testing.T) { return "+func TestParser() {}", nil } - DetectLanguage = + DetectLanguage = func(filename string) string { + + } } From 16486c74f1ba41a8a8003d12d1a6aac620fa6525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:34:35 +0500 Subject: [PATCH 054/207] changed the 'v2.12.x' branch --- auto-function_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/auto-function_test.go b/auto-function_test.go index e5423a3..00845c4 100644 --- a/auto-function_test.go +++ b/auto-function_test.go @@ -8,6 +8,8 @@ func TestParser_AddedGoFunction(t *testing.T) { } DetectLanguage = func(filename string) string { - + return "go" } + + msg, err := Parse } From faa0a676606fa635b426c7250f86491acf826303 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:34:51 +0500 Subject: [PATCH 055/207] changed the 'v2.12.x' branch --- auto-function_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto-function_test.go b/auto-function_test.go index 00845c4..20fc3b7 100644 --- a/auto-function_test.go +++ b/auto-function_test.go @@ -11,5 +11,5 @@ func TestParser_AddedGoFunction(t *testing.T) { return "go" } - msg, err := Parse + msg, err := Parser([]string{"test"}) } From 171ad94748c5608fee956e1e26b1498b0edd945e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:35:07 +0500 Subject: [PATCH 056/207] changed the 'v2.12.x' branch --- auto-function_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto-function_test.go b/auto-function_test.go index 20fc3b7..c242a30 100644 --- a/auto-function_test.go +++ b/auto-function_test.go @@ -11,5 +11,5 @@ func TestParser_AddedGoFunction(t *testing.T) { return "go" } - msg, err := Parser([]string{"test"}) + msg, err := Parser([]string{"auto-commit-parser-test.go"}) } From ccb206789814e0b2c0f4f1adec8c57f995b02b8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:35:25 +0500 Subject: [PATCH 057/207] if err is not equal to nil --- auto-function_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/auto-function_test.go b/auto-function_test.go index c242a30..b88cb92 100644 --- a/auto-function_test.go +++ b/auto-function_test.go @@ -12,4 +12,7 @@ func TestParser_AddedGoFunction(t *testing.T) { } msg, err := Parser([]string{"auto-commit-parser-test.go"}) + if err != nil { + + } } From d529b2556d9773c38786d37cf567be273855ca63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:35:42 +0500 Subject: [PATCH 058/207] changed the 'v2.12.x' branch --- auto-function_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/auto-function_test.go b/auto-function_test.go index b88cb92..9f3744f 100644 --- a/auto-function_test.go +++ b/auto-function_test.go @@ -13,6 +13,8 @@ func TestParser_AddedGoFunction(t *testing.T) { msg, err := Parser([]string{"auto-commit-parser-test.go"}) if err != nil { - + t.Fatalf("unexpected error: %v", err) } + + exp } From 5fb46ca5093b1e06759faf5f7bf4e1f13ce03f7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:36:13 +0500 Subject: [PATCH 059/207] added variable expected | if msg is not equal to expected --- auto-function_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/auto-function_test.go b/auto-function_test.go index 9f3744f..ca33879 100644 --- a/auto-function_test.go +++ b/auto-function_test.go @@ -16,5 +16,8 @@ func TestParser_AddedGoFunction(t *testing.T) { t.Fatalf("unexpected error: %v", err) } - exp + expected := "added function TestParser" + if msg != expected { + t.Errorf("expected '%s'") + } } From 125c3befcd8d75fefe9e53f54b751f624e0a17f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:36:30 +0500 Subject: [PATCH 060/207] changed the 'v2.12.x' branch --- auto-function_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto-function_test.go b/auto-function_test.go index ca33879..c7e8e33 100644 --- a/auto-function_test.go +++ b/auto-function_test.go @@ -18,6 +18,6 @@ func TestParser_AddedGoFunction(t *testing.T) { expected := "added function TestParser" if msg != expected { - t.Errorf("expected '%s'") + t.Errorf("expected '%s', got '%s'", expected, msg) } } From 7efc68bf2f1cac1096f6be8d230f0d343956e78a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:37:47 +0500 Subject: [PATCH 061/207] changed the 'v2.12.x' branch --- auto-function_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto-function_test.go b/auto-function_test.go index c7e8e33..f70dae5 100644 --- a/auto-function_test.go +++ b/auto-function_test.go @@ -7,7 +7,7 @@ func TestParser_AddedGoFunction(t *testing.T) { return "+func TestParser() {}", nil } - DetectLanguage = func(filename string) string { + DetectLanguage = func(file string) string { return "go" } From 4975c064c83b03e10775a5b82a89820fcc53d715 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:38:04 +0500 Subject: [PATCH 062/207] changed the 'v2.12.x' branch --- auto-function_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto-function_test.go b/auto-function_test.go index f70dae5..c7e8e33 100644 --- a/auto-function_test.go +++ b/auto-function_test.go @@ -7,7 +7,7 @@ func TestParser_AddedGoFunction(t *testing.T) { return "+func TestParser() {}", nil } - DetectLanguage = func(file string) string { + DetectLanguage = func(filename string) string { return "go" } From 6c07b0c4bc90ea4a0a7ef2015696b5569fe4afed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:39:55 +0500 Subject: [PATCH 063/207] changed the 'v2.12.x' branch --- parser.go | 1 + 1 file changed, 1 insertion(+) diff --git a/parser.go b/parser.go index a027065..d5d3fe6 100644 --- a/parser.go +++ b/parser.go @@ -46,6 +46,7 @@ var Parser = func(files []string) (string, error) { mu.Unlock() diff, err := GetDiff(file) + fmt. if err != nil { errChan <- fmt.Errorf("error getting diff for %s: %w", file, err) continue From aeb40a3629a9f3acbd3376cb62a0154825f74d10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:40:12 +0500 Subject: [PATCH 064/207] changed the 'v2.12.x' branch --- parser.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parser.go b/parser.go index d5d3fe6..f9e45c9 100644 --- a/parser.go +++ b/parser.go @@ -46,7 +46,7 @@ var Parser = func(files []string) (string, error) { mu.Unlock() diff, err := GetDiff(file) - fmt. + fmt.Println(diff) if err != nil { errChan <- fmt.Errorf("error getting diff for %s: %w", file, err) continue From e499d0f5f1e9ea6f645657e9809c8e076e76e97f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:40:28 +0500 Subject: [PATCH 065/207] changed the 'v2.12.x' branch --- parser.go | 1 - 1 file changed, 1 deletion(-) diff --git a/parser.go b/parser.go index f9e45c9..a027065 100644 --- a/parser.go +++ b/parser.go @@ -46,7 +46,6 @@ var Parser = func(files []string) (string, error) { mu.Unlock() diff, err := GetDiff(file) - fmt.Println(diff) if err != nil { errChan <- fmt.Errorf("error getting diff for %s: %w", file, err) continue From 8da82e6abca9be816b8e760102ee2abf715cd417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:42:02 +0500 Subject: [PATCH 066/207] changed the 'v2.12.x' branch --- auto-function_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto-function_test.go b/auto-function_test.go index c7e8e33..c33c63b 100644 --- a/auto-function_test.go +++ b/auto-function_test.go @@ -4,7 +4,7 @@ import "testing" func TestParser_AddedGoFunction(t *testing.T) { GetDiff = func(file string) (string, error) { - return "+func TestParser() {}", nil + return "+func TestParser()", nil } DetectLanguage = func(filename string) string { From 9cd84bce9e0ce60fcf53cb4e63405021435668ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:42:18 +0500 Subject: [PATCH 067/207] changed the 'v2.12.x' branch --- auto-function_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto-function_test.go b/auto-function_test.go index c33c63b..c7e8e33 100644 --- a/auto-function_test.go +++ b/auto-function_test.go @@ -4,7 +4,7 @@ import "testing" func TestParser_AddedGoFunction(t *testing.T) { GetDiff = func(file string) (string, error) { - return "+func TestParser()", nil + return "+func TestParser() {}", nil } DetectLanguage = func(filename string) string { From 5ac1c500bf584e5af08d74e70758ed3748131613 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:42:59 +0500 Subject: [PATCH 068/207] changed the 'v2.12.x' branch --- parser.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/parser.go b/parser.go index a027065..812953f 100644 --- a/parser.go +++ b/parser.go @@ -22,6 +22,8 @@ func AppendMsg(commitMsg, addition string) string { } var Parser = func(files []string) (string, error) { + return "", nil + var ( payloadMsg string mu sync.Mutex From de59ac88ca764c049d98439693f1034ad98b8b0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:43:17 +0500 Subject: [PATCH 069/207] changed the 'v2.12.x' branch --- parser.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parser.go b/parser.go index 812953f..1695699 100644 --- a/parser.go +++ b/parser.go @@ -22,7 +22,7 @@ func AppendMsg(commitMsg, addition string) string { } var Parser = func(files []string) (string, error) { - return "", nil + return "started", nil var ( payloadMsg string From 60aec9e3ea97687dd2acf3d7ac6a89d785ca645a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:43:44 +0500 Subject: [PATCH 070/207] changed the 'v2.12.x' branch --- auto-function_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto-function_test.go b/auto-function_test.go index c7e8e33..7357960 100644 --- a/auto-function_test.go +++ b/auto-function_test.go @@ -11,7 +11,7 @@ func TestParser_AddedGoFunction(t *testing.T) { return "go" } - msg, err := Parser([]string{"auto-commit-parser-test.go"}) + msg, err := Parser([]string{"auto-commit-parser-test.go", ""}) if err != nil { t.Fatalf("unexpected error: %v", err) } From f83397b8de38db51414c15430adaedc6191a7102 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:44:00 +0500 Subject: [PATCH 071/207] changed the 'v2.12.x' branch --- auto-function_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto-function_test.go b/auto-function_test.go index 7357960..09a976b 100644 --- a/auto-function_test.go +++ b/auto-function_test.go @@ -11,7 +11,7 @@ func TestParser_AddedGoFunction(t *testing.T) { return "go" } - msg, err := Parser([]string{"auto-commit-parser-test.go", ""}) + msg, err := Parser([]string{"auto-commit-parser-test.go", "auto-commit-parser-test.go"}) if err != nil { t.Fatalf("unexpected error: %v", err) } From 340a2f329156bf3d089f61bab8a0a31ef1518182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:44:16 +0500 Subject: [PATCH 072/207] changed the 'v2.12.x' branch --- auto-function_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto-function_test.go b/auto-function_test.go index 09a976b..c7e8e33 100644 --- a/auto-function_test.go +++ b/auto-function_test.go @@ -11,7 +11,7 @@ func TestParser_AddedGoFunction(t *testing.T) { return "go" } - msg, err := Parser([]string{"auto-commit-parser-test.go", "auto-commit-parser-test.go"}) + msg, err := Parser([]string{"auto-commit-parser-test.go"}) if err != nil { t.Fatalf("unexpected error: %v", err) } From c2a686799d293914972588c6a718e451916d7761 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:44:50 +0500 Subject: [PATCH 073/207] changed the 'v2.12.x' branch --- auto-function_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto-function_test.go b/auto-function_test.go index c7e8e33..c33c63b 100644 --- a/auto-function_test.go +++ b/auto-function_test.go @@ -4,7 +4,7 @@ import "testing" func TestParser_AddedGoFunction(t *testing.T) { GetDiff = func(file string) (string, error) { - return "+func TestParser() {}", nil + return "+func TestParser()", nil } DetectLanguage = func(filename string) string { From d2f8d15bd1418fb255975212987caa645e95ac88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:45:41 +0500 Subject: [PATCH 074/207] changed the 'v2.12.x' branch --- auto-commit_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto-commit_test.go b/auto-commit_test.go index 7dc012c..b453e01 100644 --- a/auto-commit_test.go +++ b/auto-commit_test.go @@ -9,7 +9,7 @@ func TestAutoCommit_NoStagedFiles(t *testing.T) { calledInfo := "" GetStagedFiles = func() ([]string, error) { return []string{}, nil } - Parser = func(files []string) (string, error) { return "", nil } + // Parser = func(files []string) (string, error) { return "", nil } Commit = func(msg string) error { return nil } ErrorLogger = func(err error) { t.Errorf("unexpected error: %v", err) } InfoLogger = func(msg string) { calledInfo = msg } From 62ade17517fe3b0caf27721c71ab856fafc79d03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:46:23 +0500 Subject: [PATCH 075/207] changed the 'v2.12.x' branch --- auto-commit_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto-commit_test.go b/auto-commit_test.go index b453e01..ce460bd 100644 --- a/auto-commit_test.go +++ b/auto-commit_test.go @@ -24,7 +24,7 @@ func TestAutoCommit_NoStagedFiles(t *testing.T) { func TestAutoCommit_ErrorGettingFiles(t *testing.T) { GetStagedFiles = func() ([]string, error) { return nil, errors.New("fail") } - Parser = func(files []string) (string, error) { return "", nil } + // Parser = func(files []string) (string, error) { return "", nil } Commit = func(msg string) error { return nil } InfoLogger = func(msg string) {} GetVersion = func(show bool) {} From 4b74b052a5c95f8618d9399ac9069f32bf0199bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:46:39 +0500 Subject: [PATCH 076/207] changed the 'v2.12.x' branch --- auto-commit_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/auto-commit_test.go b/auto-commit_test.go index ce460bd..7dc012c 100644 --- a/auto-commit_test.go +++ b/auto-commit_test.go @@ -9,7 +9,7 @@ func TestAutoCommit_NoStagedFiles(t *testing.T) { calledInfo := "" GetStagedFiles = func() ([]string, error) { return []string{}, nil } - // Parser = func(files []string) (string, error) { return "", nil } + Parser = func(files []string) (string, error) { return "", nil } Commit = func(msg string) error { return nil } ErrorLogger = func(err error) { t.Errorf("unexpected error: %v", err) } InfoLogger = func(msg string) { calledInfo = msg } @@ -24,7 +24,7 @@ func TestAutoCommit_NoStagedFiles(t *testing.T) { func TestAutoCommit_ErrorGettingFiles(t *testing.T) { GetStagedFiles = func() ([]string, error) { return nil, errors.New("fail") } - // Parser = func(files []string) (string, error) { return "", nil } + Parser = func(files []string) (string, error) { return "", nil } Commit = func(msg string) error { return nil } InfoLogger = func(msg string) {} GetVersion = func(show bool) {} From 8006e33b3dcece3f535113d892ac0a043f7b0f83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:46:55 +0500 Subject: [PATCH 077/207] changed the 'v2.12.x' branch --- parser.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/parser.go b/parser.go index 1695699..a027065 100644 --- a/parser.go +++ b/parser.go @@ -22,8 +22,6 @@ func AppendMsg(commitMsg, addition string) string { } var Parser = func(files []string) (string, error) { - return "started", nil - var ( payloadMsg string mu sync.Mutex From b997c6f294893efe824c6334b49eb87d5dd42f39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:52:23 +0500 Subject: [PATCH 078/207] added variable restore | added variables: origGetStagedFiles, origParser, origCommit, origErrorLogger, origInfoLogger, origGetVersion | added function SaveAndRestoreMocks --- auto-commit_test.go | 8 ++------ test.g.go | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 test.g.go diff --git a/auto-commit_test.go b/auto-commit_test.go index 7dc012c..b9ca669 100644 --- a/auto-commit_test.go +++ b/auto-commit_test.go @@ -8,12 +8,8 @@ import ( func TestAutoCommit_NoStagedFiles(t *testing.T) { calledInfo := "" - GetStagedFiles = func() ([]string, error) { return []string{}, nil } - Parser = func(files []string) (string, error) { return "", nil } - Commit = func(msg string) error { return nil } - ErrorLogger = func(err error) { t.Errorf("unexpected error: %v", err) } - InfoLogger = func(msg string) { calledInfo = msg } - GetVersion = func(show bool) {} + restore := saveAndRestoreMocks() + defer restore() AutoCommit() diff --git a/test.g.go b/test.g.go new file mode 100644 index 0000000..ed8b347 --- /dev/null +++ b/test.g.go @@ -0,0 +1,19 @@ +package main + +func SaveAndRestoreMocks() func() { + origGetStagedFiles := GetStagedFiles + origParser := Parser + origCommit := Commit + origErrorLogger := ErrorLogger + origInfoLogger := InfoLogger + origGetVersion := GetVersion + + return func() { + GetStagedFiles = origGetStagedFiles + Parser = origParser + Commit = origCommit + ErrorLogger = origErrorLogger + InfoLogger = origInfoLogger + GetVersion = origGetVersion + } +} From 501e87207be63c207dbd8d2a4f142a7520eda051 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:52:39 +0500 Subject: [PATCH 079/207] changed value in variable restore --- auto-commit_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto-commit_test.go b/auto-commit_test.go index b9ca669..bb60145 100644 --- a/auto-commit_test.go +++ b/auto-commit_test.go @@ -8,7 +8,7 @@ import ( func TestAutoCommit_NoStagedFiles(t *testing.T) { calledInfo := "" - restore := saveAndRestoreMocks() + restore := SaveAndRestoreMocks() defer restore() AutoCommit() From 2728cbc2680473e0d274432759b31c6174d2a97c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:52:55 +0500 Subject: [PATCH 080/207] changed the 'v2.12.x' branch --- auto-commit_test.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/auto-commit_test.go b/auto-commit_test.go index bb60145..7dc012c 100644 --- a/auto-commit_test.go +++ b/auto-commit_test.go @@ -8,8 +8,12 @@ import ( func TestAutoCommit_NoStagedFiles(t *testing.T) { calledInfo := "" - restore := SaveAndRestoreMocks() - defer restore() + GetStagedFiles = func() ([]string, error) { return []string{}, nil } + Parser = func(files []string) (string, error) { return "", nil } + Commit = func(msg string) error { return nil } + ErrorLogger = func(err error) { t.Errorf("unexpected error: %v", err) } + InfoLogger = func(msg string) { calledInfo = msg } + GetVersion = func(show bool) {} AutoCommit() From a8e6a40558a798f8a835944158ba62c22f10f4ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:55:47 +0500 Subject: [PATCH 081/207] deleted function SaveAndRestoreMocks | added structure Mocks | added type Mocks --- test.g.go | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/test.g.go b/test.g.go index ed8b347..d5e2284 100644 --- a/test.g.go +++ b/test.g.go @@ -1,19 +1,10 @@ package main -func SaveAndRestoreMocks() func() { - origGetStagedFiles := GetStagedFiles - origParser := Parser - origCommit := Commit - origErrorLogger := ErrorLogger - origInfoLogger := InfoLogger - origGetVersion := GetVersion - - return func() { - GetStagedFiles = origGetStagedFiles - Parser = origParser - Commit = origCommit - ErrorLogger = origErrorLogger - InfoLogger = origInfoLogger - GetVersion = origGetVersion - } +type Mocks struct { + GetStagedFiles func() ([]string, error) + Parser func([]string) (string, error) + Commit func(string) error + ErrorLogger func(error) + InfoLogger func(string) + GetVersion func(bool) } From e0fbf61b60637604e40a224de7e58529e2562068 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:56:03 +0500 Subject: [PATCH 082/207] changed the 'v2.12.x' branch --- test.g.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test.g.go b/test.g.go index d5e2284..694d25e 100644 --- a/test.g.go +++ b/test.g.go @@ -8,3 +8,5 @@ type Mocks struct { InfoLogger func(string) GetVersion func(bool) } + +func SaveMocks From 620d3ee80d8bd23adcb378d3ca0503948d729556 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:56:19 +0500 Subject: [PATCH 083/207] changed the 'v2.12.x' branch --- test.g.go | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/test.g.go b/test.g.go index 694d25e..0748579 100644 --- a/test.g.go +++ b/test.g.go @@ -1,12 +1,23 @@ package main type Mocks struct { - GetStagedFiles func() ([]string, error) - Parser func([]string) (string, error) - Commit func(string) error - ErrorLogger func(error) - InfoLogger func(string) - GetVersion func(bool) + GetStagedFiles func() ([]string, error) + Parser func([]string) (string, error) + Commit func(string) error + ErrorLogger func(error) + InfoLogger func(string) + GetVersion func(bool) } -func SaveMocks +func SaveMocks() *Mocks { + return &Mocks{ + GetStagedFiles: GetStagedFiles, + Parser: Parser, + Commit: Commit, + ErrorLogger: ErrorLogger, + InfoLogger: InfoLogger, + GetVersion: GetVersion, + } +} + +func (m *Mocks) From a83dc5405d1c40d9c1c1da45fce370fba4743874 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:56:35 +0500 Subject: [PATCH 084/207] changed the 'v2.12.x' branch --- auto-commit_test.go | 3 ++- test.g.go | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/auto-commit_test.go b/auto-commit_test.go index 7dc012c..d8be09f 100644 --- a/auto-commit_test.go +++ b/auto-commit_test.go @@ -6,8 +6,9 @@ import ( ) func TestAutoCommit_NoStagedFiles(t *testing.T) { - calledInfo := "" + orig + calledInfo := "" GetStagedFiles = func() ([]string, error) { return []string{}, nil } Parser = func(files []string) (string, error) { return "", nil } Commit = func(msg string) error { return nil } diff --git a/test.g.go b/test.g.go index 0748579..c7d2dcd 100644 --- a/test.g.go +++ b/test.g.go @@ -20,4 +20,11 @@ func SaveMocks() *Mocks { } } -func (m *Mocks) +func (m *Mocks) Apply() { + GetStagedFiles = m.GetStagedFiles + Parser = m.Parser + Commit = m.Commit + ErrorLogger = m.ErrorLogger + InfoLogger = m.InfoLogger + GetVersion = m.GetVersion +} From 1e5a0371824792e31ed66d8d5efc103e11972cdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:57:08 +0500 Subject: [PATCH 085/207] added variables: mocks, mocks --- auto-commit_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/auto-commit_test.go b/auto-commit_test.go index d8be09f..33266d4 100644 --- a/auto-commit_test.go +++ b/auto-commit_test.go @@ -6,7 +6,8 @@ import ( ) func TestAutoCommit_NoStagedFiles(t *testing.T) { - orig + mocks := SaveMocks() + defer mocks.Apply() calledInfo := "" GetStagedFiles = func() ([]string, error) { return []string{}, nil } @@ -24,6 +25,9 @@ func TestAutoCommit_NoStagedFiles(t *testing.T) { } func TestAutoCommit_ErrorGettingFiles(t *testing.T) { + mocks := SaveMocks() + defer mocks.Apply() + GetStagedFiles = func() ([]string, error) { return nil, errors.New("fail") } Parser = func(files []string) (string, error) { return "", nil } Commit = func(msg string) error { return nil } From d6c579c86bbb0a3858139654b736bc95b4ca0392 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:57:41 +0500 Subject: [PATCH 086/207] added variable mocks | changed value in variable expected --- auto-function_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/auto-function_test.go b/auto-function_test.go index c33c63b..6a4891d 100644 --- a/auto-function_test.go +++ b/auto-function_test.go @@ -3,6 +3,9 @@ package main import "testing" func TestParser_AddedGoFunction(t *testing.T) { + mocks := SaveMocks() + defer mocks.Apply() + GetDiff = func(file string) (string, error) { return "+func TestParser()", nil } @@ -16,7 +19,7 @@ func TestParser_AddedGoFunction(t *testing.T) { t.Fatalf("unexpected error: %v", err) } - expected := "added function TestParser" + expected := "aded function TestParser" if msg != expected { t.Errorf("expected '%s', got '%s'", expected, msg) } From 40e87d9807682a1b6e71b18d1c0a8470cf5bb96a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 00:57:53 +0500 Subject: [PATCH 087/207] changed value in variable expected --- auto-function_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto-function_test.go b/auto-function_test.go index 6a4891d..6c7fa6c 100644 --- a/auto-function_test.go +++ b/auto-function_test.go @@ -19,7 +19,7 @@ func TestParser_AddedGoFunction(t *testing.T) { t.Fatalf("unexpected error: %v", err) } - expected := "aded function TestParser" + expected := "added function TestParser" if msg != expected { t.Errorf("expected '%s', got '%s'", expected, msg) } From 597e3891032e1e68455c906de0cd6cd8cd381cd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 01:18:39 +0500 Subject: [PATCH 088/207] added static html code web-site --- autoweb/static/index.html | 174 ++++++++++++++++++++++++++++++++++++++ diff.go | 6 +- 2 files changed, 177 insertions(+), 3 deletions(-) create mode 100644 autoweb/static/index.html diff --git a/autoweb/static/index.html b/autoweb/static/index.html new file mode 100644 index 0000000..46c006b --- /dev/null +++ b/autoweb/static/index.html @@ -0,0 +1,174 @@ + + + + + + Git Auto-Commit - The Future Industries + + + + + + + + + + + + + + + + +
+

Git auto-commit - automatic commit generation tool

+ +

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

+ +

+ The development is conducted as an open source project and is + distributed under the MIT license (or other compatible + licensing, depending on the implementation). Git Auto-Commit can + be integrated into CI/CD pipelines, hook scripts, or used + manually via the command line. +

+ +

Main features:

+
    +
  • + Analysis of changes in the work tree and automatic + generation of commit messages in natural language. +
  • +
  • + Integration with Git via the + git auto sub-command or configuration of user + aliases. +
  • +
  • + Support for templates and configurations for customizing + message structure to project standards (Conventional + Commits, Semantic Commit Messages, etc.). +
  • +
  • + Scalability: works both in small projects and in large + monorepositories. +
  • +
+ +

Install

+

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

+
+iex ((New-Object Net.WebClient).DownloadString('https://github.com/thefuture-industries/git-auto-commit/blob/main/scripts/install-windows-auto-commit.ps1?raw=true'))
+ +

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

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

Setting up

+

Launch

+

+ Everything is ready now, after making changes to the code, just + run: +

+ +

1 Option

+
+git add .
+git auto
+git push
+ +

2 Commands

+
+git auto -w   # Commit observer: you don't have to think and write anymore, `git auto -w` will figure it out and commit for you!
+git auto -v   # Viewing the current version of auto-commit
+git auto -u   # Upgrade to the new auto-commit version
+ +
+ Distributed under the MIT License • © 2025 The Future + Industries +
+
+ + + + diff --git a/diff.go b/diff.go index 4bf7a71..96fa7dc 100644 --- a/diff.go +++ b/diff.go @@ -67,9 +67,9 @@ var GetDiff = func(file string) (string, error) { // return nil, err // } -// return files, nil -// } -var GetStagedFiles = func () ([]string, error) { +// return files, nil +// } +var GetStagedFiles = func() ([]string, error) { cmd := exec.Command("git", "diff", "--cached", "--name-only") stdout, err := cmd.StdoutPipe() From 03bf2b4103c0455f279c3922dffe3b1225cee36f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:34:16 +0500 Subject: [PATCH 089/207] the 'vercel.json' file has been changed | the 'index.html' file has been changed --- vercel.json | 14 ++++++++++++++ {autoweb/static => www}/index.html | 0 2 files changed, 14 insertions(+) create mode 100644 vercel.json rename {autoweb/static => www}/index.html (100%) diff --git a/vercel.json b/vercel.json new file mode 100644 index 0000000..f8f5ec0 --- /dev/null +++ b/vercel.json @@ -0,0 +1,14 @@ +{ + "builds": [ + { + "src": "www/**/*", + "use": "@vercel/static" + } + ], + "routes": [ + { + "src": "/(.*)", + "dest": "/www/$1" + } + ] +} diff --git a/autoweb/static/index.html b/www/index.html similarity index 100% rename from autoweb/static/index.html rename to www/index.html From c4009637db9ed3a990a1ac9c42982a3035364b85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:34:49 +0500 Subject: [PATCH 090/207] deleted function GetStagedFiles --- diff.go | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/diff.go b/diff.go index 96fa7dc..583dee7 100644 --- a/diff.go +++ b/diff.go @@ -41,34 +41,6 @@ var GetDiff = func(file string) (string, error) { return buf.String(), nil } -// func GetStagedFiles() ([]string, error) { -// cmd := exec.Command("git", "diff", "--cached", "--name-only") - -// stdout, err := cmd.StdoutPipe() -// if err != nil { -// return nil, err -// } - -// if err := cmd.Start(); err != nil { -// return nil, err -// } - -// var files []string -// scanner := bufio.NewScanner(stdout) -// for scanner.Scan() { -// files = append(files, scanner.Text()) -// } - -// if err := scanner.Err(); err != nil { -// return nil, err -// } - -// if err := cmd.Wait(); err != nil { -// return nil, err -// } - -// return files, nil -// } var GetStagedFiles = func() ([]string, error) { cmd := exec.Command("git", "diff", "--cached", "--name-only") From 5e72dc28eae420f9bad14ee84fb13d054f8fe24d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:35:05 +0500 Subject: [PATCH 091/207] added variables: builder, cmd, buf, cmd, scanner | if err is not equal to nil; err := cmd.Run(); if err is not equal to nil; if err is not equal to nil; err := cmd.Start(); if err is not equal to nil; err := scanner.Err(); if err is not equal to nil; err := cmd.Wait(); if err is not equal to nil --- diff.go => diff/diff.go | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename diff.go => diff/diff.go (100%) diff --git a/diff.go b/diff/diff.go similarity index 100% rename from diff.go rename to diff/diff.go From 9b4f9f8c9923493a5dd59042213454a4e52db176 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:35:22 +0500 Subject: [PATCH 092/207] changed the 'v2.12.x' branch --- diff/diff.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diff/diff.go b/diff/diff.go index 583dee7..f09f999 100644 --- a/diff/diff.go +++ b/diff/diff.go @@ -1,4 +1,4 @@ -package main +package diff import ( "bufio" From ab79c247ca9bfcf362afeb8046c1d744d1429da2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:35:38 +0500 Subject: [PATCH 093/207] added variables: cmd, out, root, cmd | added functions: GetGitRoot, GetCurrentBranch | err := cmd.Run(); if err is not equal to nil; if err is not equal to nil | included 'bytes', 'os/exec', 'strings' in git.go --- git.go => git/git.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename git.go => git/git.go (97%) diff --git a/git.go b/git/git.go similarity index 97% rename from git.go rename to git/git.go index ecc4f2b..c736261 100644 --- a/git.go +++ b/git/git.go @@ -1,4 +1,4 @@ -package main +package git import ( "bytes" From 773c804c9f67eca7bc7a33e052b5011e2ff5e5d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:35:56 +0500 Subject: [PATCH 094/207] changed the 'v2.12.x' branch --- diff/diff.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/diff/diff.go b/diff/diff.go index f09f999..8c94171 100644 --- a/diff/diff.go +++ b/diff/diff.go @@ -6,6 +6,8 @@ import ( "os/exec" "strings" "sync" + + "git-auto-commit/git" ) var diffBufferPool = sync.Pool{ From a328e8aa1b3202826a6eaa3746f3d8754089ba9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:36:14 +0500 Subject: [PATCH 095/207] changed the 'v2.12.x' branch --- diff/diff.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diff/diff.go b/diff/diff.go index 8c94171..ce293e3 100644 --- a/diff/diff.go +++ b/diff/diff.go @@ -20,7 +20,7 @@ var GetDiff = func(file string) (string, error) { var builder strings.Builder builder.Reset() - root, err := GetGitRoot() + root, err := GetGitRoot() git if err != nil { return "", err } From 95300fed47a8e66b6462ac6ee1b14923b142fb69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:36:30 +0500 Subject: [PATCH 096/207] changed the 'v2.12.x' branch --- diff/diff.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diff/diff.go b/diff/diff.go index ce293e3..c5fcec1 100644 --- a/diff/diff.go +++ b/diff/diff.go @@ -20,7 +20,7 @@ var GetDiff = func(file string) (string, error) { var builder strings.Builder builder.Reset() - root, err := GetGitRoot() git + root, err := git.GetGitRoot() if err != nil { return "", err } From da773c46b604151302cf27ed0e270d5b3ec8dcf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:37:16 +0500 Subject: [PATCH 097/207] changed the 'v2.12.x' branch --- parser.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/parser.go b/parser.go index a027065..441495a 100644 --- a/parser.go +++ b/parser.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "git-auto-commit/diff" "path/filepath" "strings" "sync" @@ -45,7 +46,7 @@ var Parser = func(files []string) (string, error) { } mu.Unlock() - diff, err := GetDiff(file) + diff, err := diff.GetDiff(file) if err != nil { errChan <- fmt.Errorf("error getting diff for %s: %w", file, err) continue From 6cb051245a4833d37f10cee7274c5fa0e0a7c27d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:37:48 +0500 Subject: [PATCH 098/207] added variables: builder, workers, jobs, lang, nextMsg | added function AppendMsg --- parser.go => parser/parser.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename parser.go => parser/parser.go (99%) diff --git a/parser.go b/parser/parser.go similarity index 99% rename from parser.go rename to parser/parser.go index 441495a..4d272a8 100644 --- a/parser.go +++ b/parser/parser.go @@ -1,4 +1,4 @@ -package main +package parser import ( "fmt" From a731d4072721454a0abf10e5c8b2099f6bf3a729 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:38:03 +0500 Subject: [PATCH 099/207] included 'time' in define.go --- define.go => constants/define.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename define.go => constants/define.go (96%) diff --git a/define.go b/constants/define.go similarity index 96% rename from define.go rename to constants/define.go index 8da364a..ec6ec58 100644 --- a/define.go +++ b/constants/define.go @@ -1,4 +1,4 @@ -package main +package constants import "time" From dce987aad2c16f3e7ffd095fa4603f0a08cf945a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:38:20 +0500 Subject: [PATCH 100/207] changed the 'v2.12.x' branch --- parser/parser.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/parser/parser.go b/parser/parser.go index 4d272a8..de7cfab 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -2,6 +2,7 @@ package parser import ( "fmt" + "git-auto-commit/constants" "git-auto-commit/diff" "path/filepath" "strings" @@ -40,7 +41,7 @@ var Parser = func(files []string) (string, error) { for file := range jobs { mu.Lock() - if uint16(len(payloadMsg)) > MAX_COMMIT_LENGTH { + if uint16(len(payloadMsg)) > constants.MAX_COMMIT_LENGTH { mu.Unlock() continue } @@ -81,7 +82,7 @@ var Parser = func(files []string) (string, error) { mu.Lock() for _, change := range fileChanges { nextMsg := AppendMsg(payloadMsg, change) - if len(nextMsg) > int(MAX_COMMIT_LENGTH) { + if len(nextMsg) > int(constants.MAX_COMMIT_LENGTH) { if len(payloadMsg) == 0 { if len(change) > int(MAX_COMMIT_LENGTH) { change = change[:int(MAX_COMMIT_LENGTH)] From 2cd444175ea5c7bc7d879db9853bb14e8b179602 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:38:36 +0500 Subject: [PATCH 101/207] changed the 'v2.12.x' branch --- parser/parser.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/parser/parser.go b/parser/parser.go index de7cfab..00fbf4a 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -84,8 +84,8 @@ var Parser = func(files []string) (string, error) { nextMsg := AppendMsg(payloadMsg, change) if len(nextMsg) > int(constants.MAX_COMMIT_LENGTH) { if len(payloadMsg) == 0 { - if len(change) > int(MAX_COMMIT_LENGTH) { - change = change[:int(MAX_COMMIT_LENGTH)] + if len(change) > int(constants.MAX_COMMIT_LENGTH) { + change = change[:int(constants.MAX_COMMIT_LENGTH)] } payloadMsg = change From d00b98c2db53f93d3b8e189eda871c99f287a138 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:40:48 +0500 Subject: [PATCH 102/207] changed the 'v2.12.x' branch --- auto-logic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto-logic.go b/auto-logic.go index 2e13794..8181d61 100644 --- a/auto-logic.go +++ b/auto-logic.go @@ -169,7 +169,7 @@ func FormattedLogic(line, lang, filename string) string { result = builder.String() } - if len(result) > int(MAX_COMMIT_LENGTH) && len(newIfs) == 1 { + if len(result) > int(constants.MAX_COMMIT_LENGTH) && len(newIfs) == 1 { result = result[:int(MAX_COMMIT_LENGTH)] } From 70d28d07047d113b766621d95794b0718ccd50f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:41:04 +0500 Subject: [PATCH 103/207] changed the 'v2.12.x' branch --- auto-logic.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/auto-logic.go b/auto-logic.go index 8181d61..92db64a 100644 --- a/auto-logic.go +++ b/auto-logic.go @@ -1,6 +1,7 @@ package main import ( + "git-auto-commit/constants" "git-auto-commit/types" "regexp" "strings" @@ -170,7 +171,7 @@ func FormattedLogic(line, lang, filename string) string { } if len(result) > int(constants.MAX_COMMIT_LENGTH) && len(newIfs) == 1 { - result = result[:int(MAX_COMMIT_LENGTH)] + result = result[:int(constants.MAX_COMMIT_LENGTH)] } return result @@ -195,7 +196,7 @@ func FormattedLogic(line, lang, filename string) string { } result := makeResult(oldSwitches) - for len(result) > int(MAX_COMMIT_LENGTH) && len(oldSwitches) > 1 { + for len(result) > int(constants.MAX_COMMIT_LENGTH) && len(oldSwitches) > 1 { oldSwitches = oldSwitches[:len(oldSwitches)-1] result = makeResult(oldSwitches) } From 50107305e43121d92691dba1c5b56c7c8997eb4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:41:21 +0500 Subject: [PATCH 104/207] changed the 'v2.12.x' branch --- auto-logic.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/auto-logic.go b/auto-logic.go index 92db64a..dadda38 100644 --- a/auto-logic.go +++ b/auto-logic.go @@ -201,8 +201,8 @@ func FormattedLogic(line, lang, filename string) string { result = makeResult(oldSwitches) } - if len(result) > int(MAX_COMMIT_LENGTH) && len(oldSwitches) == 1 { - result = result[:int(MAX_COMMIT_LENGTH)] + if len(result) > int(constants.MAX_COMMIT_LENGTH) && len(oldSwitches) == 1 { + result = result[:int(constants.MAX_COMMIT_LENGTH)] } return result @@ -227,13 +227,13 @@ func FormattedLogic(line, lang, filename string) string { } result := makeResult(newSwitches) - for len(result) > int(MAX_COMMIT_LENGTH) && len(newSwitches) > 1 { + for len(result) > int(constants.MAX_COMMIT_LENGTH) && len(newSwitches) > 1 { newSwitches = newSwitches[:len(newSwitches)-1] result = makeResult(newSwitches) } - if len(result) > int(MAX_COMMIT_LENGTH) && len(newSwitches) == 1 { - result = result[:int(MAX_COMMIT_LENGTH)] + if len(result) > int(constants.MAX_COMMIT_LENGTH) && len(newSwitches) == 1 { + result = result[:int(constants.MAX_COMMIT_LENGTH)] } return result @@ -259,7 +259,7 @@ func FormattedLogic(line, lang, filename string) string { } result := makeResult(osw, nsw) - for len(result) > int(MAX_COMMIT_LENGTH) && (len(osw.Cases) > 1 || len(nsw.Cases) > 1) { + for len(result) > int(constants.MAX_COMMIT_LENGTH) && (len(osw.Cases) > 1 || len(nsw.Cases) > 1) { if len(osw.Cases) > len(nsw.Cases) { osw.Cases = osw.Cases[:len(osw.Cases)-1] } else { From 4fa2cd64d629ec210e024922733d4a210e72d027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:41:37 +0500 Subject: [PATCH 105/207] changed the 'v2.12.x' branch --- auto-logic.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/auto-logic.go b/auto-logic.go index dadda38..ef25980 100644 --- a/auto-logic.go +++ b/auto-logic.go @@ -155,7 +155,7 @@ func FormattedLogic(line, lang, filename string) string { } result := builder.String() - for len(result) > int(MAX_COMMIT_LENGTH) && len(newIfs) > 1 { + for len(result) > int(constants.MAX_COMMIT_LENGTH) && len(newIfs) > 1 { newIfs = newIfs[:len(newIfs)-1] builder.Reset() @@ -269,8 +269,8 @@ func FormattedLogic(line, lang, filename string) string { result = makeResult(osw, nsw) } - if len(result) > int(MAX_COMMIT_LENGTH) && len(osw.Cases) == 1 && len(nsw.Cases) == 1 { - result = result[:int(MAX_COMMIT_LENGTH)] + if len(result) > int(constants.MAX_COMMIT_LENGTH) && len(osw.Cases) == 1 && len(nsw.Cases) == 1 { + result = result[:int(constants.MAX_COMMIT_LENGTH)] } return result From 6d62d56b06e0e939210eafc6245607278e517a3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:41:53 +0500 Subject: [PATCH 106/207] added variables: lines, inImportBlock, trimmed, importName, quoted, l, quoted, result | added function FormattedImport --- auto-comment.go => pkg/auto-comment.go | 0 auto-function.go => pkg/auto-function.go | 0 auto-import.go => pkg/auto-import.go | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename auto-comment.go => pkg/auto-comment.go (100%) rename auto-function.go => pkg/auto-function.go (100%) rename auto-import.go => pkg/auto-import.go (100%) diff --git a/auto-comment.go b/pkg/auto-comment.go similarity index 100% rename from auto-comment.go rename to pkg/auto-comment.go diff --git a/auto-function.go b/pkg/auto-function.go similarity index 100% rename from auto-function.go rename to pkg/auto-function.go diff --git a/auto-import.go b/pkg/auto-import.go similarity index 100% rename from auto-import.go rename to pkg/auto-import.go From afebc5d758484082d0321f36aea06bd041de9ab3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:42:09 +0500 Subject: [PATCH 107/207] added variables: m, name, parent, methods, m, name, parent, methods, methodRegex, mm, mod, m, name, parent, methods, m, name, parent, methods, m, name, m, name, parent, methods, methods, methodRegex, mm, builder, lines | added variables: builder, issue, builder --- pkg/auto-comment.go | 2 +- auto-logic.go => pkg/auto-logic.go | 0 auto-oop.go => pkg/auto-oop.go | 0 auto-remote.go => pkg/auto-remote.go | 0 auto-structure.go => pkg/auto-structure.go | 0 auto-variables.go => pkg/auto-variables.go | 0 6 files changed, 1 insertion(+), 1 deletion(-) rename auto-logic.go => pkg/auto-logic.go (100%) rename auto-oop.go => pkg/auto-oop.go (100%) rename auto-remote.go => pkg/auto-remote.go (100%) rename auto-structure.go => pkg/auto-structure.go (100%) rename auto-variables.go => pkg/auto-variables.go (100%) diff --git a/pkg/auto-comment.go b/pkg/auto-comment.go index 06ab7d0..c1caffe 100644 --- a/pkg/auto-comment.go +++ b/pkg/auto-comment.go @@ -1 +1 @@ -package main +package pkg diff --git a/auto-logic.go b/pkg/auto-logic.go similarity index 100% rename from auto-logic.go rename to pkg/auto-logic.go diff --git a/auto-oop.go b/pkg/auto-oop.go similarity index 100% rename from auto-oop.go rename to pkg/auto-oop.go diff --git a/auto-remote.go b/pkg/auto-remote.go similarity index 100% rename from auto-remote.go rename to pkg/auto-remote.go diff --git a/auto-structure.go b/pkg/auto-structure.go similarity index 100% rename from auto-structure.go rename to pkg/auto-structure.go diff --git a/auto-variables.go b/pkg/auto-variables.go similarity index 100% rename from auto-variables.go rename to pkg/auto-variables.go From 013ca29b1ae908da98e8c6efe268148714998217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:43:00 +0500 Subject: [PATCH 108/207] added variables: lines, inImportBlock, trimmed, importName, quoted, l, quoted, result | added function FormattedImport | added variables: builder, issue, builder | added functions: FormattedByRemote, FormattedByBranch | added variables: m, m, typ, m, m, lines, parser --- {pkg => ac}/auto-comment.go | 0 {pkg => ac}/auto-function.go | 0 {pkg => ac}/auto-import.go | 0 {pkg => ac}/auto-logic.go | 0 {pkg => ac}/auto-oop.go | 0 {pkg => ac}/auto-remote.go | 0 {pkg => ac}/auto-structure.go | 0 {pkg => ac}/auto-variables.go | 0 8 files changed, 0 insertions(+), 0 deletions(-) rename {pkg => ac}/auto-comment.go (100%) rename {pkg => ac}/auto-function.go (100%) rename {pkg => ac}/auto-import.go (100%) rename {pkg => ac}/auto-logic.go (100%) rename {pkg => ac}/auto-oop.go (100%) rename {pkg => ac}/auto-remote.go (100%) rename {pkg => ac}/auto-structure.go (100%) rename {pkg => ac}/auto-variables.go (100%) diff --git a/pkg/auto-comment.go b/ac/auto-comment.go similarity index 100% rename from pkg/auto-comment.go rename to ac/auto-comment.go diff --git a/pkg/auto-function.go b/ac/auto-function.go similarity index 100% rename from pkg/auto-function.go rename to ac/auto-function.go diff --git a/pkg/auto-import.go b/ac/auto-import.go similarity index 100% rename from pkg/auto-import.go rename to ac/auto-import.go diff --git a/pkg/auto-logic.go b/ac/auto-logic.go similarity index 100% rename from pkg/auto-logic.go rename to ac/auto-logic.go diff --git a/pkg/auto-oop.go b/ac/auto-oop.go similarity index 100% rename from pkg/auto-oop.go rename to ac/auto-oop.go diff --git a/pkg/auto-remote.go b/ac/auto-remote.go similarity index 100% rename from pkg/auto-remote.go rename to ac/auto-remote.go diff --git a/pkg/auto-structure.go b/ac/auto-structure.go similarity index 100% rename from pkg/auto-structure.go rename to ac/auto-structure.go diff --git a/pkg/auto-variables.go b/ac/auto-variables.go similarity index 100% rename from pkg/auto-variables.go rename to ac/auto-variables.go From 3e836a7d7d9f9b20008e91acb74b6ed78c2b7f82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:43:32 +0500 Subject: [PATCH 109/207] added variables: lines, line, parser, m, name, paramsString, params, parts, m, name, params, parts, m, name, returnType, params, parts, name, params, parts, m, returnType, name, params, parts, m, name, params, parts | added variables: builder, issue, builder --- ac/auto-comment.go | 1 - acpkg/auto-comment.go | 1 + {ac => acpkg}/auto-function.go | 2 +- {ac => acpkg}/auto-import.go | 2 +- {ac => acpkg}/auto-logic.go | 0 {ac => acpkg}/auto-oop.go | 2 +- {ac => acpkg}/auto-remote.go | 2 +- {ac => acpkg}/auto-structure.go | 2 +- {ac => acpkg}/auto-variables.go | 2 +- 9 files changed, 7 insertions(+), 7 deletions(-) delete mode 100644 ac/auto-comment.go create mode 100644 acpkg/auto-comment.go rename {ac => acpkg}/auto-function.go (99%) rename {ac => acpkg}/auto-import.go (99%) rename {ac => acpkg}/auto-logic.go (100%) rename {ac => acpkg}/auto-oop.go (99%) rename {ac => acpkg}/auto-remote.go (98%) rename {ac => acpkg}/auto-structure.go (99%) rename {ac => acpkg}/auto-variables.go (99%) diff --git a/ac/auto-comment.go b/ac/auto-comment.go deleted file mode 100644 index c1caffe..0000000 --- a/ac/auto-comment.go +++ /dev/null @@ -1 +0,0 @@ -package pkg diff --git a/acpkg/auto-comment.go b/acpkg/auto-comment.go new file mode 100644 index 0000000..f3537b5 --- /dev/null +++ b/acpkg/auto-comment.go @@ -0,0 +1 @@ +package acpkg diff --git a/ac/auto-function.go b/acpkg/auto-function.go similarity index 99% rename from ac/auto-function.go rename to acpkg/auto-function.go index 28ae597..750f645 100644 --- a/ac/auto-function.go +++ b/acpkg/auto-function.go @@ -1,4 +1,4 @@ -package main +package acpkg import ( "git-auto-commit/types" diff --git a/ac/auto-import.go b/acpkg/auto-import.go similarity index 99% rename from ac/auto-import.go rename to acpkg/auto-import.go index f4664a9..dc9ba4c 100644 --- a/ac/auto-import.go +++ b/acpkg/auto-import.go @@ -1,4 +1,4 @@ -package main +package acpkg import ( "regexp" diff --git a/ac/auto-logic.go b/acpkg/auto-logic.go similarity index 100% rename from ac/auto-logic.go rename to acpkg/auto-logic.go diff --git a/ac/auto-oop.go b/acpkg/auto-oop.go similarity index 99% rename from ac/auto-oop.go rename to acpkg/auto-oop.go index 59c2690..9cd7536 100644 --- a/ac/auto-oop.go +++ b/acpkg/auto-oop.go @@ -1,4 +1,4 @@ -package main +package acpkg import ( "git-auto-commit/types" diff --git a/ac/auto-remote.go b/acpkg/auto-remote.go similarity index 98% rename from ac/auto-remote.go rename to acpkg/auto-remote.go index cdde711..127e102 100644 --- a/ac/auto-remote.go +++ b/acpkg/auto-remote.go @@ -1,4 +1,4 @@ -package main +package acpkg import ( "strconv" diff --git a/ac/auto-structure.go b/acpkg/auto-structure.go similarity index 99% rename from ac/auto-structure.go rename to acpkg/auto-structure.go index d1826d8..7a170fc 100644 --- a/ac/auto-structure.go +++ b/acpkg/auto-structure.go @@ -1,4 +1,4 @@ -package main +package acpkg import ( "git-auto-commit/types" diff --git a/ac/auto-variables.go b/acpkg/auto-variables.go similarity index 99% rename from ac/auto-variables.go rename to acpkg/auto-variables.go index 06354e1..a7411c5 100644 --- a/ac/auto-variables.go +++ b/acpkg/auto-variables.go @@ -1,4 +1,4 @@ -package main +package acpkg import ( "git-auto-commit/types" From 6f95bab6fe76014646211b9f3059bfd496904eee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:44:03 +0500 Subject: [PATCH 110/207] changed the 'v2.12.x' branch --- main.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 2f9478a..00df6a4 100644 --- a/main.go +++ b/main.go @@ -2,12 +2,14 @@ package main import ( "fmt" + "git-auto-commit/diff" + "git-auto-commit/git" "os" ) func main() { if len(os.Args) > 1 && (os.Args[1] == "-w" || os.Args[1] == "--watch") { - path, err := GetGitRoot() + path, err := git.GetGitRoot() if err != nil { ErrorLogger(err) return @@ -30,7 +32,7 @@ func main() { func AutoCommit() { GetVersion(false) - files, err := GetStagedFiles() + files, err := diff.GetStagedFiles() if err != nil { ErrorLogger(fmt.Errorf("error getting staged files: %s", err.Error())) return From 5ae25e5feb3ebfaee257f96294d0fcf5bc76c2bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:44:19 +0500 Subject: [PATCH 111/207] changed the 'v2.12.x' branch --- main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 00df6a4..e560766 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,7 @@ import ( "fmt" "git-auto-commit/diff" "git-auto-commit/git" + "git-auto-commit/parser" "os" ) @@ -43,7 +44,7 @@ func AutoCommit() { return } - parserMsg, err := Parser(files) + parserMsg, err := parser.Parser(files) if err != nil { ErrorLogger(err) return From 203c3eaf66b5deb62777c6ca06852714742e644c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:45:05 +0500 Subject: [PATCH 112/207] added variables: lines, inImportBlock, trimmed, importName, quoted, l, quoted, result | added function FormattedImport --- acpkg/{auto-comment.go => acpkg-comment.go} | 0 acpkg/{auto-function.go => acpkg-function.go} | 0 acpkg/{auto-import.go => acpkg-import.go} | 0 acpkg/{auto-logic.go => acpkg-logic.go} | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename acpkg/{auto-comment.go => acpkg-comment.go} (100%) rename acpkg/{auto-function.go => acpkg-function.go} (100%) rename acpkg/{auto-import.go => acpkg-import.go} (100%) rename acpkg/{auto-logic.go => acpkg-logic.go} (100%) diff --git a/acpkg/auto-comment.go b/acpkg/acpkg-comment.go similarity index 100% rename from acpkg/auto-comment.go rename to acpkg/acpkg-comment.go diff --git a/acpkg/auto-function.go b/acpkg/acpkg-function.go similarity index 100% rename from acpkg/auto-function.go rename to acpkg/acpkg-function.go diff --git a/acpkg/auto-import.go b/acpkg/acpkg-import.go similarity index 100% rename from acpkg/auto-import.go rename to acpkg/acpkg-import.go diff --git a/acpkg/auto-logic.go b/acpkg/acpkg-logic.go similarity index 100% rename from acpkg/auto-logic.go rename to acpkg/acpkg-logic.go From 1b18c6aafbad005cecda99f39a80042054992b82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:45:37 +0500 Subject: [PATCH 113/207] added variables: m, name, parent, methods, m, name, parent, methods, methodRegex, mm, mod, m, name, parent, methods, m, name, parent, methods, m, name, m, name, parent, methods, methods, methodRegex, mm, builder, lines | added variables: builder, issue, builder --- acpkg/{auto-oop.go => acpkg-oop.go} | 0 acpkg/{auto-remote.go => acpkg-remote.go} | 0 acpkg/{auto-structure.go => acpkg-structure.go} | 0 acpkg/{auto-variables.go => acpkg-variables.go} | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename acpkg/{auto-oop.go => acpkg-oop.go} (100%) rename acpkg/{auto-remote.go => acpkg-remote.go} (100%) rename acpkg/{auto-structure.go => acpkg-structure.go} (100%) rename acpkg/{auto-variables.go => acpkg-variables.go} (100%) diff --git a/acpkg/auto-oop.go b/acpkg/acpkg-oop.go similarity index 100% rename from acpkg/auto-oop.go rename to acpkg/acpkg-oop.go diff --git a/acpkg/auto-remote.go b/acpkg/acpkg-remote.go similarity index 100% rename from acpkg/auto-remote.go rename to acpkg/acpkg-remote.go diff --git a/acpkg/auto-structure.go b/acpkg/acpkg-structure.go similarity index 100% rename from acpkg/auto-structure.go rename to acpkg/acpkg-structure.go diff --git a/acpkg/auto-variables.go b/acpkg/acpkg-variables.go similarity index 100% rename from acpkg/auto-variables.go rename to acpkg/acpkg-variables.go From aa8758a48442d5e5888f8dd4c5efe024ce6199f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:46:08 +0500 Subject: [PATCH 114/207] added variable ext | added switch on 'ext' with cases: '.go', '.py', '.js', '.jsx', '.ts', '.tsx', '.cpp', '.c', '.h', '.java', '.cs', '.rs', '.scala' | included 'path/filepath', 'strings' in detected.go --- detected.go => achelper/detected.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename detected.go => achelper/detected.go (97%) diff --git a/detected.go b/achelper/detected.go similarity index 97% rename from detected.go rename to achelper/detected.go index c58e1c3..b9b93de 100644 --- a/detected.go +++ b/achelper/detected.go @@ -1,4 +1,4 @@ -package main +package achelper import ( "path/filepath" From 5a6476a49b607fa31227203fb934663986610748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:46:40 +0500 Subject: [PATCH 115/207] changed value in variable lang --- acpkg/acpkg-logic.go | 2 +- parser/parser.go | 24 +++++++++++++----------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/acpkg/acpkg-logic.go b/acpkg/acpkg-logic.go index ef25980..a190409 100644 --- a/acpkg/acpkg-logic.go +++ b/acpkg/acpkg-logic.go @@ -1,4 +1,4 @@ -package main +package acpkg import ( "git-auto-commit/constants" diff --git a/parser/parser.go b/parser/parser.go index 00fbf4a..caec4b2 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -2,6 +2,8 @@ package parser import ( "fmt" + "git-auto-commit/achelper" + "git-auto-commit/acpkg" "git-auto-commit/constants" "git-auto-commit/diff" "path/filepath" @@ -53,7 +55,7 @@ var Parser = func(files []string) (string, error) { continue } - lang := DetectLanguage(file) + lang := achelper.DetectLanguage(file) if lang == "" { mu.Lock() payloadMsg = AppendMsg(payloadMsg, fmt.Sprintf("the '%s' file has been changed", filepath.Base(file))) @@ -63,15 +65,15 @@ var Parser = func(files []string) (string, error) { var fileChanges []string for _, formatted := range []string{ - FormattedVariables(diff, lang), - FormattedFunction(diff, lang), - FormattedClass(diff, lang), - FormattedLogic(diff, lang, filepath.Base(file)), - FormattedImport(diff, lang, filepath.Base(file)), - FormattedStruct(diff, lang), - FormattedType(diff, lang), - FormattedInterface(diff, lang), - FormattedEnum(diff, lang), + acpkg.FormattedVariables(diff, lang), + acpkg.FormattedFunction(diff, lang), + acpkg.FormattedClass(diff, lang), + acpkg.FormattedLogic(diff, lang, filepath.Base(file)), + acpkg.FormattedImport(diff, lang, filepath.Base(file)), + acpkg.FormattedStruct(diff, lang), + acpkg.FormattedType(diff, lang), + acpkg.FormattedInterface(diff, lang), + acpkg.FormattedEnum(diff, lang), } { if formatted != "" { fileChanges = append(fileChanges, formatted) @@ -117,7 +119,7 @@ var Parser = func(files []string) (string, error) { } if len(payloadMsg) == 0 { - formattedByRemote, err := FormattedByRemote("") + formattedByRemote, err := acpkg.FormattedByRemote("") if err != nil { return "", err } From 44cf2e514cb32e5c8e5151263d613df48e0908e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:46:55 +0500 Subject: [PATCH 116/207] changed the 'v2.12.x' branch --- parser/parser.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parser/parser.go b/parser/parser.go index caec4b2..0ac7262 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -124,7 +124,7 @@ var Parser = func(files []string) (string, error) { return "", err } - formattedByBranch, err := FormattedByBranch() + formattedByBranch, err := acpkg.FormattedByBranch() if err != nil { return "", err } From 1a636290bf4bc0cc14cfea5c02f93d7ed792e5d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:47:12 +0500 Subject: [PATCH 117/207] changed the 'v2.12.x' branch --- acpkg/acpkg-function.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/acpkg/acpkg-function.go b/acpkg/acpkg-function.go index 750f645..3b4859e 100644 --- a/acpkg/acpkg-function.go +++ b/acpkg/acpkg-function.go @@ -1,6 +1,7 @@ package acpkg import ( + "git-auto-commit/constants" "git-auto-commit/types" "regexp" "strings" @@ -121,7 +122,7 @@ func FormattedFunction(diff, lang string) string { } parser := strings.Join(results, " | ") - for len(parser) > int(MAX_COMMIT_LENGTH) && len(results) > 1 { + for len(parser) > int(constants.MAX_COMMIT_LENGTH) && len(results) > 1 { results = results[:len(results)-1] parser = strings.Join(results, " | ") } From d614d61b3df3daeb330d7909de36435648c4e157 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:47:28 +0500 Subject: [PATCH 118/207] changed the 'v2.12.x' branch --- acpkg/acpkg-function.go | 4 ++-- acpkg/acpkg-import.go | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/acpkg/acpkg-function.go b/acpkg/acpkg-function.go index 3b4859e..64fff20 100644 --- a/acpkg/acpkg-function.go +++ b/acpkg/acpkg-function.go @@ -127,8 +127,8 @@ func FormattedFunction(diff, lang string) string { parser = strings.Join(results, " | ") } - if len(parser) > int(MAX_COMMIT_LENGTH) && len(results) == 1 { - parser = parser[:int(MAX_COMMIT_LENGTH)] + if len(parser) > int(constants.MAX_COMMIT_LENGTH) && len(results) == 1 { + parser = parser[:int(constants.MAX_COMMIT_LENGTH)] } return parser diff --git a/acpkg/acpkg-import.go b/acpkg/acpkg-import.go index dc9ba4c..26f8413 100644 --- a/acpkg/acpkg-import.go +++ b/acpkg/acpkg-import.go @@ -1,6 +1,7 @@ package acpkg import ( + "git-auto-commit/constants" "regexp" "strings" ) @@ -86,13 +87,13 @@ func FormattedImport(diff, lang, filename string) string { } result := "included " + strings.Join(quoted, ", ") + " in " + filename - for len(result) > int(MAX_COMMIT_LENGTH) && len(quoted) > 1 { + for len(result) > int(constants.MAX_COMMIT_LENGTH) && len(quoted) > 1 { quoted = quoted[:len(quoted)-1] result = "included " + strings.Join(quoted, ", ") + " in " + filename } - if len(result) > int(MAX_COMMIT_LENGTH) && len(quoted) == 1 { - result = result[:int(MAX_COMMIT_LENGTH)] + if len(result) > int(constants.MAX_COMMIT_LENGTH) && len(quoted) == 1 { + result = result[:int(constants.MAX_COMMIT_LENGTH)] } return result From f9bf8428fe53b1434a64bcfc447586d1c7df942e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:47:46 +0500 Subject: [PATCH 119/207] added variables: re, match, cmd, url, regex, match, builder, buf, githubIssue | added functions: ExtractIssueNumber, GetOwnerRepository, GetIssueData --- issues.go => git/issues.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename issues.go => git/issues.go (99%) diff --git a/issues.go b/git/issues.go similarity index 99% rename from issues.go rename to git/issues.go index 111710b..0c10d92 100644 --- a/issues.go +++ b/git/issues.go @@ -1,4 +1,4 @@ -package main +package git import ( "bytes" From 662d1c24219f863c1b919536ad9e77b590fbc994 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:48:04 +0500 Subject: [PATCH 120/207] changed value in variable issue --- acpkg/acpkg-remote.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/acpkg/acpkg-remote.go b/acpkg/acpkg-remote.go index 127e102..c7b6d61 100644 --- a/acpkg/acpkg-remote.go +++ b/acpkg/acpkg-remote.go @@ -1,6 +1,7 @@ package acpkg import ( + "git-auto-commit/git" "strconv" "strings" ) @@ -14,12 +15,12 @@ func FormattedByRemote(token string) (string, error) { return "", err } - issue := ExtractIssueNumber(branch) + issue := git.ExtractIssueNumber(branch) if issue == "" { return "", nil } - owner, repo, err := GetOwnerRepository() + owner, repo, err := git.GetOwnerRepository() if err != nil { return "", err } From bf84e3a05859aebce8793441755be6ade88ac0f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:48:19 +0500 Subject: [PATCH 121/207] changed the 'v2.12.x' branch --- acpkg/acpkg-remote.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acpkg/acpkg-remote.go b/acpkg/acpkg-remote.go index c7b6d61..3a3082d 100644 --- a/acpkg/acpkg-remote.go +++ b/acpkg/acpkg-remote.go @@ -25,7 +25,7 @@ func FormattedByRemote(token string) (string, error) { return "", err } - issueName, issueNumber, err := GetIssueData(owner, repo, issue, token) + issueName, issueNumber, err := git.GetIssueData(owner, repo, issue, token) if err != nil { return "", err } From 3b909f951b7051e59c598df18091a3aa77d35f92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:48:35 +0500 Subject: [PATCH 122/207] changed the 'v2.12.x' branch --- acpkg/acpkg-remote.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/acpkg/acpkg-remote.go b/acpkg/acpkg-remote.go index 3a3082d..f481fac 100644 --- a/acpkg/acpkg-remote.go +++ b/acpkg/acpkg-remote.go @@ -10,7 +10,7 @@ func FormattedByRemote(token string) (string, error) { var builder strings.Builder builder.Reset() - branch, err := GetCurrentBranch() + branch, err := git.GetCurrentBranch() if err != nil { return "", err } @@ -42,7 +42,7 @@ func FormattedByBranch() (string, error) { var builder strings.Builder builder.Reset() - branch, err := GetCurrentBranch() + branch, err := git.GetCurrentBranch() if err != nil { return "", err } From e0efc6deb1d56463048eca6c68b29708042017fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:49:21 +0500 Subject: [PATCH 123/207] changed the 'v2.12.x' branch --- json.go => config/json.go | 2 +- git/issues.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) rename json.go => config/json.go (87%) diff --git a/json.go b/config/json.go similarity index 87% rename from json.go rename to config/json.go index b406a6a..ac34300 100644 --- a/json.go +++ b/config/json.go @@ -1,4 +1,4 @@ -package main +package config import jsoniter "github.com/json-iterator/go" diff --git a/git/issues.go b/git/issues.go index 0c10d92..aa52391 100644 --- a/git/issues.go +++ b/git/issues.go @@ -4,6 +4,7 @@ import ( "bytes" "fmt" "git-auto-commit/types" + "git-auto-commit/config" "io" "net/http" "os/exec" @@ -79,7 +80,7 @@ func GetIssueData(owner, repo, issue, token string) (string, uint32, error) { } var githubIssue types.GithubIssue - if err := json.Unmarshal(buf.Bytes(), &githubIssue); err != nil { + if err := config.json.Unmarshal(buf.Bytes(), &githubIssue); err != nil { return "", 0, err } From 31de7b2be5ff7aab119e82186abf6af844e316e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:49:39 +0500 Subject: [PATCH 124/207] changed the 'v2.12.x' branch --- config/json.go | 2 +- git/issues.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/json.go b/config/json.go index ac34300..e981a89 100644 --- a/config/json.go +++ b/config/json.go @@ -2,4 +2,4 @@ package config import jsoniter "github.com/json-iterator/go" -var json = jsoniter.ConfigCompatibleWithStandardLibrary +var JSON = jsoniter.ConfigCompatibleWithStandardLibrary diff --git a/git/issues.go b/git/issues.go index aa52391..aa88e97 100644 --- a/git/issues.go +++ b/git/issues.go @@ -80,7 +80,7 @@ func GetIssueData(owner, repo, issue, token string) (string, uint32, error) { } var githubIssue types.GithubIssue - if err := config.json.Unmarshal(buf.Bytes(), &githubIssue); err != nil { + if err := config.JSON.Unmarshal(buf.Bytes(), &githubIssue); err != nil { return "", 0, err } From fc3aafe89bcf694cbbeaf3b23c6329553694051e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:49:57 +0500 Subject: [PATCH 125/207] changed the 'v2.12.x' branch --- acpkg/acpkg-variables.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acpkg/acpkg-variables.go b/acpkg/acpkg-variables.go index a7411c5..8f6b19e 100644 --- a/acpkg/acpkg-variables.go +++ b/acpkg/acpkg-variables.go @@ -129,7 +129,7 @@ func FormattedVariables(diff, lang string) string { } parser := strings.Join(results, " | ") - for len(parser) > int(MAX_COMMIT_LENGTH) && len(results) > 1 { + for len(parser) > int(constants.MAX_COMMIT_LENGTH) && len(results) > 1 { results = results[:len(results)-1] parser = strings.Join(results, " | ") } From bff8703793de0276390b0ac077bae8d7cff64281 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:50:14 +0500 Subject: [PATCH 126/207] changed the 'v2.12.x' branch --- acpkg/acpkg-variables.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/acpkg/acpkg-variables.go b/acpkg/acpkg-variables.go index 8f6b19e..46e9d04 100644 --- a/acpkg/acpkg-variables.go +++ b/acpkg/acpkg-variables.go @@ -1,6 +1,7 @@ package acpkg import ( + "git-auto-commit/constants" "git-auto-commit/types" "regexp" "strings" @@ -134,8 +135,8 @@ func FormattedVariables(diff, lang string) string { parser = strings.Join(results, " | ") } - if len(parser) > int(MAX_COMMIT_LENGTH) && len(results) == 1 { - parser = parser[:int(MAX_COMMIT_LENGTH)] + if len(parser) > int(constants.MAX_COMMIT_LENGTH) && len(results) == 1 { + parser = parser[:int(constants.MAX_COMMIT_LENGTH)] } return parser From 4052aa689d694539a5050605bfe70166a18f28fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:50:30 +0500 Subject: [PATCH 127/207] included 'git-auto-commit/diff' in test.g.go --- test.g.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test.g.go b/test.g.go index c7d2dcd..82d69b9 100644 --- a/test.g.go +++ b/test.g.go @@ -1,5 +1,7 @@ package main +import "git-auto-commit/diff" + type Mocks struct { GetStagedFiles func() ([]string, error) Parser func([]string) (string, error) @@ -11,7 +13,7 @@ type Mocks struct { func SaveMocks() *Mocks { return &Mocks{ - GetStagedFiles: GetStagedFiles, + GetStagedFiles: diffGetStagedFiles, Parser: Parser, Commit: Commit, ErrorLogger: ErrorLogger, From c596a718a683af459b331e9e0c11e12ebb2169d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:50:47 +0500 Subject: [PATCH 128/207] included 'git-auto-commit/diff', 'git-auto-commit/parser' in test.g.go --- test.g.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test.g.go b/test.g.go index 82d69b9..0857a5b 100644 --- a/test.g.go +++ b/test.g.go @@ -1,6 +1,9 @@ package main -import "git-auto-commit/diff" +import ( + "git-auto-commit/diff" + "git-auto-commit/parser" +) type Mocks struct { GetStagedFiles func() ([]string, error) @@ -13,8 +16,8 @@ type Mocks struct { func SaveMocks() *Mocks { return &Mocks{ - GetStagedFiles: diffGetStagedFiles, - Parser: Parser, + GetStagedFiles: diff.GetStagedFiles, + Parser: parser.Parser, Commit: Commit, ErrorLogger: ErrorLogger, InfoLogger: InfoLogger, From d9903b4813e8050583660522a0b1bed1168084f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:51:03 +0500 Subject: [PATCH 129/207] changed the 'v2.12.x' branch --- test.g.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test.g.go b/test.g.go index 0857a5b..38ca360 100644 --- a/test.g.go +++ b/test.g.go @@ -26,8 +26,8 @@ func SaveMocks() *Mocks { } func (m *Mocks) Apply() { - GetStagedFiles = m.GetStagedFiles - Parser = m.Parser + diff.GetStagedFiles = m.GetStagedFiles + parser.Parser = m.Parser Commit = m.Commit ErrorLogger = m.ErrorLogger InfoLogger = m.InfoLogger From 7b5228620ef556a742e78c9cc31921886777be48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:51:21 +0500 Subject: [PATCH 130/207] added variable cmd | included 'fmt', 'os', 'os/exec' in commit.go --- commit.go => git/commit.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename commit.go => git/commit.go (95%) diff --git a/commit.go b/git/commit.go similarity index 95% rename from commit.go rename to git/commit.go index 9cdfc61..9a7a077 100644 --- a/commit.go +++ b/git/commit.go @@ -1,4 +1,4 @@ -package main +package git import ( "fmt" From 9a12aed2b74585217da18820ebb167238e6dc9d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:52:09 +0500 Subject: [PATCH 131/207] added variables: builder, builder, builder | included 'fmt', 'strings' in logger.go --- logger.go => achelper/logger.go | 2 +- git/commit.go | 3 ++- test.g.go | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) rename logger.go => achelper/logger.go (97%) diff --git a/logger.go b/achelper/logger.go similarity index 97% rename from logger.go rename to achelper/logger.go index d9e0ab4..7a22b84 100644 --- a/logger.go +++ b/achelper/logger.go @@ -1,4 +1,4 @@ -package main +package achelper import ( "fmt" diff --git a/git/commit.go b/git/commit.go index 9a7a077..d8eae71 100644 --- a/git/commit.go +++ b/git/commit.go @@ -2,12 +2,13 @@ package git import ( "fmt" + "git-auto-commit/achelper" "os" "os/exec" ) var Commit = func(commitMsg string) error { - GitLogger(fmt.Sprintf("commit is: %s", commitMsg)) + achelper.GitLogger(fmt.Sprintf("commit is: %s", commitMsg)) cmd := exec.Command("git", "commit", "-m", commitMsg) cmd.Stdout = os.Stdout diff --git a/test.g.go b/test.g.go index 38ca360..2e3ba9f 100644 --- a/test.g.go +++ b/test.g.go @@ -18,7 +18,7 @@ func SaveMocks() *Mocks { return &Mocks{ GetStagedFiles: diff.GetStagedFiles, Parser: parser.Parser, - Commit: Commit, + Commit: git.Commit, ErrorLogger: ErrorLogger, InfoLogger: InfoLogger, GetVersion: GetVersion, From b6ae91df1790ccb169382fba1164ee35a91b4f22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:52:27 +0500 Subject: [PATCH 132/207] changed the 'v2.12.x' branch --- test.g.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test.g.go b/test.g.go index 2e3ba9f..5a5fc8d 100644 --- a/test.g.go +++ b/test.g.go @@ -1,7 +1,9 @@ package main import ( + "git-auto-commit/achelper" "git-auto-commit/diff" + "git-auto-commit/git" "git-auto-commit/parser" ) @@ -19,8 +21,8 @@ func SaveMocks() *Mocks { GetStagedFiles: diff.GetStagedFiles, Parser: parser.Parser, Commit: git.Commit, - ErrorLogger: ErrorLogger, - InfoLogger: InfoLogger, + ErrorLogger: achelper.ErrorLogger, + InfoLogger: achelper.InfoLogger, GetVersion: GetVersion, } } From bfe9c8474f62035879e1a1d711af979a9676abd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:52:42 +0500 Subject: [PATCH 133/207] changed the 'v2.12.x' branch --- test.g.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test.g.go b/test.g.go index 5a5fc8d..5c3d18c 100644 --- a/test.g.go +++ b/test.g.go @@ -30,8 +30,8 @@ func SaveMocks() *Mocks { func (m *Mocks) Apply() { diff.GetStagedFiles = m.GetStagedFiles parser.Parser = m.Parser - Commit = m.Commit - ErrorLogger = m.ErrorLogger - InfoLogger = m.InfoLogger + git.Commit = m.Commit + achelper.ErrorLogger = m.ErrorLogger + achelper.InfoLogger = m.InfoLogger GetVersion = m.GetVersion } From 738e58ac8b28d75c20dfaca68a21a9f11be783c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:52:59 +0500 Subject: [PATCH 134/207] changed the 'v2.12.x' branch --- version.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/version.go b/version.go index d8296e4..5b2e3ae 100644 --- a/version.go +++ b/version.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "git-auto-commit/achelper" "net/http" "os" "path/filepath" @@ -38,7 +39,7 @@ var GetVersion = func(isCurrent bool) { TagName string `json:"tag_name"` } if err := json.NewDecoder(resp.Body).Decode(&data); err != nil { - ErrorLogger(fmt.Errorf("could not parse version info: %w", err)) + achelper.ErrorLogger(fmt.Errorf("could not parse version info: %w", err)) return } From 04b2ce59d8bf5d4be53af97180f273301f2e6d13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:53:17 +0500 Subject: [PATCH 135/207] changed the 'v2.12.x' branch --- version.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/version.go b/version.go index 5b2e3ae..df68c5b 100644 --- a/version.go +++ b/version.go @@ -3,6 +3,8 @@ package main import ( "fmt" "git-auto-commit/achelper" + "git-auto-commit/config" + "git-auto-commit/git" "net/http" "os" "path/filepath" @@ -10,9 +12,9 @@ import ( ) var GetVersion = func(isCurrent bool) { - root, err := GetGitRoot() + root, err := git.GetGitRoot() if err != nil { - ErrorLogger(fmt.Errorf("could not get git root: %w", err)) + achelper.ErrorLogger(fmt.Errorf("could not get git root: %w", err)) return } @@ -38,7 +40,7 @@ var GetVersion = func(isCurrent bool) { var data struct { TagName string `json:"tag_name"` } - if err := json.NewDecoder(resp.Body).Decode(&data); err != nil { + if err := config.JSON.NewDecoder(resp.Body).Decode(&data); err != nil { achelper.ErrorLogger(fmt.Errorf("could not parse version info: %w", err)) return } From ebde60057186577cad3f95febda1b8f46f7db096 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:53:36 +0500 Subject: [PATCH 136/207] changed value in variable versionFile --- version.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/version.go b/version.go index df68c5b..b70f96e 100644 --- a/version.go +++ b/version.go @@ -4,6 +4,7 @@ import ( "fmt" "git-auto-commit/achelper" "git-auto-commit/config" + "git-auto-commit/constants" "git-auto-commit/git" "net/http" "os" @@ -18,7 +19,7 @@ var GetVersion = func(isCurrent bool) { return } - versionFile := filepath.Join(root, ".git", "hooks", VERSION_FILE) + versionFile := filepath.Join(root, ".git", "hooks", constants.VERSION_FILE) version, err := os.ReadFile(versionFile) if err != nil { From 9960d5fcc3e11b0052cba1f640323ee9e6338b13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:53:54 +0500 Subject: [PATCH 137/207] changed the 'v2.12.x' branch --- version.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/version.go b/version.go index b70f96e..1454cf1 100644 --- a/version.go +++ b/version.go @@ -23,7 +23,7 @@ var GetVersion = func(isCurrent bool) { version, err := os.ReadFile(versionFile) if err != nil { - ErrorLogger(fmt.Errorf("unknown version for auto-commit, please re-install: %w", err)) + achelper.ErrorLogger(fmt.Errorf("unknown version for auto-commit, please re-install: %w", err)) return } @@ -31,9 +31,9 @@ var GetVersion = func(isCurrent bool) { fmt.Println("[git auto-commit] current version:", strings.TrimSpace(string(version))) } - resp, err := http.Get(GITHUB_API_REPO_URL + "/releases/latest") + resp, err := http.Get(constants.GITHUB_API_REPO_URL + "/releases/latest") if err != nil { - ErrorLogger(fmt.Errorf("could not check latest version: %w", err)) + achelper.ErrorLogger(fmt.Errorf("could not check latest version: %w", err)) return } defer resp.Body.Close() From 8b6cc9a28435bee3333b2195ac521083394d84c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:54:44 +0500 Subject: [PATCH 138/207] added variables: versionFile, data, scriptUpdate, scriptUpdateExt, tmpFile | added functions: AutoCommitUpdate, downloadFile --- update.go => achelper/update.go | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename update.go => achelper/update.go (100%) diff --git a/update.go b/achelper/update.go similarity index 100% rename from update.go rename to achelper/update.go From 130d8b867e10dfed4debcd46d8dd7f6cac0fc839 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:55:01 +0500 Subject: [PATCH 139/207] added variables: versionFile, data | added variables: sigs, cmd | added function WatchCommit --- version.go => achelper/version.go | 0 watcher.go => achelper/watcher.go | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename version.go => achelper/version.go (100%) rename watcher.go => achelper/watcher.go (100%) diff --git a/version.go b/achelper/version.go similarity index 100% rename from version.go rename to achelper/version.go diff --git a/watcher.go b/achelper/watcher.go similarity index 100% rename from watcher.go rename to achelper/watcher.go From fced47f151f9460a522f74cff4b6eedf8965b38b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:55:19 +0500 Subject: [PATCH 140/207] changed the 'v2.12.x' branch --- main.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index e560766..d68b5f5 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "git-auto-commit/achelper" "git-auto-commit/diff" "git-auto-commit/git" "git-auto-commit/parser" @@ -31,27 +32,27 @@ func main() { } func AutoCommit() { - GetVersion(false) + achelper.GetVersion(false) files, err := diff.GetStagedFiles() if err != nil { - ErrorLogger(fmt.Errorf("error getting staged files: %s", err.Error())) + achelper.ErrorLogger(fmt.Errorf("error getting staged files: %s", err.Error())) return } if len(files) == 0 { - InfoLogger("No files staged for commit.") + achelper.InfoLogger("No files staged for commit.") return } parserMsg, err := parser.Parser(files) if err != nil { - ErrorLogger(err) + achelper.ErrorLogger(err) return } if err := Commit(parserMsg); err != nil { - ErrorLogger(fmt.Errorf("error committing: %s", err.Error())) + achelper.ErrorLogger(fmt.Errorf("error committing: %s", err.Error())) return } } From 03436e023cbfa3c50cef45ac084ba1c342934180 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:55:37 +0500 Subject: [PATCH 141/207] changed the 'v2.12.x' branch --- achelper/watcher.go | 2 +- main.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/achelper/watcher.go b/achelper/watcher.go index 1dd86a1..0389a8c 100644 --- a/achelper/watcher.go +++ b/achelper/watcher.go @@ -1,4 +1,4 @@ -package main +package achelper import ( "fmt" diff --git a/main.go b/main.go index d68b5f5..d904404 100644 --- a/main.go +++ b/main.go @@ -51,7 +51,7 @@ func AutoCommit() { return } - if err := Commit(parserMsg); err != nil { + if err := git.Commit(parserMsg); err != nil { achelper.ErrorLogger(fmt.Errorf("error committing: %s", err.Error())) return } From f7b61ca38fb8cdb94df6ed962b3255f5ecc8b6f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:55:57 +0500 Subject: [PATCH 142/207] changed the 'v2.12.x' branch --- achelper/update.go | 2 +- achelper/version.go | 2 +- achelper/watcher.go | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/achelper/update.go b/achelper/update.go index 66526e9..fd25734 100644 --- a/achelper/update.go +++ b/achelper/update.go @@ -1,4 +1,4 @@ -package main +package achelper import ( "fmt" diff --git a/achelper/version.go b/achelper/version.go index 1454cf1..285717d 100644 --- a/achelper/version.go +++ b/achelper/version.go @@ -1,4 +1,4 @@ -package main +package achelper import ( "fmt" diff --git a/achelper/watcher.go b/achelper/watcher.go index 0389a8c..0961dc6 100644 --- a/achelper/watcher.go +++ b/achelper/watcher.go @@ -2,6 +2,7 @@ package achelper import ( "fmt" + "git-auto-commit/diff" "os" "os/exec" "os/signal" @@ -65,7 +66,7 @@ func WatchCommit(path string) { return } - files, err := GetStagedFiles() + files, err := diff.GetStagedFiles() if err != nil { ErrorLogger(fmt.Errorf("error getting staged files: %s", err.Error())) return From 2193e6242d506eadf5b1dfb04e59d779b0cb094e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:56:45 +0500 Subject: [PATCH 143/207] changed the 'v2.12.x' branch --- achelper/version.go | 5 ++--- achelper/watcher.go | 11 +++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/achelper/version.go b/achelper/version.go index 285717d..6eab7c1 100644 --- a/achelper/version.go +++ b/achelper/version.go @@ -2,7 +2,6 @@ package achelper import ( "fmt" - "git-auto-commit/achelper" "git-auto-commit/config" "git-auto-commit/constants" "git-auto-commit/git" @@ -15,7 +14,7 @@ import ( var GetVersion = func(isCurrent bool) { root, err := git.GetGitRoot() if err != nil { - achelper.ErrorLogger(fmt.Errorf("could not get git root: %w", err)) + ErrorLogger(fmt.Errorf("could not get git root: %w", err)) return } @@ -23,7 +22,7 @@ var GetVersion = func(isCurrent bool) { version, err := os.ReadFile(versionFile) if err != nil { - achelper.ErrorLogger(fmt.Errorf("unknown version for auto-commit, please re-install: %w", err)) + ErrorLogger(fmt.Errorf("unknown version for auto-commit, please re-install: %w", err)) return } diff --git a/achelper/watcher.go b/achelper/watcher.go index 0961dc6..a93569d 100644 --- a/achelper/watcher.go +++ b/achelper/watcher.go @@ -2,7 +2,10 @@ package achelper import ( "fmt" + "git-auto-commit/constants" "git-auto-commit/diff" + "git-auto-commit/git" + "git-auto-commit/parser" "os" "os/exec" "os/signal" @@ -76,14 +79,14 @@ func WatchCommit(path string) { InfoLogger("No files staged for commit.") } - parser, err := Parser(files) + parser, err := parser.Parser(files) if err != nil { ErrorLogger(err) return } - if uint16(len(parser)) >= MAX_COMMIT_LENGTH_WATCHER { - if err := Commit(parser); err != nil { + if uint16(len(parser)) >= constants.MAX_COMMIT_LENGTH_WATCHER { + if err := git.Commit(parser); err != nil { ErrorLogger(err) } } @@ -92,6 +95,6 @@ func WatchCommit(path string) { ErrorLogger(err) } - time.Sleep(COMMIT_TIME) + time.Sleep(constants.COMMIT_TIME) } } From 73ca3458ddc2c04dd3bf76c3eeb0a5a0edd46ad9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:57:03 +0500 Subject: [PATCH 144/207] changed the 'v2.12.x' branch --- achelper/update.go | 3 ++- achelper/version.go | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/achelper/update.go b/achelper/update.go index fd25734..5d55420 100644 --- a/achelper/update.go +++ b/achelper/update.go @@ -2,6 +2,7 @@ package achelper import ( "fmt" + "git-auto-commit/git" "io" "net/http" "os" @@ -12,7 +13,7 @@ import ( ) func AutoCommitUpdate() { - root, err := GetGitRoot() + root, err := git.GetGitRoot() if err != nil { ErrorLogger(err) return diff --git a/achelper/version.go b/achelper/version.go index 6eab7c1..6d79457 100644 --- a/achelper/version.go +++ b/achelper/version.go @@ -32,7 +32,7 @@ var GetVersion = func(isCurrent bool) { resp, err := http.Get(constants.GITHUB_API_REPO_URL + "/releases/latest") if err != nil { - achelper.ErrorLogger(fmt.Errorf("could not check latest version: %w", err)) + ErrorLogger(fmt.Errorf("could not check latest version: %w", err)) return } defer resp.Body.Close() @@ -41,7 +41,7 @@ var GetVersion = func(isCurrent bool) { TagName string `json:"tag_name"` } if err := config.JSON.NewDecoder(resp.Body).Decode(&data); err != nil { - achelper.ErrorLogger(fmt.Errorf("could not parse version info: %w", err)) + ErrorLogger(fmt.Errorf("could not parse version info: %w", err)) return } From 03da2af27c99f59a7549e88b28e4f52a2038e009 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:57:21 +0500 Subject: [PATCH 145/207] changed value in variable versionFile --- achelper/update.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/achelper/update.go b/achelper/update.go index 5d55420..d4f24bf 100644 --- a/achelper/update.go +++ b/achelper/update.go @@ -2,6 +2,7 @@ package achelper import ( "fmt" + "git-auto-commit/constants" "git-auto-commit/git" "io" "net/http" @@ -19,7 +20,7 @@ func AutoCommitUpdate() { return } - versionFile := filepath.Join(root, ".git", "hooks", VERSION_FILE) + versionFile := filepath.Join(root, ".git", "hooks", constants.VERSION_FILE) version, err := os.ReadFile(versionFile) if err != nil { @@ -27,7 +28,7 @@ func AutoCommitUpdate() { return } - resp, err := http.Get(GITHUB_API_REPO_URL + "/releases/latest") + resp, err := http.Get(constants.GITHUB_API_REPO_URL + "/releases/latest") if err != nil { ErrorLogger(fmt.Errorf("could not check latest version: %w", err)) return From 94388753f35a4d0060091ee6754bbe8797abcd10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:57:38 +0500 Subject: [PATCH 146/207] changed the 'v2.12.x' branch --- achelper/update.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/achelper/update.go b/achelper/update.go index d4f24bf..dae388d 100644 --- a/achelper/update.go +++ b/achelper/update.go @@ -2,6 +2,7 @@ package achelper import ( "fmt" + "git-auto-commit/config" "git-auto-commit/constants" "git-auto-commit/git" "io" @@ -38,7 +39,7 @@ func AutoCommitUpdate() { var data struct { TagName string `json:"tag_name"` } - if err := json.NewDecoder(resp.Body).Decode(&data); err != nil { + if err := config.JSON.NewDecoder(resp.Body).Decode(&data); err != nil { ErrorLogger(fmt.Errorf("could not parse version info: %w", err)) return } From 341adab473e95ba6296bed794b125a65e8b00257 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:57:56 +0500 Subject: [PATCH 147/207] changed the 'v2.12.x' branch --- main.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index d904404..d13710e 100644 --- a/main.go +++ b/main.go @@ -13,7 +13,7 @@ func main() { if len(os.Args) > 1 && (os.Args[1] == "-w" || os.Args[1] == "--watch") { path, err := git.GetGitRoot() if err != nil { - ErrorLogger(err) + achelper.ErrorLogger(err) return } @@ -21,11 +21,11 @@ func main() { path = fmt.Sprintf("%s/%s", path, os.Args[2]) } - WatchCommit(path) + achelper.WatchCommit(path) } else if len(os.Args) > 1 && (os.Args[1] == "-v" || os.Args[1] == "--version") { - GetVersion(true) + achelper.GetVersion(true) } else if len(os.Args) > 1 && (os.Args[1] == "-u" || os.Args[1] == "--update") { - AutoCommitUpdate() + achelper.AutoCommitUpdate() } else { AutoCommit() } From f653c11d1ec4f425a8cfc373a4b4da385dca554f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:58:13 +0500 Subject: [PATCH 148/207] changed the 'v2.12.x' branch --- test.g.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test.g.go b/test.g.go index 5c3d18c..6833f8d 100644 --- a/test.g.go +++ b/test.g.go @@ -23,7 +23,7 @@ func SaveMocks() *Mocks { Commit: git.Commit, ErrorLogger: achelper.ErrorLogger, InfoLogger: achelper.InfoLogger, - GetVersion: GetVersion, + GetVersion: achelper.GetVersion, } } @@ -33,5 +33,5 @@ func (m *Mocks) Apply() { git.Commit = m.Commit achelper.ErrorLogger = m.ErrorLogger achelper.InfoLogger = m.InfoLogger - GetVersion = m.GetVersion + achelper.GetVersion = m.GetVersion } From cbcf49026419e7a4fb71eea89f9b56fd48bbf558 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 21:58:45 +0500 Subject: [PATCH 149/207] changed the 'v2.12.x' branch --- git/issues.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git/issues.go b/git/issues.go index aa88e97..d010753 100644 --- a/git/issues.go +++ b/git/issues.go @@ -3,8 +3,8 @@ package git import ( "bytes" "fmt" - "git-auto-commit/types" "git-auto-commit/config" + "git-auto-commit/types" "io" "net/http" "os/exec" From 81b4e4a039dc266ab716feabb48e97ab8a06f922 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:00:06 +0500 Subject: [PATCH 150/207] added variables: builder, builder, builder | included 'fmt', 'strings' in logger.go --- achelper/{ => logger}/logger.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename achelper/{ => logger}/logger.go (97%) diff --git a/achelper/logger.go b/achelper/logger/logger.go similarity index 97% rename from achelper/logger.go rename to achelper/logger/logger.go index 7a22b84..d4b380a 100644 --- a/achelper/logger.go +++ b/achelper/logger/logger.go @@ -1,4 +1,4 @@ -package achelper +package logger import ( "fmt" From 249287e7bcf292df4b1333e2168dc94587a9286e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:00:22 +0500 Subject: [PATCH 151/207] changed the 'v2.12.x' branch --- achelper/watcher.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/achelper/watcher.go b/achelper/watcher.go index a93569d..6e3d84d 100644 --- a/achelper/watcher.go +++ b/achelper/watcher.go @@ -2,6 +2,7 @@ package achelper import ( "fmt" + "git-auto-commit/achelper/logger" "git-auto-commit/constants" "git-auto-commit/diff" "git-auto-commit/git" @@ -22,12 +23,12 @@ func WatchCommit(path string) { watcher, err := fsnotify.NewWatcher() if err != nil { - ErrorLogger(err) + logger.ErrorLogger(err) return } defer watcher.Close() - InfoLogger("Started commit watcher...") + logger.InfoLogger("Started commit watcher...") if err := filepath.Walk(path, func(path string, info os.FileInfo, err error) error { if info.IsDir() && !strings.HasPrefix(path, ".git") { From fc3a7d37cb867eeafc6ff953e869071f92eb6750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:00:38 +0500 Subject: [PATCH 152/207] changed the 'v2.12.x' branch --- achelper/watcher.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/achelper/watcher.go b/achelper/watcher.go index 6e3d84d..3d49de5 100644 --- a/achelper/watcher.go +++ b/achelper/watcher.go @@ -39,7 +39,7 @@ func WatchCommit(path string) { return nil }); err != nil { - ErrorLogger(err) + logger.ErrorLogger(err) return } @@ -47,7 +47,7 @@ func WatchCommit(path string) { signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) go func() { <-sigs - InfoLogger("shutdown work watcher...") + logger.InfoLogger("shutdown work watcher...") os.Exit(0) }() @@ -66,7 +66,7 @@ func WatchCommit(path string) { } if err := exec.Command("git", "add", ".").Run(); err != nil { - ErrorLogger(err) + logger.ErrorLogger(err) return } From 9ecd233208e0f3219ff4e95d44738aa82507acd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:00:54 +0500 Subject: [PATCH 153/207] changed the 'v2.12.x' branch --- achelper/watcher.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/achelper/watcher.go b/achelper/watcher.go index 3d49de5..77dbc61 100644 --- a/achelper/watcher.go +++ b/achelper/watcher.go @@ -72,12 +72,12 @@ func WatchCommit(path string) { files, err := diff.GetStagedFiles() if err != nil { - ErrorLogger(fmt.Errorf("error getting staged files: %s", err.Error())) + logger.ErrorLogger(fmt.Errorf("error getting staged files: %s", err.Error())) return } if len(files) == 0 { - InfoLogger("No files staged for commit.") + logger.InfoLogger("No files staged for commit.") } parser, err := parser.Parser(files) From 18b5102df695d7c011f07106918d7e95bf830d8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:01:11 +0500 Subject: [PATCH 154/207] changed the 'v2.12.x' branch --- achelper/watcher.go | 6 +++--- git/commit.go | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/achelper/watcher.go b/achelper/watcher.go index 77dbc61..b7dbd51 100644 --- a/achelper/watcher.go +++ b/achelper/watcher.go @@ -82,18 +82,18 @@ func WatchCommit(path string) { parser, err := parser.Parser(files) if err != nil { - ErrorLogger(err) + logger.ErrorLogger(err) return } if uint16(len(parser)) >= constants.MAX_COMMIT_LENGTH_WATCHER { if err := git.Commit(parser); err != nil { - ErrorLogger(err) + logger.ErrorLogger(err) } } } case err := <-watcher.Errors: - ErrorLogger(err) + logger.ErrorLogger(err) } time.Sleep(constants.COMMIT_TIME) diff --git a/git/commit.go b/git/commit.go index d8eae71..f6a5726 100644 --- a/git/commit.go +++ b/git/commit.go @@ -2,7 +2,6 @@ package git import ( "fmt" - "git-auto-commit/achelper" "os" "os/exec" ) From 25695f0d284fb77c0d4d6a7c9927827ceeecdcfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:01:28 +0500 Subject: [PATCH 155/207] changed the 'v2.12.x' branch --- git/commit.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/git/commit.go b/git/commit.go index f6a5726..995974f 100644 --- a/git/commit.go +++ b/git/commit.go @@ -2,12 +2,13 @@ package git import ( "fmt" + "git-auto-commit/achelper/logger" "os" "os/exec" ) var Commit = func(commitMsg string) error { - achelper.GitLogger(fmt.Sprintf("commit is: %s", commitMsg)) + logger.GitLogger(fmt.Sprintf("commit is: %s", commitMsg)) cmd := exec.Command("git", "commit", "-m", commitMsg) cmd.Stdout = os.Stdout From 8534246b10ff8f3208081a09f894904a21be18cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:02:33 +0500 Subject: [PATCH 156/207] added variable ext | added switch on 'ext' with cases: '.go', '.py', '.js', '.jsx', '.ts', '.tsx', '.cpp', '.c', '.h', '.java', '.cs', '.rs', '.scala' | included 'path/filepath', 'strings' in detected.go --- achelper/{ => code}/detected.go | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename achelper/{ => code}/detected.go (100%) diff --git a/achelper/detected.go b/achelper/code/detected.go similarity index 100% rename from achelper/detected.go rename to achelper/code/detected.go From 3f1af95b5ae4f2b3899ef267fe8efa065b1383ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:02:50 +0500 Subject: [PATCH 157/207] changed value in variable lang --- achelper/code/detected.go | 2 +- parser/parser.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/achelper/code/detected.go b/achelper/code/detected.go index b9b93de..e3a7072 100644 --- a/achelper/code/detected.go +++ b/achelper/code/detected.go @@ -1,4 +1,4 @@ -package achelper +package code import ( "path/filepath" diff --git a/parser/parser.go b/parser/parser.go index 0ac7262..8e14ecb 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -55,7 +55,7 @@ var Parser = func(files []string) (string, error) { continue } - lang := achelper.DetectLanguage(file) + lang := code.DetectLanguage(file) if lang == "" { mu.Lock() payloadMsg = AppendMsg(payloadMsg, fmt.Sprintf("the '%s' file has been changed", filepath.Base(file))) From 716624d56131d49e7e10637d45fe797bb0debaf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:03:06 +0500 Subject: [PATCH 158/207] changed the 'v2.12.x' branch --- parser/parser.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parser/parser.go b/parser/parser.go index 8e14ecb..d53ca52 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -2,7 +2,7 @@ package parser import ( "fmt" - "git-auto-commit/achelper" + "git-auto-commit/achelper/code" "git-auto-commit/acpkg" "git-auto-commit/constants" "git-auto-commit/diff" From 9af19b629cd089382812507f040d84d8a1d7d760 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:04:12 +0500 Subject: [PATCH 159/207] changed the 'v2.12.x' branch --- achelper/update.go | 13 +++++++------ achelper/version.go | 9 +++++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/achelper/update.go b/achelper/update.go index dae388d..90074fd 100644 --- a/achelper/update.go +++ b/achelper/update.go @@ -2,6 +2,7 @@ package achelper import ( "fmt" + "git-auto-commit/achelper/logger" "git-auto-commit/config" "git-auto-commit/constants" "git-auto-commit/git" @@ -17,7 +18,7 @@ import ( func AutoCommitUpdate() { root, err := git.GetGitRoot() if err != nil { - ErrorLogger(err) + logger.ErrorLogger(err) return } @@ -25,13 +26,13 @@ func AutoCommitUpdate() { version, err := os.ReadFile(versionFile) if err != nil { - ErrorLogger(fmt.Errorf("unknown version for auto-commit, please re-install: %w", err)) + logger.ErrorLogger(fmt.Errorf("unknown version for auto-commit, please re-install: %w", err)) return } resp, err := http.Get(constants.GITHUB_API_REPO_URL + "/releases/latest") if err != nil { - ErrorLogger(fmt.Errorf("could not check latest version: %w", err)) + logger.ErrorLogger(fmt.Errorf("could not check latest version: %w", err)) return } defer resp.Body.Close() @@ -40,7 +41,7 @@ func AutoCommitUpdate() { TagName string `json:"tag_name"` } if err := config.JSON.NewDecoder(resp.Body).Decode(&data); err != nil { - ErrorLogger(fmt.Errorf("could not parse version info: %w", err)) + logger.ErrorLogger(fmt.Errorf("could not parse version info: %w", err)) return } @@ -64,7 +65,7 @@ func AutoCommitUpdate() { tmpFile := filepath.Join(os.TempDir(), "auto-commit-update"+scriptUpdateExt) err = downloadFile(scriptUpdate, tmpFile) if err != nil { - ErrorLogger(fmt.Errorf("failed to download update script: %v", err)) + logger.ErrorLogger(fmt.Errorf("failed to download update script: %v", err)) return } defer os.Remove(tmpFile) @@ -80,7 +81,7 @@ func AutoCommitUpdate() { cmd.Stderr = os.Stderr if err := cmd.Run(); err != nil { - ErrorLogger(fmt.Errorf("failed to run update script: %v", err)) + logger.ErrorLogger(fmt.Errorf("failed to run update script: %v", err)) return } } diff --git a/achelper/version.go b/achelper/version.go index 6d79457..9c87b59 100644 --- a/achelper/version.go +++ b/achelper/version.go @@ -2,6 +2,7 @@ package achelper import ( "fmt" + "git-auto-commit/achelper/logger" "git-auto-commit/config" "git-auto-commit/constants" "git-auto-commit/git" @@ -14,7 +15,7 @@ import ( var GetVersion = func(isCurrent bool) { root, err := git.GetGitRoot() if err != nil { - ErrorLogger(fmt.Errorf("could not get git root: %w", err)) + logger.ErrorLogger(fmt.Errorf("could not get git root: %w", err)) return } @@ -22,7 +23,7 @@ var GetVersion = func(isCurrent bool) { version, err := os.ReadFile(versionFile) if err != nil { - ErrorLogger(fmt.Errorf("unknown version for auto-commit, please re-install: %w", err)) + logger.ErrorLogger(fmt.Errorf("unknown version for auto-commit, please re-install: %w", err)) return } @@ -32,7 +33,7 @@ var GetVersion = func(isCurrent bool) { resp, err := http.Get(constants.GITHUB_API_REPO_URL + "/releases/latest") if err != nil { - ErrorLogger(fmt.Errorf("could not check latest version: %w", err)) + logger.ErrorLogger(fmt.Errorf("could not check latest version: %w", err)) return } defer resp.Body.Close() @@ -41,7 +42,7 @@ var GetVersion = func(isCurrent bool) { TagName string `json:"tag_name"` } if err := config.JSON.NewDecoder(resp.Body).Decode(&data); err != nil { - ErrorLogger(fmt.Errorf("could not parse version info: %w", err)) + logger.ErrorLogger(fmt.Errorf("could not parse version info: %w", err)) return } From 95cf4052c4ce766ae06b23c469ccef1f66179290 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:04:30 +0500 Subject: [PATCH 160/207] changed the 'v2.12.x' branch --- main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index d13710e..bd0cdb8 100644 --- a/main.go +++ b/main.go @@ -3,6 +3,7 @@ package main import ( "fmt" "git-auto-commit/achelper" + "git-auto-commit/achelper/logger" "git-auto-commit/diff" "git-auto-commit/git" "git-auto-commit/parser" @@ -13,7 +14,7 @@ func main() { if len(os.Args) > 1 && (os.Args[1] == "-w" || os.Args[1] == "--watch") { path, err := git.GetGitRoot() if err != nil { - achelper.ErrorLogger(err) + logger.ErrorLogger(err) return } From a9019a12b09d419bb592df13238b10499b61a0d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:04:47 +0500 Subject: [PATCH 161/207] changed the 'v2.12.x' branch --- main.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index bd0cdb8..817e20e 100644 --- a/main.go +++ b/main.go @@ -37,23 +37,23 @@ func AutoCommit() { files, err := diff.GetStagedFiles() if err != nil { - achelper.ErrorLogger(fmt.Errorf("error getting staged files: %s", err.Error())) + logger.ErrorLogger(fmt.Errorf("error getting staged files: %s", err.Error())) return } if len(files) == 0 { - achelper.InfoLogger("No files staged for commit.") + logger.InfoLogger("No files staged for commit.") return } parserMsg, err := parser.Parser(files) if err != nil { - achelper.ErrorLogger(err) + logger.ErrorLogger(err) return } if err := git.Commit(parserMsg); err != nil { - achelper.ErrorLogger(fmt.Errorf("error committing: %s", err.Error())) + logger.ErrorLogger(fmt.Errorf("error committing: %s", err.Error())) return } } From 7b153e36f13e8059d1f7645360d53e599980d629 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:05:03 +0500 Subject: [PATCH 162/207] changed the 'v2.12.x' branch --- test.g.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test.g.go b/test.g.go index 6833f8d..4743f15 100644 --- a/test.g.go +++ b/test.g.go @@ -2,6 +2,7 @@ package main import ( "git-auto-commit/achelper" + "git-auto-commit/achelper/logger" "git-auto-commit/diff" "git-auto-commit/git" "git-auto-commit/parser" @@ -21,8 +22,8 @@ func SaveMocks() *Mocks { GetStagedFiles: diff.GetStagedFiles, Parser: parser.Parser, Commit: git.Commit, - ErrorLogger: achelper.ErrorLogger, - InfoLogger: achelper.InfoLogger, + ErrorLogger: logger.ErrorLogger, + InfoLogger: logger.InfoLogger, GetVersion: achelper.GetVersion, } } @@ -31,7 +32,7 @@ func (m *Mocks) Apply() { diff.GetStagedFiles = m.GetStagedFiles parser.Parser = m.Parser git.Commit = m.Commit - achelper.ErrorLogger = m.ErrorLogger - achelper.InfoLogger = m.InfoLogger + logger.ErrorLogger = m.ErrorLogger + logger.InfoLogger = m.InfoLogger achelper.GetVersion = m.GetVersion } From 72c762e1e840005508982fe6f92e188e760f182e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:05:35 +0500 Subject: [PATCH 163/207] added variables: mocks, calledInfo, mocks, calledErr, expected | added functions: TestAutoCommit_NoStagedFiles, TestAutoCommit_ErrorGettingFiles | if calledInfo is not equal to No files staged for commit."; if calledErr is not equal to expected | included 'errors', 'testing' in auto-commit_test.go --- auto-commit_test.go => tests/auto-commit_test.go | 0 auto-function_test.go => tests/auto-function_test.go | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename auto-commit_test.go => tests/auto-commit_test.go (100%) rename auto-function_test.go => tests/auto-function_test.go (100%) diff --git a/auto-commit_test.go b/tests/auto-commit_test.go similarity index 100% rename from auto-commit_test.go rename to tests/auto-commit_test.go diff --git a/auto-function_test.go b/tests/auto-function_test.go similarity index 100% rename from auto-function_test.go rename to tests/auto-function_test.go From 3246deb16e1d3dd97474815d90a4430371543867 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:05:52 +0500 Subject: [PATCH 164/207] added variables: mocks, expected | added functions: TestParser_AddedGoFunction, TestParser | if err is not equal to nil; if msg is not equal to expected | included 'testing' in af_test.go | added variables: mocks, calledInfo, mocks, calledErr, expected --- tests/{auto-commit_test.go => ac_test.go} | 0 tests/{auto-function_test.go => af_test.go} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename tests/{auto-commit_test.go => ac_test.go} (100%) rename tests/{auto-function_test.go => af_test.go} (100%) diff --git a/tests/auto-commit_test.go b/tests/ac_test.go similarity index 100% rename from tests/auto-commit_test.go rename to tests/ac_test.go diff --git a/tests/auto-function_test.go b/tests/af_test.go similarity index 100% rename from tests/auto-function_test.go rename to tests/af_test.go From a65ed55b1225ffef2da20e777411886aec772eb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:06:09 +0500 Subject: [PATCH 165/207] added function SaveMocks | included 'git-auto-commit/achelper', 'git-auto-commit/achelper/logger', 'git-auto-commit/diff', 'git-auto-commit/git', 'git-auto-commit/parser' in test.g.go | added structure Mocks | added type Mocks --- test.g.go => tests/test.g.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename test.g.go => tests/test.g.go (98%) diff --git a/test.g.go b/tests/test.g.go similarity index 98% rename from test.g.go rename to tests/test.g.go index 4743f15..3b75aad 100644 --- a/test.g.go +++ b/tests/test.g.go @@ -1,4 +1,4 @@ -package main +package tests import ( "git-auto-commit/achelper" From 3f7af74d39b32098c8a796fdd33a289a6ea1fcd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:06:27 +0500 Subject: [PATCH 166/207] changed the 'v2.12.x' branch --- tests/ac_test.go | 2 +- tests/af_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ac_test.go b/tests/ac_test.go index 33266d4..4fd2c24 100644 --- a/tests/ac_test.go +++ b/tests/ac_test.go @@ -1,4 +1,4 @@ -package main +package tests import ( "errors" diff --git a/tests/af_test.go b/tests/af_test.go index 6c7fa6c..a0158c9 100644 --- a/tests/af_test.go +++ b/tests/af_test.go @@ -1,4 +1,4 @@ -package main +package tests import "testing" From 4f2420fd82c8835d142ea76f2da168fbc02c64bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:07:30 +0500 Subject: [PATCH 167/207] included 'git-auto-commit/achelper/code', 'git-auto-commit/diff', 'git-auto-commit/parser', 'testing' in af_test.go --- tests/af_test.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/af_test.go b/tests/af_test.go index a0158c9..9951ebb 100644 --- a/tests/af_test.go +++ b/tests/af_test.go @@ -1,20 +1,25 @@ package tests -import "testing" +import ( + "git-auto-commit/achelper/code" + "git-auto-commit/diff" + "git-auto-commit/parser" + "testing" +) func TestParser_AddedGoFunction(t *testing.T) { mocks := SaveMocks() defer mocks.Apply() - GetDiff = func(file string) (string, error) { + diff.GetDiff = func(file string) (string, error) { return "+func TestParser()", nil } - DetectLanguage = func(filename string) string { + code.DetectLanguage = func(filename string) string { return "go" } - msg, err := Parser([]string{"auto-commit-parser-test.go"}) + msg, err := parser.Parser([]string{"auto-commit-parser-test.go"}) if err != nil { t.Fatalf("unexpected error: %v", err) } From af4fccd5080355b26fcb5205f75a962aa2908a22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:08:16 +0500 Subject: [PATCH 168/207] changed the 'v2.12.x' branch --- tests/ac_test.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/ac_test.go b/tests/ac_test.go index 4fd2c24..c2e42c7 100644 --- a/tests/ac_test.go +++ b/tests/ac_test.go @@ -2,6 +2,9 @@ package tests import ( "errors" + "git-auto-commit/achelper/logger" + "git-auto-commit/diff" + "git-auto-commit/parser" "testing" ) @@ -10,11 +13,11 @@ func TestAutoCommit_NoStagedFiles(t *testing.T) { defer mocks.Apply() calledInfo := "" - GetStagedFiles = func() ([]string, error) { return []string{}, nil } - Parser = func(files []string) (string, error) { return "", nil } - Commit = func(msg string) error { return nil } - ErrorLogger = func(err error) { t.Errorf("unexpected error: %v", err) } - InfoLogger = func(msg string) { calledInfo = msg } + diff.GetStagedFiles = func() ([]string, error) { return []string{}, nil } + parser.Parser = func(files []string) (string, error) { return "", nil } + git.Commit = func(msg string) error { return nil } + logger.ErrorLogger = func(err error) { t.Errorf("unexpected error: %v", err) } + logger.InfoLogger = func(msg string) { calledInfo = msg } GetVersion = func(show bool) {} AutoCommit() From a925a9cb58a72e05ccbb785ce4606ad600dc2ef6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:08:34 +0500 Subject: [PATCH 169/207] changed the 'v2.12.x' branch --- tests/ac_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/ac_test.go b/tests/ac_test.go index c2e42c7..c3d4e01 100644 --- a/tests/ac_test.go +++ b/tests/ac_test.go @@ -2,8 +2,10 @@ package tests import ( "errors" + "git-auto-commit/achelper" "git-auto-commit/achelper/logger" "git-auto-commit/diff" + "git-auto-commit/git" "git-auto-commit/parser" "testing" ) @@ -18,7 +20,7 @@ func TestAutoCommit_NoStagedFiles(t *testing.T) { git.Commit = func(msg string) error { return nil } logger.ErrorLogger = func(err error) { t.Errorf("unexpected error: %v", err) } logger.InfoLogger = func(msg string) { calledInfo = msg } - GetVersion = func(show bool) {} + achelper.GetVersion = func(show bool) {} AutoCommit() From 191328c497d79956b3a4091ed5fcfe3bfc00d3ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:10:11 +0500 Subject: [PATCH 170/207] added function AutoCommit | if err is not equal to nil; added condition logic: len(files) == 0; if err is not equal to nil; err := git.Commit(parserMsg); if err is not equal to nil | deleted function AutoCommit --- ac/ac.go | 36 ++++++++++++++++++++++++++++++++++++ main.go | 26 -------------------------- 2 files changed, 36 insertions(+), 26 deletions(-) create mode 100644 ac/ac.go diff --git a/ac/ac.go b/ac/ac.go new file mode 100644 index 0000000..d622068 --- /dev/null +++ b/ac/ac.go @@ -0,0 +1,36 @@ +package acpkg + +import ( + "fmt" + "git-auto-commit/achelper" + "git-auto-commit/achelper/logger" + "git-auto-commit/diff" + "git-auto-commit/git" + "git-auto-commit/parser" +) + +func AutoCommit() { + achelper.GetVersion(false) + + files, err := diff.GetStagedFiles() + if err != nil { + logger.ErrorLogger(fmt.Errorf("error getting staged files: %s", err.Error())) + return + } + + if len(files) == 0 { + logger.InfoLogger("No files staged for commit.") + return + } + + parserMsg, err := parser.Parser(files) + if err != nil { + logger.ErrorLogger(err) + return + } + + if err := git.Commit(parserMsg); err != nil { + logger.ErrorLogger(fmt.Errorf("error committing: %s", err.Error())) + return + } +} diff --git a/main.go b/main.go index 817e20e..f1bd62f 100644 --- a/main.go +++ b/main.go @@ -31,29 +31,3 @@ func main() { AutoCommit() } } - -func AutoCommit() { - achelper.GetVersion(false) - - files, err := diff.GetStagedFiles() - if err != nil { - logger.ErrorLogger(fmt.Errorf("error getting staged files: %s", err.Error())) - return - } - - if len(files) == 0 { - logger.InfoLogger("No files staged for commit.") - return - } - - parserMsg, err := parser.Parser(files) - if err != nil { - logger.ErrorLogger(err) - return - } - - if err := git.Commit(parserMsg); err != nil { - logger.ErrorLogger(fmt.Errorf("error committing: %s", err.Error())) - return - } -} From 3c618c60437f809953b91ad26b3aee39ded1dd35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:10:27 +0500 Subject: [PATCH 171/207] changed the 'v2.12.x' branch --- main.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index f1bd62f..42e773f 100644 --- a/main.go +++ b/main.go @@ -4,9 +4,7 @@ import ( "fmt" "git-auto-commit/achelper" "git-auto-commit/achelper/logger" - "git-auto-commit/diff" - "git-auto-commit/git" - "git-auto-commit/parser" + "git-auto-commit/ac" "os" ) @@ -28,6 +26,6 @@ func main() { } else if len(os.Args) > 1 && (os.Args[1] == "-u" || os.Args[1] == "--update") { achelper.AutoCommitUpdate() } else { - AutoCommit() + ac.AutoCommit() } } From 1c72b86093fc1ff7f65ec540870f27fecdc0ef71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:10:43 +0500 Subject: [PATCH 172/207] changed the 'v2.12.x' branch --- ac/ac.go | 2 +- main.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ac/ac.go b/ac/ac.go index d622068..ff860d8 100644 --- a/ac/ac.go +++ b/ac/ac.go @@ -1,4 +1,4 @@ -package acpkg +package ac import ( "fmt" diff --git a/main.go b/main.go index 42e773f..0db4f56 100644 --- a/main.go +++ b/main.go @@ -2,9 +2,10 @@ package main import ( "fmt" + "git-auto-commit/ac" "git-auto-commit/achelper" "git-auto-commit/achelper/logger" - "git-auto-commit/ac" + "git-auto-commit/git" "os" ) From 0aeef33a7c9f7a8f75f4f6d0abab83ee1033cd8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:11:01 +0500 Subject: [PATCH 173/207] changed the 'v2.12.x' branch --- tests/ac_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ac_test.go b/tests/ac_test.go index c3d4e01..d239649 100644 --- a/tests/ac_test.go +++ b/tests/ac_test.go @@ -22,7 +22,7 @@ func TestAutoCommit_NoStagedFiles(t *testing.T) { logger.InfoLogger = func(msg string) { calledInfo = msg } achelper.GetVersion = func(show bool) {} - AutoCommit() + ac.AutoCommit() if calledInfo != "No files staged for commit." { t.Errorf("expected info log 'No files staged for commit.', got '%s'", calledInfo) From 8a8929313746727d08ea133c58a66d5d15b7eff0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:11:18 +0500 Subject: [PATCH 174/207] changed the 'v2.12.x' branch --- tests/ac_test.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/ac_test.go b/tests/ac_test.go index d239649..864961b 100644 --- a/tests/ac_test.go +++ b/tests/ac_test.go @@ -2,6 +2,7 @@ package tests import ( "errors" + "git-auto-commit/ac" "git-auto-commit/achelper" "git-auto-commit/achelper/logger" "git-auto-commit/diff" @@ -36,15 +37,15 @@ func TestAutoCommit_ErrorGettingFiles(t *testing.T) { GetStagedFiles = func() ([]string, error) { return nil, errors.New("fail") } Parser = func(files []string) (string, error) { return "", nil } Commit = func(msg string) error { return nil } - InfoLogger = func(msg string) {} - GetVersion = func(show bool) {} + logger.InfoLogger = func(msg string) {} + achelper.GetVersion = func(show bool) {} var calledErr string - ErrorLogger = func(err error) { calledErr = err.Error() } + logger.ErrorLogger = func(err error) { calledErr = err.Error() } - InfoLogger = func(msg string) { calledErr = msg } + logger.InfoLogger = func(msg string) { calledErr = msg } - AutoCommit() + ac.AutoCommit() expected := "error getting staged files: fail" if calledErr != expected { From 6f4ffa16290de596d558abea7f954b4814c445cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:11:35 +0500 Subject: [PATCH 175/207] changed the 'v2.12.x' branch --- tests/ac_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/ac_test.go b/tests/ac_test.go index 864961b..6b8bc98 100644 --- a/tests/ac_test.go +++ b/tests/ac_test.go @@ -34,9 +34,9 @@ func TestAutoCommit_ErrorGettingFiles(t *testing.T) { mocks := SaveMocks() defer mocks.Apply() - GetStagedFiles = func() ([]string, error) { return nil, errors.New("fail") } - Parser = func(files []string) (string, error) { return "", nil } - Commit = func(msg string) error { return nil } + diff.GetStagedFiles = func() ([]string, error) { return nil, errors.New("fail") } + parser.Parser = func(files []string) (string, error) { return "", nil } + git.Commit = func(msg string) error { return nil } logger.InfoLogger = func(msg string) {} achelper.GetVersion = func(show bool) {} From c15c5b6d07c8aa3ee67ed1cddd10ee4799e3efe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:15:40 +0500 Subject: [PATCH 176/207] added variables: mocks, expected, mocks, expected | added functions: TestParser_DeletedGoFunction, TestParser, TestParser_DeletedGoFunction, TestParser | if err is not equal to nil; if msg is not equal to expected; if err is not equal to nil; if msg is not equal to expected --- tests/af_test.go | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/tests/af_test.go b/tests/af_test.go index 9951ebb..09cc4a1 100644 --- a/tests/af_test.go +++ b/tests/af_test.go @@ -29,3 +29,49 @@ func TestParser_AddedGoFunction(t *testing.T) { t.Errorf("expected '%s', got '%s'", expected, msg) } } + +func TestParser_DeletedGoFunction(t *testing.T) { + mocks := SaveMocks() + defer mocks.Apply() + + diff.GetDiff = func(file string) (string, error) { + return "-func TestParser()", nil + } + + code.DetectLanguage = func(filename string) string { + return "go" + } + + msg, err := parser.Parser([]string{"auto-commit-parser-test.go"}) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + expected := "deleted function TestParser" + if msg != expected { + t.Errorf("expected '%s', got '%s'", expected, msg) + } +} + +func TestParser_DeletedGoFunction(t *testing.T) { + mocks := SaveMocks() + defer mocks.Apply() + + diff.GetDiff = func(file string) (string, error) { + return "-func TestParser()", nil + } + + code.DetectLanguage = func(filename string) string { + return "go" + } + + msg, err := parser.Parser([]string{"auto-commit-parser-test.go"}) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + expected := "deleted function TestParser" + if msg != expected { + t.Errorf("expected '%s', got '%s'", expected, msg) + } +} From 2125ef7c0de24fcdfc89fda2759c854f2db8cb4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:15:56 +0500 Subject: [PATCH 177/207] renamed function TestParser_DeletedGoFunction -> TestParser_RenamedGoFunction --- tests/af_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/af_test.go b/tests/af_test.go index 09cc4a1..b411dc3 100644 --- a/tests/af_test.go +++ b/tests/af_test.go @@ -53,7 +53,7 @@ func TestParser_DeletedGoFunction(t *testing.T) { } } -func TestParser_DeletedGoFunction(t *testing.T) { +func TestParser_RenamedGoFunction(t *testing.T) { mocks := SaveMocks() defer mocks.Apply() From 104748165401c381790598b74e40f2d12bd95714 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:16:12 +0500 Subject: [PATCH 178/207] changed the 'v2.12.x' branch --- tests/af_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/af_test.go b/tests/af_test.go index b411dc3..9b822a3 100644 --- a/tests/af_test.go +++ b/tests/af_test.go @@ -58,7 +58,7 @@ func TestParser_RenamedGoFunction(t *testing.T) { defer mocks.Apply() diff.GetDiff = func(file string) (string, error) { - return "-func TestParser()", nil + return "-func TestParser()\n+func TestParser()", nil } code.DetectLanguage = func(filename string) string { From 58be57244e9d55439413c3dbe80074d64016f736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:16:28 +0500 Subject: [PATCH 179/207] changed value in variable expected --- tests/af_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/af_test.go b/tests/af_test.go index 9b822a3..83d9b98 100644 --- a/tests/af_test.go +++ b/tests/af_test.go @@ -35,7 +35,7 @@ func TestParser_DeletedGoFunction(t *testing.T) { defer mocks.Apply() diff.GetDiff = func(file string) (string, error) { - return "-func TestParser()", nil + return "-func TestParser() {}", nil } code.DetectLanguage = func(filename string) string { @@ -70,7 +70,7 @@ func TestParser_RenamedGoFunction(t *testing.T) { t.Fatalf("unexpected error: %v", err) } - expected := "deleted function TestParser" + expected := "renamed function TestParser -> TestParser" if msg != expected { t.Errorf("expected '%s', got '%s'", expected, msg) } From 5c0b732c5ea3822845e0c9bc80968d438badaa6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:17:51 +0500 Subject: [PATCH 180/207] changed the 'v2.12.x' branch --- tests/af_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/af_test.go b/tests/af_test.go index 83d9b98..91cea00 100644 --- a/tests/af_test.go +++ b/tests/af_test.go @@ -53,7 +53,7 @@ func TestParser_DeletedGoFunction(t *testing.T) { } } -func TestParser_RenamedGoFunction(t *testing.T) { +func TestParser_RenamedGoFunction TestFormattedFunction_ChangedParamName(t *testing.T) { mocks := SaveMocks() defer mocks.Apply() From c617ff826f38846b1cadb3ac884f279faf7494df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:18:08 +0500 Subject: [PATCH 181/207] renamed functions: TestParser_AddedGoFunction -> TestFormattedFunction_AddedGoFunction, TestParser_DeletedGoFunction -> TestFormattedFunction_DeletedGoFunction --- tests/af_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/af_test.go b/tests/af_test.go index 91cea00..ba00639 100644 --- a/tests/af_test.go +++ b/tests/af_test.go @@ -7,7 +7,7 @@ import ( "testing" ) -func TestParser_AddedGoFunction(t *testing.T) { +func TestFormattedFunction_AddedGoFunction(t *testing.T) { mocks := SaveMocks() defer mocks.Apply() @@ -30,7 +30,7 @@ func TestParser_AddedGoFunction(t *testing.T) { } } -func TestParser_DeletedGoFunction(t *testing.T) { +func TestFormattedFunction_DeletedGoFunction(t *testing.T) { mocks := SaveMocks() defer mocks.Apply() @@ -53,7 +53,7 @@ func TestParser_DeletedGoFunction(t *testing.T) { } } -func TestParser_RenamedGoFunction TestFormattedFunction_ChangedParamName(t *testing.T) { +func TestFormattedFunction_RenamedGoFunction TestFormattedFunction_ChangedParamName(t *testing.T) { mocks := SaveMocks() defer mocks.Apply() From 935a69af30e88558dcb1fd2324267794bdfa8807 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:18:24 +0500 Subject: [PATCH 182/207] changed the 'v2.12.x' branch --- tests/af_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/af_test.go b/tests/af_test.go index ba00639..bcf032a 100644 --- a/tests/af_test.go +++ b/tests/af_test.go @@ -53,7 +53,7 @@ func TestFormattedFunction_DeletedGoFunction(t *testing.T) { } } -func TestFormattedFunction_RenamedGoFunction TestFormattedFunction_ChangedParamName(t *testing.T) { +func TestFormattedFunction_ChangedParamNameGoFunction(t *testing.T) { mocks := SaveMocks() defer mocks.Apply() From bcf5ec956a8c47aa604aaa2eac3abd7340dd5b86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:18:40 +0500 Subject: [PATCH 183/207] renamed function TestParser -> ParamTest --- tests/af_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/af_test.go b/tests/af_test.go index bcf032a..fe9720a 100644 --- a/tests/af_test.go +++ b/tests/af_test.go @@ -58,7 +58,7 @@ func TestFormattedFunction_ChangedParamNameGoFunction(t *testing.T) { defer mocks.Apply() diff.GetDiff = func(file string) (string, error) { - return "-func TestParser()\n+func TestParser()", nil + return "-func ParamTest(a int)\n+func ParamTest(b int)", nil } code.DetectLanguage = func(filename string) string { From 184d2f936fcfe850812fc2f6657b23d7db647851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:18:56 +0500 Subject: [PATCH 184/207] changed value in variable expected --- tests/af_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/af_test.go b/tests/af_test.go index fe9720a..c3ec784 100644 --- a/tests/af_test.go +++ b/tests/af_test.go @@ -70,7 +70,7 @@ func TestFormattedFunction_ChangedParamNameGoFunction(t *testing.T) { t.Fatalf("unexpected error: %v", err) } - expected := "renamed function TestParser -> TestParser" + expected := "changed parameter in PadramTest function" if msg != expected { t.Errorf("expected '%s', got '%s'", expected, msg) } From 70d8b510971b7e440233919aaf02b9e4ddf070dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:19:12 +0500 Subject: [PATCH 185/207] changed value in variable expected --- tests/af_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/af_test.go b/tests/af_test.go index c3ec784..b213e72 100644 --- a/tests/af_test.go +++ b/tests/af_test.go @@ -70,7 +70,7 @@ func TestFormattedFunction_ChangedParamNameGoFunction(t *testing.T) { t.Fatalf("unexpected error: %v", err) } - expected := "changed parameter in PadramTest function" + expected := "changed parameter in ParamTest function" if msg != expected { t.Errorf("expected '%s', got '%s'", expected, msg) } From 8a2bbd0cdea28fe60003795fd4ee1e3c8b03065a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:19:28 +0500 Subject: [PATCH 186/207] added variables: mocks, expected | added functions: TestFormattedFunction_ChangedParamTypeGoFunction, TypeTest | if err is not equal to nil; if msg is not equal to expected --- tests/af_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/af_test.go b/tests/af_test.go index b213e72..7b58785 100644 --- a/tests/af_test.go +++ b/tests/af_test.go @@ -75,3 +75,26 @@ func TestFormattedFunction_ChangedParamNameGoFunction(t *testing.T) { t.Errorf("expected '%s', got '%s'", expected, msg) } } + +func TestFormattedFunction_ChangedParamTypeGoFunction(t *testing.T) { + mocks := SaveMocks() + defer mocks.Apply() + + diff.GetDiff = func(file string) (string, error) { + return "-func TypeTest(a int)\n+func TypeTest(a string)", nil + } + + code.DetectLanguage = func(filename string) string { + return "go" + } + + msg, err := parser.Parser([]string{"auto-commit-parser-test.go"}) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + expected := "changed parameter in ParamTest function" + if msg != expected { + t.Errorf("expected '%s', got '%s'", expected, msg) + } +} From ad864a680309949f4b082c1757e47aadc9c1cec2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:19:45 +0500 Subject: [PATCH 187/207] renamed functions: TestParser -> AddedGoFunction, TestParser -> DeletedGoFunction --- tests/af_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/af_test.go b/tests/af_test.go index 7b58785..e7119c9 100644 --- a/tests/af_test.go +++ b/tests/af_test.go @@ -12,7 +12,7 @@ func TestFormattedFunction_AddedGoFunction(t *testing.T) { defer mocks.Apply() diff.GetDiff = func(file string) (string, error) { - return "+func TestParser()", nil + return "+func AddedGoFunction()", nil } code.DetectLanguage = func(filename string) string { @@ -35,7 +35,7 @@ func TestFormattedFunction_DeletedGoFunction(t *testing.T) { defer mocks.Apply() diff.GetDiff = func(file string) (string, error) { - return "-func TestParser() {}", nil + return "-func DeletedGoFunction() {}", nil } code.DetectLanguage = func(filename string) string { From ad666405625b435d6b1ed491d9731710854cd02b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:20:01 +0500 Subject: [PATCH 188/207] changed value in variable expected | added type a --- tests/af_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/af_test.go b/tests/af_test.go index e7119c9..08d3d62 100644 --- a/tests/af_test.go +++ b/tests/af_test.go @@ -93,7 +93,7 @@ func TestFormattedFunction_ChangedParamTypeGoFunction(t *testing.T) { t.Fatalf("unexpected error: %v", err) } - expected := "changed parameter in ParamTest function" + expected := "changed parameter type a in TypeTest function" if msg != expected { t.Errorf("expected '%s', got '%s'", expected, msg) } From 44ef06a7d47d34e9fb9713ff0c0ac26c4a8d32a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:20:30 +0500 Subject: [PATCH 189/207] changed value in variable expected --- tests/af_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/af_test.go b/tests/af_test.go index 08d3d62..996867a 100644 --- a/tests/af_test.go +++ b/tests/af_test.go @@ -24,7 +24,7 @@ func TestFormattedFunction_AddedGoFunction(t *testing.T) { t.Fatalf("unexpected error: %v", err) } - expected := "added function TestParser" + expected := "added function AddedGoFunction" if msg != expected { t.Errorf("expected '%s', got '%s'", expected, msg) } From 54e8d77cf48007327420620e2b2c869c651f0d3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:20:47 +0500 Subject: [PATCH 190/207] changed value in variable expected --- tests/af_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/af_test.go b/tests/af_test.go index 996867a..4654460 100644 --- a/tests/af_test.go +++ b/tests/af_test.go @@ -47,7 +47,7 @@ func TestFormattedFunction_DeletedGoFunction(t *testing.T) { t.Fatalf("unexpected error: %v", err) } - expected := "deleted function TestParser" + expected := "deleted function DeletedGoFunction" if msg != expected { t.Errorf("expected '%s', got '%s'", expected, msg) } From 0fb0487308b405deb5f3cb5731f696c437aacdd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:21:07 +0500 Subject: [PATCH 191/207] added variables: mocks, expected | added functions: TestFormattedFunction_AddedGoFunction, AddedGoFunction | if err is not equal to nil; if msg is not equal to expected --- tests/af_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/af_test.go b/tests/af_test.go index 4654460..93a6d81 100644 --- a/tests/af_test.go +++ b/tests/af_test.go @@ -30,6 +30,29 @@ func TestFormattedFunction_AddedGoFunction(t *testing.T) { } } +func TestFormattedFunction_AddedGoFunction(t *testing.T) { + mocks := SaveMocks() + defer mocks.Apply() + + diff.GetDiff = func(file string) (string, error) { + return "+func AddedGoFunction()", nil + } + + code.DetectLanguage = func(filename string) string { + return "go" + } + + msg, err := parser.Parser([]string{"auto-commit-parser-test.go"}) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + expected := "added function AddedGoFunction" + if msg != expected { + t.Errorf("expected '%s', got '%s'", expected, msg) + } +} + func TestFormattedFunction_DeletedGoFunction(t *testing.T) { mocks := SaveMocks() defer mocks.Apply() From 13b4151035c3ecdb90fc7b8344d660d267fe61b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:21:24 +0500 Subject: [PATCH 192/207] renamed functions: TestFormattedFunction_AddedGoFunction -> TestFormattedFunction_AddedGoFunctions, AddedGoFunction -> AddedGoFunction1 --- tests/af_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/af_test.go b/tests/af_test.go index 93a6d81..27efec8 100644 --- a/tests/af_test.go +++ b/tests/af_test.go @@ -30,12 +30,12 @@ func TestFormattedFunction_AddedGoFunction(t *testing.T) { } } -func TestFormattedFunction_AddedGoFunction(t *testing.T) { +func TestFormattedFunction_AddedGoFunctions(t *testing.T) { mocks := SaveMocks() defer mocks.Apply() diff.GetDiff = func(file string) (string, error) { - return "+func AddedGoFunction()", nil + return "+func AddedGoFunction1()\n+func AddedGoFunction2()", nil } code.DetectLanguage = func(filename string) string { From 86965c307156005d32a4d7714bdff4f139a1c057 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:21:40 +0500 Subject: [PATCH 193/207] changed value in variable expected --- tests/af_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/af_test.go b/tests/af_test.go index 27efec8..f009c8f 100644 --- a/tests/af_test.go +++ b/tests/af_test.go @@ -35,7 +35,7 @@ func TestFormattedFunction_AddedGoFunctions(t *testing.T) { defer mocks.Apply() diff.GetDiff = func(file string) (string, error) { - return "+func AddedGoFunction1()\n+func AddedGoFunction2()", nil + return "+func AddedGoFunction1()\n+func AddedGoFunction2()\n+func AddedGoFunction3()", nil } code.DetectLanguage = func(filename string) string { @@ -47,7 +47,7 @@ func TestFormattedFunction_AddedGoFunctions(t *testing.T) { t.Fatalf("unexpected error: %v", err) } - expected := "added function AddedGoFunction" + expected := "added functions: AddedGoFunction1, AddedGoFunction2, AddedGoFunction3" if msg != expected { t.Errorf("expected '%s', got '%s'", expected, msg) } From cabdf67566b3267de51c2a6528b6acb1c2731fe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:21:58 +0500 Subject: [PATCH 194/207] changed value in variable expected --- tests/af_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/af_test.go b/tests/af_test.go index f009c8f..8aceff8 100644 --- a/tests/af_test.go +++ b/tests/af_test.go @@ -47,7 +47,7 @@ func TestFormattedFunction_AddedGoFunctions(t *testing.T) { t.Fatalf("unexpected error: %v", err) } - expected := "added functions: AddedGoFunction1, AddedGoFunction2, AddedGoFunction3" + expected := "added functions: AddedGoFunction1, AddeGoFunction2, AddedGoFunction3" if msg != expected { t.Errorf("expected '%s', got '%s'", expected, msg) } From 5e8deef97ee59dac3947bded7e844a4acd987c8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:22:13 +0500 Subject: [PATCH 195/207] changed value in variable expected --- tests/af_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/af_test.go b/tests/af_test.go index 8aceff8..f009c8f 100644 --- a/tests/af_test.go +++ b/tests/af_test.go @@ -47,7 +47,7 @@ func TestFormattedFunction_AddedGoFunctions(t *testing.T) { t.Fatalf("unexpected error: %v", err) } - expected := "added functions: AddedGoFunction1, AddeGoFunction2, AddedGoFunction3" + expected := "added functions: AddedGoFunction1, AddedGoFunction2, AddedGoFunction3" if msg != expected { t.Errorf("expected '%s', got '%s'", expected, msg) } From f8b1010d34eefca9cd1085d289d136d8bc26b8ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:22:29 +0500 Subject: [PATCH 196/207] added variables: mocks, expected | added functions: TestFormattedFunction_DeletedGoFunctions, DeletedGoFunction | if err is not equal to nil; if msg is not equal to expected --- tests/af_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/af_test.go b/tests/af_test.go index f009c8f..07f929f 100644 --- a/tests/af_test.go +++ b/tests/af_test.go @@ -76,6 +76,29 @@ func TestFormattedFunction_DeletedGoFunction(t *testing.T) { } } +func TestFormattedFunction_DeletedGoFunctions(t *testing.T) { + mocks := SaveMocks() + defer mocks.Apply() + + diff.GetDiff = func(file string) (string, error) { + return "-func DeletedGoFunction() {}", nil + } + + code.DetectLanguage = func(filename string) string { + return "go" + } + + msg, err := parser.Parser([]string{"auto-commit-parser-test.go"}) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + expected := "deleted function DeletedGoFunction" + if msg != expected { + t.Errorf("expected '%s', got '%s'", expected, msg) + } +} + func TestFormattedFunction_ChangedParamNameGoFunction(t *testing.T) { mocks := SaveMocks() defer mocks.Apply() From 454540885960fcde5a06fb6537ed545d17b3ad83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:22:46 +0500 Subject: [PATCH 197/207] changed the 'v2.12.x' branch --- tests/af_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/af_test.go b/tests/af_test.go index 07f929f..e44700c 100644 --- a/tests/af_test.go +++ b/tests/af_test.go @@ -12,7 +12,7 @@ func TestFormattedFunction_AddedGoFunction(t *testing.T) { defer mocks.Apply() diff.GetDiff = func(file string) (string, error) { - return "+func AddedGoFunction()", nil + return "+func AddedGoFunction() {}", nil } code.DetectLanguage = func(filename string) string { @@ -81,7 +81,7 @@ func TestFormattedFunction_DeletedGoFunctions(t *testing.T) { defer mocks.Apply() diff.GetDiff = func(file string) (string, error) { - return "-func DeletedGoFunction() {}", nil + return "-func DeletedGoFunction()\n-func DeletedGoFunction()\n-func DeletedGoFunction()", nil } code.DetectLanguage = func(filename string) string { From 75b442387defce31cf3ee57e207978e0f40e1bd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:23:02 +0500 Subject: [PATCH 198/207] changed value in variable expected | renamed function DeletedGoFunction -> DeletedGoFunction1 --- tests/af_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/af_test.go b/tests/af_test.go index e44700c..ba93492 100644 --- a/tests/af_test.go +++ b/tests/af_test.go @@ -81,7 +81,7 @@ func TestFormattedFunction_DeletedGoFunctions(t *testing.T) { defer mocks.Apply() diff.GetDiff = func(file string) (string, error) { - return "-func DeletedGoFunction()\n-func DeletedGoFunction()\n-func DeletedGoFunction()", nil + return "-func DeletedGoFunction1()\n-func DeletedGoFunction2()\n-func DeletedGoFunction3()", nil } code.DetectLanguage = func(filename string) string { @@ -93,7 +93,7 @@ func TestFormattedFunction_DeletedGoFunctions(t *testing.T) { t.Fatalf("unexpected error: %v", err) } - expected := "deleted function DeletedGoFunction" + expected := "deleted function: DeletedGoFunction1, DeletedGoFunction1" if msg != expected { t.Errorf("expected '%s', got '%s'", expected, msg) } From b94780018a5a33c47693630437c404b18571dd7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:23:18 +0500 Subject: [PATCH 199/207] changed value in variable expected --- tests/af_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/af_test.go b/tests/af_test.go index ba93492..f95a216 100644 --- a/tests/af_test.go +++ b/tests/af_test.go @@ -93,7 +93,7 @@ func TestFormattedFunction_DeletedGoFunctions(t *testing.T) { t.Fatalf("unexpected error: %v", err) } - expected := "deleted function: DeletedGoFunction1, DeletedGoFunction1" + expected := "deleted function: DeletedGoFunction1, DeletedGoFunction2, DeletedGoFunction3" if msg != expected { t.Errorf("expected '%s', got '%s'", expected, msg) } From 2aca38621b1aa37dcf38246bc631dade744de64e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:23:34 +0500 Subject: [PATCH 200/207] changed value in variable expected --- tests/af_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/af_test.go b/tests/af_test.go index f95a216..2c7bb3c 100644 --- a/tests/af_test.go +++ b/tests/af_test.go @@ -93,7 +93,7 @@ func TestFormattedFunction_DeletedGoFunctions(t *testing.T) { t.Fatalf("unexpected error: %v", err) } - expected := "deleted function: DeletedGoFunction1, DeletedGoFunction2, DeletedGoFunction3" + expected := "deleted functions: DeletedGoFunction1, DeletedGoFunction2, DeletedGoFunction3" if msg != expected { t.Errorf("expected '%s', got '%s'", expected, msg) } From 2a088c8e277b3df15d3b93b09429fc5403b65482 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:24:44 +0500 Subject: [PATCH 201/207] added variables: mocks, expected | added functions: TestFormattedFunction_ChangedParamNameGoFunction, ParamTest | if err is not equal to nil; if msg is not equal to expected --- tests/af_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/af_test.go b/tests/af_test.go index 2c7bb3c..4675421 100644 --- a/tests/af_test.go +++ b/tests/af_test.go @@ -99,6 +99,28 @@ func TestFormattedFunction_DeletedGoFunctions(t *testing.T) { } } +func TestFormattedFunction_ChangedParamNameGoFunction(t *testing.T) { + mocks := SaveMocks() + defer mocks.Apply() + + diff.GetDiff = func(file string) (string, error) { + return "-func ParamTest(a int)\n+func ParamTest(b int)", nil + } + + code.DetectLanguage = func(filename string) string { + return "go" + } + + msg, err := parser.Parser([]string{"auto-commit-parser-test.go"}) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + expected := "changed parameter in ParamTest function" + if msg != expected { + t.Errorf("expected '%s', got '%s'", expected, msg) + } +} func TestFormattedFunction_ChangedParamNameGoFunction(t *testing.T) { mocks := SaveMocks() defer mocks.Apply() From 858700d666f3eed39b3659c87de21fffbced8736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:25:00 +0500 Subject: [PATCH 202/207] renamed functions: TestFormattedFunction_ChangedParamNameGoFunction -> TestFormattedFunction_ChangedParamNameGoFunctions, ParamTest -> Foo --- tests/af_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/af_test.go b/tests/af_test.go index 4675421..ed60d3e 100644 --- a/tests/af_test.go +++ b/tests/af_test.go @@ -121,12 +121,13 @@ func TestFormattedFunction_ChangedParamNameGoFunction(t *testing.T) { t.Errorf("expected '%s', got '%s'", expected, msg) } } -func TestFormattedFunction_ChangedParamNameGoFunction(t *testing.T) { + +func TestFormattedFunction_ChangedParamNameGoFunctions(t *testing.T) { mocks := SaveMocks() defer mocks.Apply() diff.GetDiff = func(file string) (string, error) { - return "-func ParamTest(a int)\n+func ParamTest(b int)", nil + return "-func Foo(a int)\n+func Foo(b int)\n-func Bar(x string)\n+func Bar(y string)", nil } code.DetectLanguage = func(filename string) string { From 9b463076011b984751264ee75a85112dabd2a3a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:25:16 +0500 Subject: [PATCH 203/207] renamed function Foo -> ParamTest1 --- tests/af_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/af_test.go b/tests/af_test.go index ed60d3e..a2a34ef 100644 --- a/tests/af_test.go +++ b/tests/af_test.go @@ -127,7 +127,7 @@ func TestFormattedFunction_ChangedParamNameGoFunctions(t *testing.T) { defer mocks.Apply() diff.GetDiff = func(file string) (string, error) { - return "-func Foo(a int)\n+func Foo(b int)\n-func Bar(x string)\n+func Bar(y string)", nil + return "-func ParamTest1(a int)\n+func ParamTest1(b int)\n-func ParamTest2(x string)\n+func ParamTest2(y string)", nil } code.DetectLanguage = func(filename string) string { From 494f685cb0a3b7e831a2bcec32f8366973c4a6b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:25:42 +0500 Subject: [PATCH 204/207] changed value in variable expected --- tests/af_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/af_test.go b/tests/af_test.go index a2a34ef..252d40c 100644 --- a/tests/af_test.go +++ b/tests/af_test.go @@ -139,7 +139,7 @@ func TestFormattedFunction_ChangedParamNameGoFunctions(t *testing.T) { t.Fatalf("unexpected error: %v", err) } - expected := "changed parameter in ParamTest function" + expected := "changed parameters in functions: Foo function, Bar function" if msg != expected { t.Errorf("expected '%s', got '%s'", expected, msg) } From 651c6988b763a6622725969bad3868c5bc5580c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:25:59 +0500 Subject: [PATCH 205/207] changed value in variable expected --- tests/af_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/af_test.go b/tests/af_test.go index 252d40c..980ec34 100644 --- a/tests/af_test.go +++ b/tests/af_test.go @@ -139,7 +139,7 @@ func TestFormattedFunction_ChangedParamNameGoFunctions(t *testing.T) { t.Fatalf("unexpected error: %v", err) } - expected := "changed parameters in functions: Foo function, Bar function" + expected := "changed parameters in functions: ParamTest1 function, ParamTest2 function" if msg != expected { t.Errorf("expected '%s', got '%s'", expected, msg) } From 18b0efc4f7c12edc8604f8d94762d65d510bd12f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:40:14 +0500 Subject: [PATCH 206/207] added variables: mocks, expected, mocks, expected, mocks, expected, mocks, expected, mocks, expected, mocks, expected, mocks, expected | added variables: mocks, expected, mocks, expected, mocks, expected, mocks, expected, mocks, expected, mocks, expected --- tests/{af_test.go => af_go_test.go} | 0 tests/af_ts_test.go | 169 ++++++++++++++++++++++++++++ tests/av_go_test.go | 146 ++++++++++++++++++++++++ tests/av_ts_test.go | 123 ++++++++++++++++++++ 4 files changed, 438 insertions(+) rename tests/{af_test.go => af_go_test.go} (100%) create mode 100644 tests/af_ts_test.go create mode 100644 tests/av_go_test.go create mode 100644 tests/av_ts_test.go diff --git a/tests/af_test.go b/tests/af_go_test.go similarity index 100% rename from tests/af_test.go rename to tests/af_go_test.go diff --git a/tests/af_ts_test.go b/tests/af_ts_test.go new file mode 100644 index 0000000..44ee13f --- /dev/null +++ b/tests/af_ts_test.go @@ -0,0 +1,169 @@ +package tests + +import ( + "git-auto-commit/achelper/code" + "git-auto-commit/diff" + "git-auto-commit/parser" + "testing" +) + +func TestFormattedFunction_AddedTSFunction(t *testing.T) { + mocks := SaveMocks() + defer mocks.Apply() + + diff.GetDiff = func(file string) (string, error) { + return "+function AddedTSFunction() {}", nil + } + + code.DetectLanguage = func(filename string) string { + return "typescript" + } + + msg, err := parser.Parser([]string{"auto-commit-parser-test.ts"}) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + expected := "added function AddedTSFunction" + if msg != expected { + t.Errorf("expected '%s', got '%s'", expected, msg) + } +} + +func TestFormattedFunction_AddedTSFunctions(t *testing.T) { + mocks := SaveMocks() + defer mocks.Apply() + + diff.GetDiff = func(file string) (string, error) { + return "+function AddedTSFunction1() {}\n+function AddedTSFunction2() {}\n+function AddedTSFunction3() {}", nil + } + + code.DetectLanguage = func(filename string) string { + return "typescript" + } + + msg, err := parser.Parser([]string{"auto-commit-parser-test.ts"}) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + expected := "added functions: AddedTSFunction1, AddedTSFunction2, AddedTSFunction3" + if msg != expected { + t.Errorf("expected '%s', got '%s'", expected, msg) + } +} + +func TestFormattedFunction_DeletedTSFunction(t *testing.T) { + mocks := SaveMocks() + defer mocks.Apply() + + diff.GetDiff = func(file string) (string, error) { + return "-function DeletedTSFunction() {}", nil + } + + code.DetectLanguage = func(filename string) string { + return "typescript" + } + + msg, err := parser.Parser([]string{"auto-commit-parser-test.ts"}) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + expected := "deleted function DeletedTSFunction" + if msg != expected { + t.Errorf("expected '%s', got '%s'", expected, msg) + } +} + +func TestFormattedFunction_DeletedTSFunctions(t *testing.T) { + mocks := SaveMocks() + defer mocks.Apply() + + diff.GetDiff = func(file string) (string, error) { + return "-function DeletedTSFunction1() {}\n-function DeletedTSFunction2() {}\n-function DeletedTSFunction3() {}", nil + } + + code.DetectLanguage = func(filename string) string { + return "typescript" + } + + msg, err := parser.Parser([]string{"auto-commit-parser-test.ts"}) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + expected := "deleted functions: DeletedTSFunction1, DeletedTSFunction2, DeletedTSFunction3" + if msg != expected { + t.Errorf("expected '%s', got '%s'", expected, msg) + } +} + +func TestFormattedFunction_ChangedParamNameTSFunction(t *testing.T) { + mocks := SaveMocks() + defer mocks.Apply() + + diff.GetDiff = func(file string) (string, error) { + return "-function ParamTest(a: number) {}\n+function ParamTest(b: number) {}", nil + } + + code.DetectLanguage = func(filename string) string { + return "typescript" + } + + msg, err := parser.Parser([]string{"auto-commit-parser-test.ts"}) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + expected := "changed parameter in ParamTest function" + if msg != expected { + t.Errorf("expected '%s', got '%s'", expected, msg) + } +} + +func TestFormattedFunction_ChangedParamNameTSFunctions(t *testing.T) { + mocks := SaveMocks() + defer mocks.Apply() + + diff.GetDiff = func(file string) (string, error) { + return "-function ParamTest1(a: number) {}\n+function ParamTest1(b: number) {}\n-function ParamTest2(x: string) {}\n+function ParamTest2(y: string) {}", nil + } + + code.DetectLanguage = func(filename string) string { + return "typescript" + } + + msg, err := parser.Parser([]string{"auto-commit-parser-test.ts"}) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + expected := "changed parameters in functions: ParamTest1 function, ParamTest2 function" + if msg != expected { + t.Errorf("expected '%s', got '%s'", expected, msg) + } +} + +func TestFormattedFunction_ChangedParamTypeTSFunction(t *testing.T) { + mocks := SaveMocks() + defer mocks.Apply() + + diff.GetDiff = func(file string) (string, error) { + return "-function TypeTest(a: number) {}\n+function TypeTest(a: string) {}", nil + } + + code.DetectLanguage = func(filename string) string { + return "typescript" + } + + msg, err := parser.Parser([]string{"auto-commit-parser-test.ts"}) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + expected := "changed parameter type a in TypeTest function" + if msg != expected { + t.Errorf("expected '%s', got '%s'", expected, msg) + } +} diff --git a/tests/av_go_test.go b/tests/av_go_test.go new file mode 100644 index 0000000..b5822f8 --- /dev/null +++ b/tests/av_go_test.go @@ -0,0 +1,146 @@ +package tests + +import ( + "git-auto-commit/achelper/code" + "git-auto-commit/diff" + "git-auto-commit/parser" + "testing" +) + +func TestFormattedVariables_AddedGoVar(t *testing.T) { + mocks := SaveMocks() + defer mocks.Apply() + + diff.GetDiff = func(file string) (string, error) { + return "+var testVar int = 5", nil + } + + code.DetectLanguage = func(filename string) string { + return "go" + } + + msg, err := parser.Parser([]string{"auto-commit-parser-test.go"}) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + expected := "added variable testVar" + if msg != expected { + t.Errorf("expected '%s', got '%s'", expected, msg) + } +} + +func TestFormattedVariables_AddedGoVarEQ(t *testing.T) { + mocks := SaveMocks() + defer mocks.Apply() + + diff.GetDiff = func(file string) (string, error) { + return "+testVar := 5", nil + } + + code.DetectLanguage = func(filename string) string { + return "go" + } + + msg, err := parser.Parser([]string{"auto-commit-parser-test.go"}) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + expected := "added variable testVar" + if msg != expected { + t.Errorf("expected '%s', got '%s'", expected, msg) + } +} + +func TestFormattedVariables_AddedGoVars(t *testing.T) { + mocks := SaveMocks() + defer mocks.Apply() + + diff.GetDiff = func(file string) (string, error) { + return "+var testVar1 int = 5\n+var testVar2 string\n+testVar3 := 0", nil + } + + code.DetectLanguage = func(filename string) string { + return "go" + } + + msg, err := parser.Parser([]string{"auto-commit-parser-test.go"}) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + expected := "added variables: testVar1, testVar2, testVar3" + if msg != expected { + t.Errorf("expected '%s', got '%s'", expected, msg) + } +} + +func TestFormattedVariables_RenamedGoVar(t *testing.T) { + mocks := SaveMocks() + defer mocks.Apply() + + diff.GetDiff = func(file string) (string, error) { + return "-var testVar1 int = 5\n+var testVar int = 5", nil + } + + code.DetectLanguage = func(filename string) string { + return "go" + } + + msg, err := parser.Parser([]string{"auto-commit-parser-test.go"}) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + expected := "renamed variable testVar1 -> testVar" + if msg != expected { + t.Errorf("expected '%s', got '%s'", expected, msg) + } +} + +func TestFormattedVariables_ChangedTypeGoVar(t *testing.T) { + mocks := SaveMocks() + defer mocks.Apply() + + diff.GetDiff = func(file string) (string, error) { + return "-var testVar int = 5\n+var testVar uint = 5", nil + } + + code.DetectLanguage = func(filename string) string { + return "go" + } + + msg, err := parser.Parser([]string{"auto-commit-parser-test.go"}) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + expected := "changed type of variable testVar (int -> uint)" + if msg != expected { + t.Errorf("expected '%s', got '%s'", expected, msg) + } +} + +func TestFormattedVariables_ChangedTypeGoVars(t *testing.T) { + mocks := SaveMocks() + defer mocks.Apply() + + diff.GetDiff = func(file string) (string, error) { + return "-var testVar uint8 = 5\n+var testVar uint16 = 5\n-var testVar2 uint16 = 5\n+var testVar2 int32 = 5", nil + } + + code.DetectLanguage = func(filename string) string { + return "go" + } + + msg, err := parser.Parser([]string{"auto-commit-parser-test.go"}) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + expected := "changed types of variables: testVar (uint8 -> uint16), testVar2 (uint16 -> int32)" + if msg != expected { + t.Errorf("expected '%s', got '%s'", expected, msg) + } +} diff --git a/tests/av_ts_test.go b/tests/av_ts_test.go new file mode 100644 index 0000000..a79ef98 --- /dev/null +++ b/tests/av_ts_test.go @@ -0,0 +1,123 @@ +package tests + +import ( + "git-auto-commit/achelper/code" + "git-auto-commit/diff" + "git-auto-commit/parser" + "testing" +) + +func TestFormattedVariables_AddedTSVar(t *testing.T) { + mocks := SaveMocks() + defer mocks.Apply() + + diff.GetDiff = func(file string) (string, error) { + return "+let testVar: number = 5;", nil + } + + code.DetectLanguage = func(filename string) string { + return "typescript" + } + + msg, err := parser.Parser([]string{"auto-commit-parser-test.ts"}) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + expected := "added variable testVar" + if msg != expected { + t.Errorf("expected '%s', got '%s'", expected, msg) + } +} + +func TestFormattedVariables_AddedTSVars(t *testing.T) { + mocks := SaveMocks() + defer mocks.Apply() + + diff.GetDiff = func(file string) (string, error) { + return "+let testVar1: number = 5;\n+const testVar2: string = 'hi';", nil + } + + code.DetectLanguage = func(filename string) string { + return "typescript" + } + + msg, err := parser.Parser([]string{"auto-commit-parser-test.ts"}) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + expected := "added variables: testVar1, testVar2" + if msg != expected { + t.Errorf("expected '%s', got '%s'", expected, msg) + } +} + +func TestFormattedVariables_RenamedTSVar(t *testing.T) { + mocks := SaveMocks() + defer mocks.Apply() + + diff.GetDiff = func(file string) (string, error) { + return "-let testVar1: number = 5;\n+let testVar: number = 5;", nil + } + + code.DetectLanguage = func(filename string) string { + return "typescript" + } + + msg, err := parser.Parser([]string{"auto-commit-parser-test.ts"}) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + expected := "renamed variable testVar1 -> testVar" + if msg != expected { + t.Errorf("expected '%s', got '%s'", expected, msg) + } +} + +func TestFormattedVariables_ChangedTypeTSVar(t *testing.T) { + mocks := SaveMocks() + defer mocks.Apply() + + diff.GetDiff = func(file string) (string, error) { + return "-let testVar: number = 5;\n+let testVar: string = 5;", nil + } + + code.DetectLanguage = func(filename string) string { + return "typescript" + } + + msg, err := parser.Parser([]string{"auto-commit-parser-test.ts"}) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + expected := "changed type of variable testVar (number -> string)" + if msg != expected { + t.Errorf("expected '%s', got '%s'", expected, msg) + } +} + +func TestFormattedVariables_ChangedTypesTSVars(t *testing.T) { + mocks := SaveMocks() + defer mocks.Apply() + + diff.GetDiff = func(file string) (string, error) { + return "-let testVar: number = 5;\n+let testVar: string = 5;\n-var testVar2: boolean = true;\n+var testVar2: number = true;", nil + } + + code.DetectLanguage = func(filename string) string { + return "typescript" + } + + msg, err := parser.Parser([]string{"auto-commit-parser-test.ts"}) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + expected := "changed types of variables: testVar (number -> string), testVar2 (boolean -> number)" + if msg != expected { + t.Errorf("expected '%s', got '%s'", expected, msg) + } +} From c0956938b82de72f8f8de70852e04e5f22067d61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=92=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 30 Jun 2025 22:45:09 +0500 Subject: [PATCH 207/207] added variables: mocks, expected, mocks, expected, mocks, expected, mocks, expected | added functions: TestFormattedImport_AddedGoImport, TestFormattedImport_AddedGoImports, TestFormattedImport_AddedImportsBlockGo, TestFormattedImport_AddedImportBlockGo --- tests/ai_go_test.go | 100 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 tests/ai_go_test.go diff --git a/tests/ai_go_test.go b/tests/ai_go_test.go new file mode 100644 index 0000000..b1cac60 --- /dev/null +++ b/tests/ai_go_test.go @@ -0,0 +1,100 @@ +package tests + +import ( + "git-auto-commit/achelper/code" + "git-auto-commit/diff" + "git-auto-commit/parser" + "testing" +) + +func TestFormattedImport_AddedGoImport(t *testing.T) { + mocks := SaveMocks() + defer mocks.Apply() + + diff.GetDiff = func(file string) (string, error) { + return "+import \"fmt\"", nil + } + + code.DetectLanguage = func(filename string) string { + return "go" + } + + msg, err := parser.Parser([]string{"main.go"}) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + expected := "included 'fmt' in main.go" + if msg != expected { + t.Errorf("expected '%s', got '%s'", expected, msg) + } +} + +func TestFormattedImport_AddedGoImports(t *testing.T) { + mocks := SaveMocks() + defer mocks.Apply() + + diff.GetDiff = func(file string) (string, error) { + return "+import \"fmt\"\n+import \"os\"", nil + } + + code.DetectLanguage = func(filename string) string { + return "go" + } + + msg, err := parser.Parser([]string{"main.go"}) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + expected := "included 'fmt', 'os' in main.go" + if msg != expected { + t.Errorf("expected '%s', got '%s'", expected, msg) + } +} + +func TestFormattedImport_AddedImportsBlockGo(t *testing.T) { + mocks := SaveMocks() + defer mocks.Apply() + + diff.GetDiff = func(file string) (string, error) { + return "+import (\n+\"fmt\"\n+\"os\"\n+)", nil + } + + code.DetectLanguage = func(filename string) string { + return "go" + } + + msg, err := parser.Parser([]string{"main.go"}) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + expected := "included 'fmt', 'os' in main.go" + if msg != expected { + t.Errorf("expected '%s', got '%s'", expected, msg) + } +} + +func TestFormattedImport_AddedImportBlockGo(t *testing.T) { + mocks := SaveMocks() + defer mocks.Apply() + + diff.GetDiff = func(file string) (string, error) { + return "+import (\n+\"fmt\"\n+)", nil + } + + code.DetectLanguage = func(filename string) string { + return "go" + } + + msg, err := parser.Parser([]string{"main.go"}) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + expected := "included 'fmt' in main.go" + if msg != expected { + t.Errorf("expected '%s', got '%s'", expected, msg) + } +}