예제 #1
0
func TestLoadRecursive(t *testing.T) {
	// given
	name := "fliglio/web"
	update := true
	dryrun := false
	recursive := true

	loader := &Loader{
		Stash:     stashClient,
		Packagist: packagist.New(),
		Satis:     satisClient,
		DestTpl:   cfg.Stash.RepoTpl,
		StashProj: cfg.Stash.ProjKey,
	}

	// when
	err := loader.Load(name, update, dryrun, recursive)

	//then
	assert.Nil(t, err)

	stashRepos, _ := stashClient.GetAllReposPage(cfg.Stash.ProjKey)
	assert.Equal(t, 8, len(stashRepos), "should be 1 repo")

	satisRepos, _ := satisClient.FindAllRepos()
	assert.Equal(t, 8, len(satisRepos), "should be 1 repo")

	cleanup()
}
예제 #2
0
func main() {
	update := flag.Bool("u", false, "update existing repositories")
	recursive := flag.Bool("r", false, "Recusively operate on all dependencies")
	dryrun := flag.Bool("dryrun", false, "perform dryrun")
	cfgPath := flag.String("config", "~/.composer-sync.yaml", "config path")

	flag.Parse()

	cfg, err := config.Load(*cfgPath)
	if err != nil {
		fmt.Printf("Bad Config: %s", err)
		os.Exit(1)
	}

	// Pull subcommand & package name from args
	if flag.NArg() != 1 {
		fmt.Printf("expected 1 arguments\n")
		flag.Usage()
		os.Exit(1)
	}

	name := flag.Arg(0)

	loginCmd := name == "login"

	if (cfg.Stash.Login == "" || cfg.Stash.Password == "") || loginCmd {
		if err := config.Login(cfg, *cfgPath, loginCmd); err != nil {
			fmt.Println(err)
			os.Exit(1)
		}

		if loginCmd {
			os.Exit(0)
		}
	}

	loader := &loader.Loader{
		Stash:     stash.New(cfg.Stash.ApiUrl, cfg.Stash.Login, cfg.Stash.Password),
		Packagist: packagist.New(),
		Satis:     &satis.SatisClient{Host: cfg.Satis.ApiUrl},
		DestTpl:   cfg.Stash.RepoTpl,
		StashProj: cfg.Stash.ProjKey,
	}

	if err := loader.Load(name, *update, *dryrun, *recursive); err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
}