Procházet zdrojové kódy

cmd: fix unable to find correct custom config

ᴜɴᴋɴᴡᴏɴ před 5 roky
rodič
revize
d3ecd22dba

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 1
internal/assets/templates/templates_gen.go


+ 8 - 8
internal/cmd/admin.go

@@ -43,7 +43,7 @@ to make automatic initialization process more smoothly`,
 			stringFlag("password", "", "User password"),
 			stringFlag("email", "", "User email address"),
 			boolFlag("admin", "User is an admin"),
-			stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"),
+			stringFlag("config, c", "", "Custom configuration file path"),
 		},
 	}
 
@@ -55,7 +55,7 @@ to make automatic initialization process more smoothly`,
 			"All inactivate accounts have been deleted successfully",
 		),
 		Flags: []cli.Flag{
-			stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"),
+			stringFlag("config, c", "", "Custom configuration file path"),
 		},
 	}
 
@@ -67,7 +67,7 @@ to make automatic initialization process more smoothly`,
 			"All repositories archives have been deleted successfully",
 		),
 		Flags: []cli.Flag{
-			stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"),
+			stringFlag("config, c", "", "Custom configuration file path"),
 		},
 	}
 
@@ -79,7 +79,7 @@ to make automatic initialization process more smoothly`,
 			"All repositories archives have been deleted successfully",
 		),
 		Flags: []cli.Flag{
-			stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"),
+			stringFlag("config, c", "", "Custom configuration file path"),
 		},
 	}
 
@@ -91,7 +91,7 @@ to make automatic initialization process more smoothly`,
 			"All repositories have done garbage collection successfully",
 		),
 		Flags: []cli.Flag{
-			stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"),
+			stringFlag("config, c", "", "Custom configuration file path"),
 		},
 	}
 
@@ -103,7 +103,7 @@ to make automatic initialization process more smoothly`,
 			"All public keys have been rewritten successfully",
 		),
 		Flags: []cli.Flag{
-			stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"),
+			stringFlag("config, c", "", "Custom configuration file path"),
 		},
 	}
 
@@ -115,7 +115,7 @@ to make automatic initialization process more smoothly`,
 			"All repositories' pre-receive, update and post-receive hooks have been resynced successfully",
 		),
 		Flags: []cli.Flag{
-			stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"),
+			stringFlag("config, c", "", "Custom configuration file path"),
 		},
 	}
 
@@ -127,7 +127,7 @@ to make automatic initialization process more smoothly`,
 			"All repository records that lost Git files have been reinitialized successfully",
 		),
 		Flags: []cli.Flag{
-			stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"),
+			stringFlag("config, c", "", "Custom configuration file path"),
 		},
 	}
 )

+ 1 - 1
internal/cmd/backup.go

@@ -31,7 +31,7 @@ which can be used for migrating Gogs to another server. The output format is mea
 portable among all supported database engines.`,
 	Action: runBackup,
 	Flags: []cli.Flag{
-		stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"),
+		stringFlag("config, c", "", "Custom configuration file path"),
 		boolFlag("verbose, v", "Show process details"),
 		stringFlag("tempdir, t", os.TempDir(), "Temporary directory path"),
 		stringFlag("target", "./", "Target directory path to save backup archive"),

+ 1 - 1
internal/cmd/hook.go

@@ -34,7 +34,7 @@ var (
 		Usage:       "Delegate commands to corresponding Git hooks",
 		Description: "All sub-commands should only be called by Git",
 		Flags: []cli.Flag{
-			stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"),
+			stringFlag("config, c", "", "Custom configuration file path"),
 		},
 		Subcommands: []cli.Command{
 			subcmdHookPreReceive,

+ 1 - 1
internal/cmd/import.go

@@ -37,7 +37,7 @@ without manually hacking the data files`,
 		Flags: []cli.Flag{
 			stringFlag("source", "", "Source directory that stores new locale files"),
 			stringFlag("target", "", "Target directory that stores old locale files"),
-			stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"),
+			stringFlag("config, c", "", "Custom configuration file path"),
 		},
 	}
 )

+ 1 - 1
internal/cmd/restore.go

@@ -32,7 +32,7 @@ If corresponding files or database tables are not presented in the archive, they
 be skipped and remain unchanged.`,
 	Action: runRestore,
 	Flags: []cli.Flag{
-		stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"),
+		stringFlag("config, c", "", "Custom configuration file path"),
 		boolFlag("verbose, v", "Show process details"),
 		stringFlag("tempdir, t", os.TempDir(), "Temporary directory path"),
 		stringFlag("from", "", "Path to backup archive"),

+ 1 - 1
internal/cmd/serv.go

@@ -31,7 +31,7 @@ var Serv = cli.Command{
 	Description: `Serv provide access auth for repositories`,
 	Action:      runServ,
 	Flags: []cli.Flag{
-		stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"),
+		stringFlag("config, c", "", "Custom configuration file path"),
 	},
 }
 

+ 1 - 1
internal/cmd/web.go

@@ -53,7 +53,7 @@ and it takes care of all the other things for you`,
 	Action: runWeb,
 	Flags: []cli.Flag{
 		stringFlag("port, p", "3000", "Temporary port number to prevent conflict"),
-		stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"),
+		stringFlag("config, c", "", "Custom configuration file path"),
 	},
 }
 

+ 6 - 5
internal/conf/conf.go

@@ -72,12 +72,13 @@ func Init(customConf string) error {
 	}
 	File.NameMapper = ini.SnackCase
 
-	customConf, err = filepath.Abs(customConf)
-	if err != nil {
-		return errors.Wrap(err, "get absolute path")
-	}
 	if customConf == "" {
-		customConf = filepath.Join(CustomDir(), "conf/app.ini")
+		customConf = filepath.Join(CustomDir(), "conf", "app.ini")
+	} else {
+		customConf, err = filepath.Abs(customConf)
+		if err != nil {
+			return errors.Wrap(err, "get absolute path")
+		}
 	}
 	CustomConf = customConf
 

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů