func getRepoDetailsByPath()

in cli/bpmetadata/repo.go [31:75]


func getRepoDetailsByPath(bpPath string, r *repoDetail, readme []byte) {
	// For a submodule, we'll try to get repo details from the
	// root blueprint or just return the current repoDetail object
	// if it's still in memory.
	if strings.Contains(bpPath, nestedBpPath) && r.Source != nil {
		// try to parse the module name from MD which will get
		// overridden with "["repoName-submoduleName" if repoName is available
		r.ModuleName = parseRepoNameFromMd(readme)
		if r.RepoName != "" {
			r.ModuleName = r.RepoName + "-" + getBpSubmoduleNameInKebabCase(bpPath)
		}

		return
	}

	s := "git"
	bpRootPath := getBlueprintRootPath(bpPath)
	currentRootRepoDetails := getRepoDetailsFromRootBp(bpRootPath)
	bpPath = strings.TrimSuffix(bpPath, "/")
	repoUrl, repoRoot, err := util.GetRepoUrlAndRootPath(bpPath)
	if err != nil {
		repoUrl = ""
		s = ""
	}

	if currentRootRepoDetails.Source.URL != "" {
		repoUrl = currentRootRepoDetails.Source.URL
	}

	n, err := util.GetRepoName(repoUrl)
	if err != nil {
		n = parseRepoNameFromMd(readme)
	}

	*r = repoDetail{
		RepoName:   n,
		ModuleName: n,
		Source: &repoSource{
			URL:               repoUrl,
			SourceType:        s,
			BlueprintRootPath: bpRootPath,
			RepoRootPath:      repoRoot,
		},
	}
}