示例#1
0
文件: main.go 项目: CadeLaRen/gov
func report(ctx *cli.Context) {
	var path string
	var err error

	if len(ctx.Args()) < 1 {
		path, err = os.Getwd()
		if err != nil {
			log.Fatalf("Unable to get current directory: %s", err)
		}
	} else {
		path = ctx.Args()[0]
	}

	rs, err := vcs.FindRepos(path)
	if err != nil {
		log.Fatalf("error finding repos: %s", err)
		panic(err)
	}

	for _, r := range rs {
		if filepath.Clean(path) != filepath.Clean(r.Root()) {
			fmt.Printf("%s\t%t\t%v\n", r.Rev(), r.IsClean(), r.Root())
		}
	}
}
示例#2
0
文件: plan.go 项目: CadeLaRen/gov
func CreatePlanFor(path string) (Plan, error) {
	plan := Plan{}

	tr, err := vcs.FindRepoForPath(path)
	if err != nil {
		return plan, fmt.Errorf("target not under source control: %s", err)
	}
	plan.TargetRepo = tr

	repos, err := vcs.FindRepos(path)
	if err != nil {
		return plan, fmt.Errorf("no repos for %s: %s", path, err)
	}

	plan.DependentRepos = make([]vcs.Dependency, 0)
	for _, r := range repos {
		if tr.Root() != r.Root() {
			// exclude self repo
			plan.DependentRepos = append(plan.DependentRepos, r)
		}
	}

	return plan, nil
}