Skip to content

Commit 963073a

Browse files
committed
feat: Refactor and improve codegpt commit command.
- Refactor `codegpt commit` command flags - Add a `preview` flag to the `codegpt commit` command - Remove the `disbaleCommit` flag from the `prepare-commit-msg` template file
1 parent 824dc67 commit 963073a

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

README.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ You can call `codegpt` directly to generate a commit message for your staged cha
7070

7171
```sh
7272
git add <files...>
73-
codegpt commit
73+
codegpt commit --preview
7474
```
7575

7676
The commit message is shown below.
@@ -81,12 +81,10 @@ We are trying to summarize a git diff
8181
We are trying to summarize a title for pull request
8282
================Commit Summary====================
8383

84-
Add OpenAI integration and CLI usage instructions
84+
feat: Add preview flag and remove disableCommit flag in commit command and template file.
8585

86-
- Add download links for pre-compiled binaries for various platforms
87-
- Add instructions for setting up OpenAI API key
88-
- Add CLI usage instructions for generating commit messages with `codegpt`
89-
- Add references to OpenAI Chat completions documentation and introducing ChatGPT and Whisper APIs
86+
- Add a `preview` flag to the `commit` command
87+
- Remove the `disbaleCommit` flag from the `prepare-commit-msg` template file
9088

9189
==================================================
9290
Write the commit message to .git/COMMIT_EDITMSG file
@@ -95,7 +93,7 @@ Write the commit message to .git/COMMIT_EDITMSG file
9593
or translate all git commit messages into a different language (`Traditional Chinese`, `Simplified Chinese` or `Japanese`)
9694

9795
```sh
98-
codegpt commit --lang zh-tw
96+
codegpt commit --lang zh-tw --preview
9997
```
10098

10199
Consider the following outcome:
@@ -104,13 +102,13 @@ Consider the following outcome:
104102
Summarize the commit message use gpt-3.5-turbo model
105103
We are trying to summarize a git diff
106104
We are trying to summarize a title for pull request
107-
We are trying to translate a git commit message to Traditional Chineselanguage
105+
We are trying to translate a git commit message to Traditional Chinese language
108106
================Commit Summary====================
109-
增加發布頁面改進和CLI模式說明。
110107

111-
- 在發布頁面上增加了不同系統的預編譯二進制文件。
112-
- 提供設置OpenAI API密鑰的說明。
113-
- 提供使用CLI模式生成暫存更改的提交消息的說明。
108+
功能:重構 codegpt commit 命令標記
109+
110+
- 將「codegpt commit」命令新增「預覽」標記
111+
- 從「codegpt commit」命令中移除「--disableCommit」標記
114112

115113
==================================================
116114
Write the commit message to .git/COMMIT_EDITMSG file

cmd/commit.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ var (
2020
commitModel string
2121

2222
// disbale auot commit in Hook mode
23-
disableAutoCommit bool
23+
preview bool
2424
)
2525

2626
func init() {
2727
commitCmd.PersistentFlags().StringP("file", "f", ".git/COMMIT_EDITMSG", "commit message file")
28-
commitCmd.PersistentFlags().BoolVar(&disableAutoCommit, "disbaleCommit", false, "disable auto commit message")
28+
commitCmd.PersistentFlags().BoolVar(&preview, "preview", false, "preview commit message")
2929
commitCmd.PersistentFlags().StringVar(&commitModel, "model", "gpt-3.5-turbo", "select openai model")
3030
commitCmd.PersistentFlags().StringVar(&commitLang, "lang", "en", "summarizing language uses English by default")
3131
_ = viper.BindPFlag("output.file", commitCmd.PersistentFlags().Lookup("file"))
@@ -158,7 +158,7 @@ var commitCmd = &cobra.Command{
158158
return err
159159
}
160160

161-
if disableAutoCommit {
161+
if preview {
162162
return nil
163163
}
164164

git/templates/prepare-commit-msg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/sh
22

3-
codegpt commit --file $1 --disbaleCommit
3+
codegpt commit --file $1 --preview

0 commit comments

Comments
 (0)