Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
2fcbb36
fix: barry quick fix, 2025-04-27 18:07:17
kooksee Apr 27, 2025
1bc7f51
fix: barry quick fix, 2025-04-27 18:08:00
kooksee Apr 27, 2025
e70b67c
fix: barry quick fix, 2025-04-27 18:24:42
kooksee Apr 27, 2025
e98374a
fix: barry quick fix, 2025-04-27 23:27:36
kooksee Apr 27, 2025
723c6a0
fix: barry quick fix, 2025-04-27 23:36:34
kooksee Apr 27, 2025
4eba156
fix: barry quick fix, 2025-04-27 23:38:27
kooksee Apr 27, 2025
beb8c5f
fix: barry quick fix, 2025-04-28 09:40:26
kooksee Apr 28, 2025
b93488d
fix: barry quick fix, 2025-04-28 13:50:47
kooksee Apr 28, 2025
c1c85b1
fix: barry quick fix, 2025-04-28 13:53:37
kooksee Apr 28, 2025
a551971
fix: barry quick fix, 2025-04-28 13:54:26
kooksee Apr 28, 2025
964ea7c
fix: barry quick fix, 2025-04-28 14:07:11
kooksee Apr 28, 2025
431724c
fix: barry quick fix, 2025-04-28 20:59:28
kooksee Apr 28, 2025
c604f89
fix: barry quick fix, 2025-04-28 21:07:17
kooksee Apr 28, 2025
8072683
refactor: move branch logging to fastcommit cmd
kooksee Apr 28, 2025
65f9bbb
fix: Add newline to shell result log
kooksee Apr 28, 2025
12d1202
refactor: improve logging format and messages
kooksee Apr 28, 2025
86270f1
refactor: replace slog.Info with fmt.Println for shell output
kooksee Apr 28, 2025
b114171
feat(tagcmd): add spinner for git fetch operation
kooksee Apr 28, 2025
621cd11
feat: add spinner for git message generation
kooksee Apr 28, 2025
fbf4cd5
refactor(tagcmd): remove unused imports and update tag prompt
kooksee Apr 28, 2025
499e6c3
refactor(cmds): update git message prompt text
kooksee Apr 28, 2025
ce1b0c5
fix: barry quick fix, 2025-04-28 21:46:36
kooksee Apr 28, 2025
42babf8
feat: add logging to GetAllGitTags
kooksee Apr 28, 2025
e70d729
refactor: update logging and config handling
kooksee Apr 29, 2025
6d25abd
refactor: move config logic to separate file
kooksee Apr 29, 2025
3657298
refactor(fastcommit): print diff files separately
kooksee Apr 29, 2025
67db605
refactor: trim shell command in log output
kooksee Apr 29, 2025
36d6071
refactor(fastcommit): replace strings.Join with log loop
kooksee Apr 29, 2025
1043f8c
refactor(utils): rename GetGitMaxTag to GetNextGitMaxTag
kooksee Apr 29, 2025
1b95140
refactor(fastcommit): simplify UI and remove validation
kooksee Apr 29, 2025
d35d502
refactor: move openai usage log after push
kooksee Apr 29, 2025
2e99c4f
feat: add prompt to openai response log
kooksee Apr 29, 2025
9080aff
feat: add show-prompt flag to fastcommit
kooksee Apr 29, 2025
5f7ba1e
refactor: Remove aliases and improve prompt formatting
kooksee Apr 29, 2025
95ec6b7
fix: barry quick fix, 2025-05-06 23:29:51
kooksee May 6, 2025
dcd8d40
fix: barry quick fix, 2025-05-07 12:01:12
kooksee May 7, 2025
f9a5f66
fix: barry quick fix, 2025-05-07 13:48:37
kooksee May 7, 2025
b79d52b
fix: barry quick fix, 2025-05-07 21:40:54
kooksee May 7, 2025
74aaf3b
fix: barry quick fix, 2025-05-08 22:48:18
kooksee May 8, 2025
424a7f9
fix: barry quick fix, 2025-05-12 12:19:02
kooksee May 12, 2025
5c1e9bb
fix: barry quick fix, 2025-05-12 12:19:48
kooksee May 12, 2025
dec2316
fix: barry quick fix, 2025-05-12 12:21:07
kooksee May 12, 2025
76c70cd
fix: barry quick fix, 2025-05-12 23:09:16
kooksee May 12, 2025
8474a8e
Merge branch 'feat/git_ver' of github.com:pubgo/fastcommit into feat/…
kooksee May 12, 2025
92eafd7
fix: barry quick fix, 2025-06-04 23:47:51
kooksee Jun 4, 2025
eceacdc
fix: barry quick fix, 2025-06-30 11:50:07
kooksee Jun 30, 2025
eb267f1
Merge branch 'feat/git_ver' of github.com:pubgo/fastcommit into feat/…
kooksee Jun 30, 2025
c9eeb75
fix: barry quick fix, 2025-06-30 11:57:43
kooksee Jun 30, 2025
d27dc0c
fix: barry quick fix, 2025-07-15 22:50:13
kooksee Jul 15, 2025
c34bc2a
fix: barry quick fix, 2025-07-15 23:10:22
kooksee Jul 15, 2025
959bc1a
fix: barry quick fix, 2025-07-15 23:24:19
kooksee Jul 15, 2025
4928235
fix: barry quick fix, 2025-07-15 23:26:16
kooksee Jul 15, 2025
9b6ccbf
fix: barry quick fix, 2025-07-16 12:05:32
kooksee Jul 16, 2025
64d0bd6
fix: barry quick fix, 2025-07-16 13:38:48
kooksee Jul 16, 2025
fcae22d
fix: barry quick fix, 2025-07-16 13:46:16
kooksee Jul 16, 2025
c3ed99f
fix: barry quick fix, 2025-07-16 20:24:12
kooksee Jul 16, 2025
b8ef1c8
fix: barry quick fix, 2025-07-16 20:24:30
kooksee Jul 16, 2025
5e4f74c
fix: barry quick fix, 2025-07-25 16:02:07
kooksee Jul 25, 2025
9256128
fix: barry quick fix, 2025-07-25 16:49:15
kooksee Jul 25, 2025
fdc623d
fix: barry quick fix, 2025-07-25 21:11:59
kooksee Jul 25, 2025
67babd6
fix: barry quick fix, 2025-09-06 19:07:22
kooksee Sep 6, 2025
8b752f0
fix: barry quick fix, 2025-09-07 17:38:01
kooksee Sep 7, 2025
ea48f6e
fix: barry quick fix, 2025-09-07 18:05:13
kooksee Sep 7, 2025
1e7ac42
fix: barry quick fix, 2025-09-07 18:11:01
kooksee Sep 7, 2025
417d823
fix: barry quick fix, 2025-09-07 18:29:51
kooksee Sep 7, 2025
12fbefd
feat: add version file and tag conflict handling
kooksee Sep 7, 2025
d72cd25
feat(upgrade): add interactive version selection using tap
kooksee Sep 7, 2025
d23c96f
fix: barry quick fix, 2025-09-07 23:06:02
kooksee Sep 7, 2025
5c807c7
fix: barry quick fix, 2025-09-07 23:16:04
kooksee Sep 7, 2025
269cbd4
chore: update dependencies and refactor error handling
kooksee Sep 7, 2025
2b79037
chore: update dependencies and refactor error handling
kooksee Sep 7, 2025
2c22ba1
fix: barry@feat/ver123, 2025-09-11 09:57:29
kooksee Sep 11, 2025
5a32664
Merge branch 'feat/ver123' of github.com:pubgo/fastcommit into feat/v…
kooksee Sep 11, 2025
1939ed6
chore: @barry quick update feat/ver123\n at 2025-09-13 09:24:41
kooksee Sep 13, 2025
4d98837
chore: quick update feat/ver123 at 2025-09-13 10:17:36
kooksee Sep 13, 2025
eccc4e3
feat(fastcommit): set initial value for commit message
kooksee Sep 13, 2025
dccd7e7
chore: quick update feat/ver123 at 2025-09-13 12:58:02
kooksee Sep 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ builds:
- GOPROXY=https://goproxy.io
targets:
- "darwin_amd64"
- "windows_amd64"
- "darwin_arm64"
# - "windows_amd64"
- "linux_amd64"
- "linux_arm64"
ldflags:
- -X 'github.com/pubgo/funk/version.version={{ .Version }}'
- -X 'github.com/pubgo/funk/version.version=v{{ .Version }}'
- -X 'github.com/pubgo/funk/version.project=fastcommit'
- -X 'github.com/pubgo/funk/version.buildTime={{ .CommitDate }}'
- -X 'github.com/pubgo/funk/version.commitID={{ .ShortCommit }}'
Expand All @@ -22,8 +24,8 @@ builds:
archives:
- format: tar.gz
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{ .ProjectName }}-{{ .Tag }}-
{{- .Os }}-
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
Expand Down
1 change: 1 addition & 0 deletions .version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v0.0.6
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Project=fastcommit
Base=github.com/pubgo/funk
# git describe --tags --always --dirty
VERSION := $(shell git tag --sort=committerdate | tail -n 1)
GIT_COMMIT := $(shell git describe --always --abbrev=7 --dirty)
BUILD_TIME := $(shell date "+%F %T")
Expand Down
51 changes: 16 additions & 35 deletions bootstrap/boot.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,62 +2,43 @@ package bootstrap

import (
"log/slog"
"os"

_ "github.com/adrg/xdg"
_ "github.com/charmbracelet/bubbletea"
"github.com/pubgo/dix"
"github.com/pubgo/dix/dix_internal"
"github.com/pubgo/funk/config"
"github.com/pubgo/funk/log"
"github.com/pubgo/funk/recovery"
_ "github.com/sashabaranov/go-openai"

"github.com/pubgo/fastcommit/cmds/configcmd"
"github.com/pubgo/fastcommit/cmds/envcmd"
"github.com/pubgo/fastcommit/cmds/fastcommit"
"github.com/pubgo/fastcommit/cmds/historycmd"
"github.com/pubgo/fastcommit/cmds/tagcmd"
"github.com/pubgo/fastcommit/cmds/upgradecmd"
"github.com/pubgo/fastcommit/cmds/versioncmd"
"github.com/pubgo/fastcommit/configs"
"github.com/pubgo/fastcommit/utils"
"github.com/pubgo/funk/assert"
"github.com/pubgo/funk/config"
"github.com/pubgo/funk/pathutil"
"github.com/pubgo/funk/recovery"
"github.com/pubgo/funk/typex"
"github.com/rs/zerolog"
_ "github.com/sashabaranov/go-openai"
"gopkg.in/yaml.v3"
)

func Main() {
func Main(ver string) {
defer recovery.Exit()

slog.Info("config path", "path", configs.GetConfigPath())
typex.DoBlock(func() {
if pathutil.IsNotExist(configs.GetConfigPath()) {
assert.Must(os.WriteFile(configs.GetConfigPath(), configs.GetDefaultConfig(), 0644))
return
}

var cfg ConfigProvider
config.LoadFromPath(&cfg, configs.GetConfigPath())

var defaultCfg ConfigProvider
assert.Exit(yaml.Unmarshal(configs.GetDefaultConfig(), &defaultCfg))
if cfg.Version == nil || cfg.Version.Name == "" || defaultCfg.Version.Name != cfg.Version.Name {
assert.Exit(os.WriteFile(configs.GetConfigPath(), configs.GetDefaultConfig(), 0644))
}
})
slog.SetDefault(slog.New(log.NewSlog(log.GetLogger("fastcommit"))))

config.SetConfigPath(configs.GetConfigPath())
dix_internal.SetLogLevel(zerolog.InfoLevel)
initConfig()

var di = dix.New(dix.WithValuesNull())
di.Provide(versioncmd.New)
di.Provide(func() *configs.Config {
return &configs.Config{
BranchName: configs.GetBranchName(),
}
})
di.Provide(upgradecmd.New)
di.Provide(configs.New)
di.Provide(tagcmd.New)
di.Provide(config.Load[ConfigProvider])
di.Provide(utils.NewOpenaiClient)
di.Provide(envcmd.New)
di.Provide(fastcommit.New)
di.Provide(historycmd.New)
di.Provide(fastcommit.New(ver))
di.Provide(configcmd.New)
di.Inject(func(cmd *fastcommit.Command) { cmd.Run() })
}
39 changes: 39 additions & 0 deletions bootstrap/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
package bootstrap

import (
"os"

"github.com/pubgo/dix/dixinternal"
"github.com/pubgo/funk/assert"
"github.com/pubgo/funk/config"
"github.com/pubgo/funk/log"
"github.com/pubgo/funk/pathutil"
"github.com/rs/zerolog"
"gopkg.in/yaml.v3"

"github.com/pubgo/fastcommit/configs"
"github.com/pubgo/fastcommit/utils"
)
Expand All @@ -9,3 +19,32 @@ type ConfigProvider struct {
Version *configs.Version `yaml:"version"`
OpenaiConfig *utils.OpenaiConfig `yaml:"openai"`
}

func initConfig() {
configs.InitEnv()

dixinternal.SetLog(func(logger log.Logger) log.Logger {
if configs.IsDebug() {
return logger.WithLevel(zerolog.DebugLevel)
}
return logger.WithLevel(zerolog.InfoLevel)
})

configPath := configs.GetConfigPath()
defaultConfigData := configs.GetDefaultConfig()
if pathutil.IsNotExist(configPath) {
assert.Must(os.WriteFile(configPath, defaultConfigData, 0644))
return
}

var cfg ConfigProvider
config.LoadFromPath(&cfg, configPath)

var defaultCfg ConfigProvider
assert.Must(yaml.Unmarshal(defaultConfigData, &defaultCfg))
if cfg.Version == nil || cfg.Version.Name == "" || defaultCfg.Version.Name != cfg.Version.Name {
assert.Must(os.WriteFile(configPath, defaultConfigData, 0644))
}
Comment on lines +45 to +47

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This logic overwrites the entire user configuration file with the default one if the version name in the config differs from the default. This is a destructive action that can lead to the loss of user-specific settings, such as their OpenAI API key or model preferences. A better approach would be to merge the configurations while preserving user settings, or at least to warn the user and ask for confirmation before overwriting the file. I suggest replacing this with a non-destructive warning.

Suggested change
if cfg.Version == nil || cfg.Version.Name == "" || defaultCfg.Version.Name != cfg.Version.Name {
assert.Must(os.WriteFile(configPath, defaultConfigData, 0644))
}
if cfg.Version == nil || cfg.Version.Name == "" || defaultCfg.Version.Name != cfg.Version.Name {
log.Warn().Msg("Your configuration file version is outdated. Please consider backing it up and regenerating it to get the latest options.")
}


config.SetConfigPath(configPath)
}
3 changes: 3 additions & 0 deletions cmds/chglogcmd/cmd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package chglogcmd

// https://github.com/goreleaser/chglog/blob/main/pkg/commands/format.go
17 changes: 17 additions & 0 deletions cmds/cmdutils/utils.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package cmdutils

import (
"sync"

"github.com/pubgo/fastcommit/configs"
"github.com/pubgo/fastcommit/utils"
"github.com/pubgo/funk/log"
)

var GetBranchName = sync.OnceValue(func() string { return utils.GetCurrentBranch().Must() })

func LoadConfigAndBranch() {
branchName := GetBranchName()
log.Info().Msg("current branch: " + branchName)
log.Info().Msg("config: " + configs.GetConfigPath())
}
53 changes: 53 additions & 0 deletions cmds/configcmd/cmd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package configcmd

import (
"context"
"fmt"
"os"
"path/filepath"

"github.com/bitfield/script"
"github.com/pkg/browser"
"github.com/pubgo/fastcommit/configs"
"github.com/pubgo/funk/assert"
"github.com/pubgo/funk/log"
"github.com/pubgo/funk/recovery"
"github.com/urfave/cli/v3"
)

func New() *cli.Command {
return &cli.Command{
Name: "config",
Usage: "config management",
Action: func(ctx context.Context, command *cli.Command) error {
defer recovery.Exit()

cfgPath := configs.GetConfigPath()
log.Info().Msgf("config path: %s", cfgPath)

log.Info().Msgf("config data: \n%s", assert.Must1(os.ReadFile(cfgPath)))
return nil
},
Commands: []*cli.Command{
{
Name: "edit",
Usage: "fastcommit config edit [open|vim|zed|code|...]",
Action: func(ctx context.Context, command *cli.Command) error {
log.Info().Msgf("config path: %s", configs.GetConfigPath())

if command.Args().Len() == 0 {
return browser.OpenFile(configs.GetConfigPath())
}

cmd := command.Args().First()

path := assert.Exit1(filepath.Abs(configs.GetConfigPath()))
shell := fmt.Sprintf(`%s "%s"`, cmd, path)
log.Info().Msgf("edit config: %s", shell)
_, err := script.Exec(shell).Stdout()
return err
Comment on lines +45 to +48

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The way the shell command is constructed and executed is vulnerable to command injection. Since cmd is taken directly from user arguments and script.Exec passes the string to a shell, a malicious argument like vim; rm -rf / could be executed. You should use os/exec to run the editor, passing the command and the file path as separate arguments to avoid shell interpretation. This will also fix the issue with interactive editors, as .Stdout() prevents interactivity. I see you've already refactored utils.RunOutput to use os/exec; a similar approach should be applied here. You will need to import the os/exec package.

shell := fmt.Sprintf(`%s "%s"`, cmd, path)
log.Info().Msgf("edit config: %s", shell)

editorCmd := exec.CommandContext(ctx, cmd, path)
editorCmd.Stdin = os.Stdin
editorCmd.Stdout = os.Stdout
editorCmd.Stderr = os.Stderr
return editorCmd.Run()

},
},
},
}
}
22 changes: 12 additions & 10 deletions cmds/envcmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package envcmd

import (
"context"

"github.com/pubgo/fastcommit/configs"
"github.com/pubgo/funk/assert"

"github.com/pubgo/funk/env"
"github.com/pubgo/funk/pretty"
"github.com/pubgo/funk/recovery"
"github.com/samber/lo"
"github.com/urfave/cli/v3"
"gopkg.in/yaml.v3"

"github.com/pubgo/fastcommit/configs"
)

func New() *cli.Command {
Expand All @@ -18,15 +18,17 @@ func New() *cli.Command {
Usage: "show all envs",
Action: func(ctx context.Context, command *cli.Command) error {
defer recovery.Exit()
var envData = configs.GetEnvConfig()
var envMap = make(map[string]*configs.EnvConfig)
assert.Must(yaml.Unmarshal(envData, &envMap))
for name := range envMap {
envMap[name].Name = name

envMap := configs.GetEnvMap()
for name, cfg := range envMap {
envData := env.Get(name)
if envData == "" {
continue
}
cfg.Default = envData
}

pretty.Println(lo.Values(envMap))

return nil
},
}
Expand Down
Loading
Loading