-
Notifications
You must be signed in to change notification settings - Fork 23
feat(git): allow adding all files #81
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -89,6 +89,12 @@ func getComitters(osArgs []string) ([]string, error) { | |
| return result, nil | ||
| } | ||
|
|
||
| // buildAddAllCommitCommand builds the git commit command to stage all files | ||
| func buildAddAllCommitCommand() ([]string, string) { | ||
|
Owner
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. If we merge the other PR first, we can use the |
||
| args := append([]string{"add", "--all", ":/"}) | ||
| return args, fmt.Sprintf("git %v", shellescape.QuoteCommand(args)) | ||
| } | ||
|
|
||
| // commit commits the changes to git | ||
| func commit(command []string) error { | ||
| cmd := exec.Command("git", command...) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ import ( | |
|
|
||
| "github.com/charmbracelet/log" | ||
| "github.com/fatih/color" | ||
|
|
||
| "github.com/stefanlogue/meteor/internal/util" | ||
|
|
||
| "github.com/atotto/clipboard" | ||
|
|
@@ -45,6 +46,7 @@ var ( | |
| debugMode bool | ||
| skipIntro bool | ||
| skipBreakingChange bool | ||
| addAll bool | ||
| FS afero.Fs = afero.NewOsFs() | ||
| AFS *afero.Afero = &afero.Afero{Fs: FS} | ||
| ) | ||
|
|
@@ -61,6 +63,7 @@ func init() { | |
| flag.BoolVarP(&skipIntro, "skip-intro", "s", false, "skip intro splash") | ||
| flag.BoolVarP(&debugMode, "debug", "D", false, "enable debug mode") | ||
| flag.BoolVarP(&skipBreakingChange, "skip-breaking-change", "b", false, "skip breaking change prompt") | ||
| flag.BoolVarP(&addAll, "add-all", "a", false, "add all unstaged changes to commit") | ||
| flag.Parse() | ||
| if isFlagPassed("version") { | ||
| fmt.Printf("meteor version %s\n", version) | ||
|
|
@@ -101,6 +104,10 @@ func main() { | |
| fail(ErrorString, err) | ||
| } | ||
|
|
||
| if !config.AddAll && addAll { | ||
| config.AddAll = true | ||
| } | ||
|
|
||
| var newCommit Commit | ||
| theme := huh.ThemeCatppuccin() | ||
| if config.ShowIntro && (isFlagPassed("skip-intro") && !skipIntro) { | ||
|
|
@@ -304,6 +311,20 @@ func main() { | |
| args = args[1:] | ||
| } | ||
|
|
||
| if config.AddAll { | ||
| rawCommitCommand, printableCommitCommand := buildAddAllCommitCommand() | ||
| err = commit(rawCommitCommand) | ||
| if err != nil { | ||
| writeToClipboard(printableCommitCommand) | ||
| fail( | ||
| "\n%s\n%s\n\n%s\n\n", | ||
| color.RedString(fmt.Sprintf("It looks like the add all failed.\nError: %s", err)), | ||
| color.YellowString("To run it again without going through meteor's wizard, simply run the following command (I've copied it to your clipboard!):"), | ||
| color.BlueString(printableCommitCommand), | ||
| ) | ||
| return | ||
| } | ||
| } | ||
|
Comment on lines
+314
to
+327
Owner
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. Have you called the wrong build function here?
Author
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. also, osargs are probably tailored to the commit functinality and make no sense in |
||
| rawCommitCommand, printableCommitCommand := buildCommitCommand(newCommit.Message, newCommit.Body, args) | ||
|
|
||
| if isFlagPassed(AsGitEditor) { | ||
|
|
||
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.
It would be nice to also have some explanation in the readme for what this flag (and the other new one) actually does