Skip to content

Commit

Permalink
refactor: all dependenceis to update
Browse files Browse the repository at this point in the history
  • Loading branch information
dd84ai committed Feb 11, 2024
1 parent 40787e1 commit a19ce76
Show file tree
Hide file tree
Showing 19 changed files with 82 additions and 109 deletions.
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ require (
github.com/ProtonMail/go-crypto v0.0.0-20221026131551-cf6655e29de4 // indirect
github.com/acomagu/bufpipe v1.0.3 // indirect
github.com/cloudflare/circl v1.1.0 // indirect
github.com/darklab8/darklab_goutils v0.3.2 // indirect
github.com/darklab8/go-typelog v0.3.2 // indirect
github.com/darklab8/go-utils v0.10.6 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/go-git/gcfg v1.5.0 // indirect
Expand Down
12 changes: 8 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ github.com/cloudflare/circl v1.1.0 h1:bZgT/A+cikZnKIwn7xL2OBj012Bmvho/o6RpRvv3GK
github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/darklab8/darklab_goutils v0.3.1 h1:R4mAGRKG6YOfoFk/OE0JCvVMKzMyQR1+DOzEVom9UXs=
github.com/darklab8/darklab_goutils v0.3.1/go.mod h1:sL2yFr77PquFePdB9tsTFzNYspyz+hkW3a3sVUjFyrU=
github.com/darklab8/darklab_goutils v0.3.2 h1:VRuICLmOh3TspmLqFeQ3If8Qkjno9gHh/qmajpU+UFg=
github.com/darklab8/darklab_goutils v0.3.2/go.mod h1:sL2yFr77PquFePdB9tsTFzNYspyz+hkW3a3sVUjFyrU=
github.com/darklab8/go-typelog v0.3.2 h1:LfQ4bUpKifNKZZFoAhrbasmpLhaXrjwnNL9GcquOy8w=
github.com/darklab8/go-typelog v0.3.2/go.mod h1:AwwOf3dkp/tpevHFNbkB+PbwlDrUUgO1CVFkEnj+q5w=
github.com/darklab8/go-utils v0.3.1 h1:R4mAGRKG6YOfoFk/OE0JCvVMKzMyQR1+DOzEVom9UXs=
github.com/darklab8/go-utils v0.3.1/go.mod h1:sL2yFr77PquFePdB9tsTFzNYspyz+hkW3a3sVUjFyrU=
github.com/darklab8/go-utils v0.3.2 h1:VRuICLmOh3TspmLqFeQ3If8Qkjno9gHh/qmajpU+UFg=
github.com/darklab8/go-utils v0.3.2/go.mod h1:sL2yFr77PquFePdB9tsTFzNYspyz+hkW3a3sVUjFyrU=
github.com/darklab8/go-utils v0.10.6 h1:BdBWa9b8uYJRDnf7C2A0GLXgCJwOAe96XIZ4uMTVE/M=
github.com/darklab8/go-utils v0.10.6/go.mod h1:sbbAj7uyQU+PZOOeI60gOdM+ji+k4at93EcdAfRJZsI=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
2 changes: 1 addition & 1 deletion interface_cli/actions/changelog/templates/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"text/template"
"time"

"github.com/darklab8/darklab_goutils/goutils/utils"
"github.com/darklab8/go-utils/goutils/utils"
)

type Templates struct {
Expand Down
8 changes: 4 additions & 4 deletions interface_cli/actions/commit_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"os"
"path/filepath"

"github.com/darklab8/darklab_goutils/goutils/logus_core"
"github.com/darklab8/darklab_goutils/goutils/utils"
"github.com/darklab8/darklab_goutils/goutils/utils/utils_types"
"github.com/darklab8/go-utils/goutils/utils"
"github.com/darklab8/go-utils/goutils/utils/utils_logus"
"github.com/darklab8/go-utils/goutils/utils/utils_types"
)

func CommmitMsg(args []string) {
Expand All @@ -22,7 +22,7 @@ func CommmitMsg(args []string) {
conf := settings.GetConfig()

inputFile := utils_types.FilePath(filepath.Join(string(utils.GetProjectDir()), args[0]))
logus.Log.Debug("Received CommitFile", logus_core.FilePath(inputFile))
logus.Log.Debug("Received CommitFile", utils_logus.FilePath(inputFile))

file, err := os.ReadFile(string(inputFile))
logus.Log.CheckFatal(err, "Could not read the file due to this error")
Expand Down
2 changes: 1 addition & 1 deletion interface_cli/actions/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"fmt"
"strings"

"github.com/darklab8/darklab_goutils/goutils/utils"
"github.com/darklab8/go-utils/goutils/utils"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions interface_cli/actions/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (
"path/filepath"
"testing"

"github.com/darklab8/darklab_goutils/goutils/utils"
"github.com/darklab8/go-utils/goutils/utils"
)

func TestWriteCommentedConfig(t *testing.T) {
current_folder := utils.GetCurrrentFolder()
current_folder := utils.GetCurrentFolder()
temp_data := filepath.Join(string(current_folder), "temp_data")
err := os.MkdirAll(temp_data, os.ModePerm)
logus.Log.CheckFatal(err, "failed to create temp_data folder")
Expand Down
4 changes: 2 additions & 2 deletions interface_cli/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"autogit/settings/logus"
"fmt"

"github.com/darklab8/darklab_goutils/goutils/logus_core"
"github.com/darklab8/go-typelog/typelog"
"github.com/spf13/cobra"
)

Expand All @@ -18,7 +18,7 @@ func (s *sharedFlags) Bind(Cmd *cobra.Command) {

func (s *sharedFlags) Run() {
if *(s.verboseLogging) {
logus.Log = logus_core.NewLogger(logus_core.LEVEL_DEBUG, false, false)
logus.Log = typelog.NewLogger("autogit", typelog.WithLogLevel(typelog.LEVEL_DEBUG))
}
logus.Log.Debug(fmt.Sprintf("verbose=%t\n", *(s.verboseLogging)))
}
Expand Down
2 changes: 1 addition & 1 deletion semanticgit/conventionalcommits/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"fmt"
"strings"

"github.com/darklab8/darklab_goutils/goutils/utils"
"github.com/darklab8/go-utils/goutils/utils"
)

type ConventionalCommit struct {
Expand Down
2 changes: 1 addition & 1 deletion semanticgit/git/gitraw/gitraw.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package gitraw
import (
"autogit/settings/logus"

"github.com/darklab8/darklab_goutils/goutils/utils"
"github.com/darklab8/go-utils/goutils/utils"
"github.com/go-git/go-git/v5"
)

Expand Down
2 changes: 1 addition & 1 deletion semanticgit/git/test_code.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"autogit/settings/logus"
"fmt"

"github.com/darklab8/darklab_goutils/goutils/utils"
"github.com/darklab8/go-utils/goutils/utils"
"github.com/go-git/go-billy/v5/memfs"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
Expand Down
4 changes: 2 additions & 2 deletions semanticgit/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"autogit/settings/logus"
"autogit/settings/types"

"github.com/darklab8/darklab_goutils/goutils/logus_core"
"github.com/darklab8/go-typelog/typelog"
)

type SemanticGit struct {
Expand All @@ -38,7 +38,7 @@ func (g *SemanticGit) GetCurrentVersion() *semvertype.SemVer {
vers, err := semver.Parse(tag.Name)

if err != nil {
logus.Log.Warn("failed to parse tag=", logus.TagName(tag.Name), logus_core.OptError(err))
logus.Log.Warn("failed to parse tag=", logus.TagName(tag.Name), typelog.OptError(err))
return git.ShouldWeStopIteration(false)
}

Expand Down
2 changes: 1 addition & 1 deletion settings/changelog.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"autogit/semanticgit/conventionalcommits/conventionalcommitstype"
"autogit/settings/logus"

"github.com/darklab8/darklab_goutils/goutils/utils/utils_types"
"github.com/darklab8/go-utils/goutils/utils/utils_types"
)

type ChangelogScheme struct {
Expand Down
21 changes: 1 addition & 20 deletions settings/envs/envs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import (
"fmt"
"os"
"path/filepath"
"strings"

"github.com/darklab8/darklab_goutils/goutils/logus_core/logus_types"
"github.com/darklab8/darklab_goutils/goutils/utils/utils_types"
"github.com/darklab8/go-utils/goutils/utils/utils_types"
)

/*
Expand All @@ -17,27 +15,10 @@ And autogit is able to run with correct settings only if run from project root
TODO fix actually to detect root folder of it, then it will not be necessary value
*/

var LogTurnJSONLogging bool
var LogShowFileLocations bool
var LogLevel logus_types.LogLevel

var PathUserHome utils_types.FilePath
var PathGitConfig utils_types.FilePath

const (
EnvTrue = "true"
)

func init() {
LogTurnJSONLogging = strings.ToLower(os.Getenv("AUTOGIT_LOG_JSON")) == EnvTrue
LogShowFileLocations = strings.ToLower(os.Getenv("AUTOGIT_LOG_SHOW_FILE_LOCATIONS")) == EnvTrue

log_level_str, is_log_level_set := os.LookupEnv("AUTOGIT_LOG_LEVEL")
if !is_log_level_set {
log_level_str = "INFO"
}
LogLevel = logus_types.LogLevel(log_level_str)

PathUserHome = utils_types.FilePath(os.Getenv("HOME"))

dirname, err := os.UserHomeDir()
Expand Down
17 changes: 2 additions & 15 deletions settings/logus/logger.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
package logus

import (
"autogit/settings/envs"

"github.com/darklab8/darklab_goutils/goutils/logus_core"
"github.com/darklab8/darklab_goutils/goutils/logus_core/logus_types"
)
import "github.com/darklab8/go-typelog/typelog"

var (
Log *logus_core.Logger
Log *typelog.Logger = typelog.NewLogger("autogit")
)

func init() {

Log = logus_core.NewLogger(
logus_types.LogLevel(envs.LogLevel),
logus_types.EnableJsonFormat(envs.LogTurnJSONLogging),
logus_types.EnableFileShowing(envs.LogShowFileLocations))
}
83 changes: 41 additions & 42 deletions settings/logus/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,79 +5,78 @@ import (
"autogit/semanticgit/semver/semvertype"
"autogit/settings/types"
"fmt"
"log/slog"
"strconv"

"github.com/darklab8/darklab_goutils/goutils/logus_core"
"github.com/darklab8/go-typelog/typelog"
"github.com/go-git/go-git/v5/plumbing"
)

func ConfigPath(value types.ConfigPath) logus_core.SlogParam {
return func(c *logus_core.SlogGroup) {
c.Params["config_path"] = string(value)
}
func ConfigPath(value types.ConfigPath) typelog.LogType {
return typelog.String("config_path", string(value))
}

func CommitHash(value plumbing.Hash) logus_core.SlogParam {
return func(c *logus_core.SlogGroup) {
c.Params["commit_hash"] = value.String()
}
func CommitHash(value plumbing.Hash) typelog.LogType {
return typelog.String("commit_hash", value.String())
}

func TagName(value types.TagName) logus_core.SlogParam {
return func(c *logus_core.SlogGroup) {
c.Params["tag_name"] = string(value)
}
func TagName(value types.TagName) typelog.LogType {
return typelog.String("tag_name", string(value))
}

func ProjectFolder(value types.ProjectFolder) logus_core.SlogParam {
return func(c *logus_core.SlogGroup) {
c.Params["project_folder"] = string(value)
}
func ProjectFolder(value types.ProjectFolder) typelog.LogType {
return typelog.String("project_folder", string(value))
}

func CommitMessage(value types.CommitOriginalMsg) logus_core.SlogParam {
return func(c *logus_core.SlogGroup) {
c.Params["commit_file"] = string(value)
}
func CommitMessage(value types.CommitOriginalMsg) typelog.LogType {
return typelog.String("commit_file", string(value))
}

func SettingsKey(value any) logus_core.SlogParam {
return func(c *logus_core.SlogGroup) {
c.Params["settings_key"] = fmt.Sprintf("%v", value)
}
func SettingsKey(value any) typelog.LogType {
return typelog.Any("settings_key", value)
}

func Commit(commit conventionalcommitstype.ParsedCommit) logus_core.SlogParam {
return func(c *logus_core.SlogGroup) {
c.Params["commit_type"] = string(commit.Type)
c.Params["commit_scope"] = string(commit.Scope)
c.Params["commit_subject"] = string(commit.Subject)
c.Params["commit_body"] = string(commit.Body)
c.Params["commit_exlamation"] = strconv.FormatBool(commit.Exclamation)
c.Params["commit_hash"] = string(commit.Hash)
func Commit(commit conventionalcommitstype.ParsedCommit) typelog.LogType {
return func(c *typelog.LogAtrs) {
c.Append(
slog.String("commit_type", string(commit.Type)),
slog.String("commit_scope", string(commit.Scope)),
slog.String("commit_subject", string(commit.Subject)),
slog.String("commit_body", string(commit.Body)),
slog.String("commit_exlamation", strconv.FormatBool(commit.Exclamation)),
slog.String("commit_hash", string(commit.Hash)),
)

for index, footer := range commit.Footers {
// Should have made structured logging allowing nested dictionaries.
// Using as work around more lazy option
c.Params[fmt.Sprintf("commit_footer_%d", index)] = fmt.Sprintf(
"token: %s, content: %s",
footer.Token,
footer.Content,
c.Append(
slog.String(
fmt.Sprintf("commit_footer_%d", index),
fmt.Sprintf(
"token: %s, content: %s",
footer.Token,
footer.Content,
),
),
)
}
for index, issue := range commit.Issue {
// Should have made structured logging allowing nested dictionaries.
// Using as work around more lazy option
c.Params[fmt.Sprintf("commit_issue_%d", index)] = string(issue)
c.Append(
slog.String(fmt.Sprintf("commit_issue_%d", index), string(issue)),
)
}
}
}

func Semver(semver *semvertype.SemVer) logus_core.SlogParam {
return func(c *logus_core.SlogGroup) {
func Semver(semver *semvertype.SemVer) typelog.LogType {
return func(c *typelog.LogAtrs) {
if semver == nil {
c.Params["semver"] = "nil"
c.Append(slog.String("semver", "nil"))
return
}
c.Params["semver"] = string(semver.ToString())
c.Append(slog.String("semver", string(semver.ToString())))
}
}
4 changes: 2 additions & 2 deletions settings/regex.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package settings
import (
"regexp"

"github.com/darklab8/darklab_goutils/goutils/utils"
"github.com/darklab8/darklab_goutils/goutils/utils/utils_types"
"github.com/darklab8/go-utils/goutils/utils"
"github.com/darklab8/go-utils/goutils/utils/utils_types"
)

type RegexScheme struct {
Expand Down
13 changes: 7 additions & 6 deletions settings/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import (
"strconv"
"strings"

"github.com/darklab8/darklab_goutils/goutils/logus_core"
"github.com/darklab8/darklab_goutils/goutils/utils/utils_types"
"github.com/darklab8/go-typelog/typelog"
"github.com/darklab8/go-utils/goutils/utils/utils_logus"
"github.com/darklab8/go-utils/goutils/utils/utils_types"

"gopkg.in/yaml.v3"
)
Expand Down Expand Up @@ -71,10 +72,10 @@ func readSettingsfile(configPath types.ConfigPath) []byte {
local_file_is_not_found := false
if err != nil {
if is_file_missing(err) {
logus.Log.Debug("not found at path repository local file with config. Fallback to global config", logus_core.FilePath(configPath.ToFilePath()), logus_core.OptError(err))
logus.Log.Debug("not found at path repository local file with config. Fallback to global config", utils_logus.FilePath(configPath.ToFilePath()), typelog.OptError(err))
local_file_is_not_found = true
} else {
logus.Log.CheckFatal(err, "Could not read the file due to error", logus.ConfigPath(configPath), logus_core.OptError(err))
logus.Log.CheckFatal(err, "Could not read the file due to error", logus.ConfigPath(configPath), typelog.OptError(err))
}
} else {
logus.Log.Debug("succesfuly read config from local repository project path", logus.ConfigPath(configPath))
Expand All @@ -85,10 +86,10 @@ func readSettingsfile(configPath types.ConfigPath) []byte {
file, err = os.ReadFile(string(GetGlobalConfigPath()))
if err != nil {
if is_file_missing(err) {
logus.Log.Debug("not found at path repository global file with config. Fallback to other in memory config", logus_core.FilePath(configPath.ToFilePath()), logus_core.OptError(err))
logus.Log.Debug("not found at path repository global file with config. Fallback to other in memory config", utils_logus.FilePath(configPath.ToFilePath()), typelog.OptError(err))
global_file_is_not_found = true
} else {
logus.Log.CheckFatal(err, "Could not read the file due to error", logus.ConfigPath(configPath), logus_core.OptError(err))
logus.Log.CheckFatal(err, "Could not read the file due to error", logus.ConfigPath(configPath), typelog.OptError(err))
}
}
}
Expand Down
Loading

0 comments on commit a19ce76

Please sign in to comment.