Skip to content
This repository was archived by the owner on Aug 24, 2024. It is now read-only.

Commit 3561cc9

Browse files
committed
root: data loss disclaimer and prompt for explicit agreement
1 parent 4c67dac commit 3561cc9

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

root.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,13 @@ import (
1313

1414
const rootCommandName = "git-bug-migration"
1515

16+
type rootOpts struct {
17+
forReal bool
18+
}
19+
1620
func NewRootCommand() *cobra.Command {
1721
env := newEnv()
22+
opts := rootOpts{}
1823

1924
migrations := []Migration{
2025
&migration1.Migration1{},
@@ -36,19 +41,30 @@ To migrate a repository, go to the corresponding repository and run "git-bug-mig
3641

3742
PreRunE: findRepo(env),
3843
RunE: func(_ *cobra.Command, _ []string) error {
39-
return runRootCmd(env, migrations)
44+
return runRootCmd(env, opts, migrations)
4045
},
4146

4247
SilenceUsage: true,
4348
DisableAutoGenTag: true,
4449
}
4550

51+
flags := cmd.Flags()
52+
flags.BoolVar(&opts.forReal, "for-real", false, "Indicate that your really want to run this tool and possibly ruin your data.")
53+
4654
cmd.AddCommand(newVersionCommand())
4755

4856
return cmd
4957
}
5058

51-
func runRootCmd(env *Env, migrations []Migration) error {
59+
func runRootCmd(env *Env, opts rootOpts, migrations []Migration) error {
60+
if !opts.forReal {
61+
env.err.Println("DISCLAIMER: This tool exist for your convenience to migrate your data and allow git-bug's authors" +
62+
" to break things and make it better. However, this migration tool is quite crude and experimental. DO NOT TRUST IT BLINDLY.\n\n" +
63+
"Please make a backup of your .git folder before running it.\n\n" +
64+
"When done, run this tool again with the --for-real flag.")
65+
os.Exit(1)
66+
}
67+
5268
for i, migration := range migrations {
5369
if i > 0 {
5470
env.out.Println()

0 commit comments

Comments
 (0)