add confirmation on sync before pushing changes

pull/32/head
Marcus Kok 2 years ago
parent 1ac0ee3ac9
commit ec8ab9dfee

@ -132,11 +132,24 @@ func runSyncCommand(cmd *cobra.Command, args []string) {
} }
if !status.IsClean() { if !status.IsClean() {
fmt.Println("Changes detected, committing and pushing...") fmt.Println("Changes detected, do you want to push them?")
confirm := promptui.Prompt {
Label: "commit and push changes",
IsConfirm: true,
}
_, err := confirm.Run()
if err != nil {
fmt.Println("Will not push changes")
return
}
fmt.Println("Pushing changes...")
err = gitAddFiles(w, FileSystem) err = gitAddFiles(w, FileSystem)
if err != nil { if err != nil {
log.Fatalf("Could not add files: %s\n", err) log.Fatalf("Could not add files: %s\n", err)
return
} }
commitMessage := "backup " + time.Now().String() commitMessage := "backup " + time.Now().String()
@ -172,8 +185,12 @@ func runSyncCommand(cmd *cobra.Command, args []string) {
} }
// a pull deletes the dotctl config from the filesystem, need to recreate it // a pull deletes the dotctl config from the filesystem, need to recreate it
rewriteConfig()
}
func rewriteConfig() {
fs := UseFilesystem() fs := UseFilesystem()
err = fs.MkdirAll(path.Join(DotfilePath, "dotctl"), 0755) err := fs.MkdirAll(path.Join(DotfilePath, "dotctl"), 0755)
if err != nil { if err != nil {
log.Fatalf("Unable to create dotfile structure: %s", error.Error(err)) log.Fatalf("Unable to create dotfile structure: %s", error.Error(err))
} }

Loading…
Cancel
Save