aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--cmd/import.go82
-rw-r--r--gogs.go3
-rw-r--r--templates/.VERSION2
4 files changed, 86 insertions, 3 deletions
diff --git a/README.md b/README.md
index 68e20d60..d3e1786b 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra
![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true)
-##### Current tip version: 0.9.100 (see [Releases](https://github.com/gogits/gogs/releases) for binary versions or submit a task on [alpha stage automated binary building system](https://build.gogs.io/))
+##### Current tip version: 0.9.101 (see [Releases](https://github.com/gogits/gogs/releases) for binary versions or submit a task on [alpha stage automated binary building system](https://build.gogs.io/))
| Web | UI | Preview |
|:-------------:|:-------:|:-------:|
diff --git a/cmd/import.go b/cmd/import.go
new file mode 100644
index 00000000..482361b6
--- /dev/null
+++ b/cmd/import.go
@@ -0,0 +1,82 @@
+// Copyright 2016 The Gogs Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package cmd
+
+import (
+ "fmt"
+ "os"
+ "path/filepath"
+ "time"
+
+ "github.com/Unknwon/com"
+ "github.com/urfave/cli"
+
+ "github.com/gogits/gogs/modules/setting"
+)
+
+var (
+ CmdImport = cli.Command{
+ Name: "import",
+ Usage: "Import portable data as local Gogs data",
+ Description: `Allow user import data from other Gogs installations to local instance
+without manually hacking the data files`,
+ Subcommands: []cli.Command{
+ subcmdImportLocale,
+ },
+ }
+
+ subcmdImportLocale = cli.Command{
+ Name: "locale",
+ Usage: "Import locale files to local repository",
+ Action: runImportLocale,
+ 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"),
+ },
+ }
+)
+
+func runImportLocale(c *cli.Context) error {
+ if !c.IsSet("source") {
+ return fmt.Errorf("Source directory is not specified")
+ } else if !c.IsSet("target") {
+ return fmt.Errorf("Target directory is not specified")
+ }
+ if !com.IsDir(c.String("source")) {
+ return fmt.Errorf("Source directory does not exist or is not a directory")
+ } else if !com.IsDir(c.String("target")) {
+ return fmt.Errorf("Target directory does not exist or is not a directory")
+ }
+
+ if c.IsSet("config") {
+ setting.CustomConf = c.String("config")
+ }
+
+ setting.NewContext()
+
+ now := time.Now()
+
+ // Cut out en-US.
+ for _, lang := range setting.Langs[1:] {
+ name := fmt.Sprintf("locale_%s.ini", lang)
+ source := filepath.Join(c.String("source"), name)
+ target := filepath.Join(c.String("target"), name)
+ if !com.IsFile(source) {
+ continue
+ }
+
+ if err := com.Copy(source, target); err != nil {
+ return fmt.Errorf("Copy file: %v", err)
+ }
+
+ // Modification time of files from Crowdin often ahead of current,
+ // so we need to set back to current.
+ os.Chtimes(target, now, now)
+ }
+
+ fmt.Println("Locale files has been successfully imported!")
+ return nil
+}
diff --git a/gogs.go b/gogs.go
index 0378bebf..e196b0f8 100644
--- a/gogs.go
+++ b/gogs.go
@@ -17,7 +17,7 @@ import (
"github.com/gogits/gogs/modules/setting"
)
-const APP_VER = "0.9.100.1119"
+const APP_VER = "0.9.101.1220"
func init() {
runtime.GOMAXPROCS(runtime.NumCPU())
@@ -36,6 +36,7 @@ func main() {
cmd.CmdDump,
cmd.CmdCert,
cmd.CmdAdmin,
+ cmd.CmdImport,
}
app.Flags = append(app.Flags, []cli.Flag{}...)
app.Run(os.Args)
diff --git a/templates/.VERSION b/templates/.VERSION
index 022770cc..f0c43973 100644
--- a/templates/.VERSION
+++ b/templates/.VERSION
@@ -1 +1 @@
-0.9.100.1119 \ No newline at end of file
+0.9.101.1220 \ No newline at end of file