-
Notifications
You must be signed in to change notification settings - Fork 1
Feat: tag & upgrade & version & fastcommit #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2fcbb36
1bc7f51
e70b67c
e98374a
723c6a0
4eba156
beb8c5f
b93488d
c1c85b1
a551971
964ea7c
431724c
c604f89
8072683
65f9bbb
12d1202
86270f1
b114171
621cd11
fbf4cd5
499e6c3
ce1b0c5
42babf8
e70d729
6d25abd
3657298
67db605
36d6071
1043f8c
1b95140
d35d502
2e99c4f
9080aff
5f7ba1e
95ec6b7
dcd8d40
f9a5f66
b79d52b
74aaf3b
424a7f9
5c1e9bb
dec2316
76c70cd
8474a8e
92eafd7
eceacdc
eb267f1
c9eeb75
d27dc0c
c34bc2a
959bc1a
4928235
9b6ccbf
64d0bd6
fcae22d
c3ed99f
b8ef1c8
5e4f74c
9256128
fdc623d
67babd6
8b752f0
ea48f6e
1e7ac42
417d823
12fbefd
d72cd25
d23c96f
5c807c7
269cbd4
2b79037
2c22ba1
5a32664
1939ed6
4d98837
eccc4e3
dccd7e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v0.0.6 |
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 |
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()) | ||
} |
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The way the shell command is constructed and executed is vulnerable to command injection. Since 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() |
||
}, | ||
}, | ||
}, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.