Browse Source

cmd: fix unable to find correct custom config

ᴜɴᴋɴᴡᴏɴ 5 years ago
parent
commit
d3ecd22dba

File diff suppressed because it is too large
+ 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("password", "", "User password"),
 			stringFlag("email", "", "User email address"),
 			stringFlag("email", "", "User email address"),
 			boolFlag("admin", "User is an admin"),
 			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",
 			"All inactivate accounts have been deleted successfully",
 		),
 		),
 		Flags: []cli.Flag{
 		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",
 			"All repositories archives have been deleted successfully",
 		),
 		),
 		Flags: []cli.Flag{
 		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",
 			"All repositories archives have been deleted successfully",
 		),
 		),
 		Flags: []cli.Flag{
 		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",
 			"All repositories have done garbage collection successfully",
 		),
 		),
 		Flags: []cli.Flag{
 		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",
 			"All public keys have been rewritten successfully",
 		),
 		),
 		Flags: []cli.Flag{
 		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",
 			"All repositories' pre-receive, update and post-receive hooks have been resynced successfully",
 		),
 		),
 		Flags: []cli.Flag{
 		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",
 			"All repository records that lost Git files have been reinitialized successfully",
 		),
 		),
 		Flags: []cli.Flag{
 		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.`,
 portable among all supported database engines.`,
 	Action: runBackup,
 	Action: runBackup,
 	Flags: []cli.Flag{
 	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"),
 		boolFlag("verbose, v", "Show process details"),
 		stringFlag("tempdir, t", os.TempDir(), "Temporary directory path"),
 		stringFlag("tempdir, t", os.TempDir(), "Temporary directory path"),
 		stringFlag("target", "./", "Target directory path to save backup archive"),
 		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",
 		Usage:       "Delegate commands to corresponding Git hooks",
 		Description: "All sub-commands should only be called by Git",
 		Description: "All sub-commands should only be called by Git",
 		Flags: []cli.Flag{
 		Flags: []cli.Flag{
-			stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"),
+			stringFlag("config, c", "", "Custom configuration file path"),
 		},
 		},
 		Subcommands: []cli.Command{
 		Subcommands: []cli.Command{
 			subcmdHookPreReceive,
 			subcmdHookPreReceive,

+ 1 - 1
internal/cmd/import.go

@@ -37,7 +37,7 @@ without manually hacking the data files`,
 		Flags: []cli.Flag{
 		Flags: []cli.Flag{
 			stringFlag("source", "", "Source directory that stores new locale files"),
 			stringFlag("source", "", "Source directory that stores new locale files"),
 			stringFlag("target", "", "Target directory that stores old 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.`,
 be skipped and remain unchanged.`,
 	Action: runRestore,
 	Action: runRestore,
 	Flags: []cli.Flag{
 	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"),
 		boolFlag("verbose, v", "Show process details"),
 		stringFlag("tempdir, t", os.TempDir(), "Temporary directory path"),
 		stringFlag("tempdir, t", os.TempDir(), "Temporary directory path"),
 		stringFlag("from", "", "Path to backup archive"),
 		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`,
 	Description: `Serv provide access auth for repositories`,
 	Action:      runServ,
 	Action:      runServ,
 	Flags: []cli.Flag{
 	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,
 	Action: runWeb,
 	Flags: []cli.Flag{
 	Flags: []cli.Flag{
 		stringFlag("port, p", "3000", "Temporary port number to prevent conflict"),
 		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
 	File.NameMapper = ini.SnackCase
 
 
-	customConf, err = filepath.Abs(customConf)
-	if err != nil {
-		return errors.Wrap(err, "get absolute path")
-	}
 	if customConf == "" {
 	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
 	CustomConf = customConf
 
 

Some files were not shown because too many files changed in this diff