func()

in config/config.go [144:179]


func (c *Config) ComputeName(path string) error {
	repo, err := git.PlainOpen(path)
	if err != nil {
		return fmt.Errorf("could not open local git directory: %s", err)
	}

	remotes, err := repo.Remotes()
	if err != nil {
		return err
	}

	remote := ""
	for _, v := range remotes {
		for _, url := range v.Config().URLs {
			if strings.Contains(strings.ToLower(url), "googlecloudplatform") {
				remote = strings.ToLower(url)
			}
		}
	}

	// Fixes bug where ssh called repos have issues. Super edge case, but
	// now its all testable
	remote = strings.ReplaceAll(remote, "git@github.com:", "https://github.com/")

	u, err := url.Parse(remote)
	if err != nil {
		return fmt.Errorf("could not parse git url: %s", err)
	}

	shortname := filepath.Base(u.Path)
	shortname = strings.ReplaceAll(shortname, ".git", "")
	shortname = strings.ReplaceAll(shortname, "deploystack-", "")
	c.Name = shortname

	return nil
}