A => .gitignore +1 -0
A => LICENSE +19 -0
@@ 1,19 @@
+Copyright (c) 2016 Siegfried Ehret <siegfried@ehret.me>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
A => README.md +48 -0
@@ 1,48 @@
+# gitzytout
+
+> git z'y tout !<br>
+(git them all!)
+
+A very small thing that reads a yaml config file and pushes to the given git repositories.
+
+Made to solve the problem of having your code centralized only on Github or Gitlab...
+
+## how to
+
+First, create a `gitzytout.yaml` file, with some content:
+
+```
+mirrors:
+- https://gitlab.com/SiegfriedEhret/gitzytout
+- https://github.com/SiegfriedEhret/gitzytout
+```
+
+## todo
+
+- [ ] Check with https/ssl urls
+- [ ] Check with passphrase keys
+- [ ] [Add a main item](https://gitlab.com/SiegfriedEhret/gitzytout/issues/1) ?
+
+## licence
+
+```
+Copyright (c) 2016 Siegfried Ehret <siegfried@ehret.me>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+```
A => gitzytout.yaml +3 -0
@@ 1,3 @@
+main: git@gitlab.com:SiegfriedEhret/test.git
+mirrors:
+- git@github.com:SiegfriedEhret/test.git
A => main.go +62 -0
@@ 1,62 @@
+package main
+
+import (
+ "fmt"
+ "io/ioutil"
+ "os/exec"
+ "os/user"
+ "strings"
+
+ "github.com/ghodss/yaml"
+)
+
+type Config struct {
+ Main string `json:"main"`
+ Mirrors []string `json:"mirrors"`
+}
+
+func (c Config) String() string {
+ return strings.Join(c.Mirrors, ", ")
+}
+
+func GetUserDir() string {
+ usr, err := user.Current()
+ if err != nil {
+ fmt.Println("!! Can't get current user", err)
+ return ""
+ }
+
+ return usr.HomeDir
+}
+
+func main() {
+ fmt.Println(" gitzytout\n =========")
+
+ const configPath string = "gitzytout.yaml"
+
+ data, err := ioutil.ReadFile(configPath)
+ if err != nil {
+ fmt.Printf("Can't read config %s", configPath)
+ }
+
+ var conf Config
+ unmarshalErr := yaml.Unmarshal(data, &conf)
+
+ if unmarshalErr != nil {
+ fmt.Println("Can't decode yaml !")
+ }
+
+ fmt.Println(conf)
+
+ // git remote set-url origin --push --add git@gitlab.com:SiegfriedEhret/test.git
+ // git remote set-url origin --push --add git@github.com:SiegfriedEhret/test.git
+
+ for _, mirror := range conf.Mirrors {
+ cmd := exec.Command("git", "remote", "set-url", "origin", "--push", "--add", mirror)
+ fmt.Println(cmd)
+ err = cmd.Run()
+ if err != nil {
+ fmt.Println("Error while running `" + strings.Join(cmd.Args, " ") + "`")
+ }
+ }
+}