function getRepoLink()

in eng/scripts/inventory-dashboard/src/formatData.ts [347:383]


function getRepoLink(pkg: any): string {
  // property and property type check
  if (pkg.RepoPath && typeof pkg.RepoPath === "string") {
    // if RepoPath prop starts with github, return it
    if (pkg.RepoPath.startsWith("https://github.com")) {
      return pkg.RepoPath;
    } else if (
      pkg.Language &&
      typeof pkg.Language === "string" &&
      languageToRepoMapping[pkg.Language]
    ) {
      // if RepoPath doesn't start with github link, prefix the RepoPath with github link for language mono repo
      return languageToRepoMapping[pkg.Language] + "/" + pkg.RepoPath;
    } else {
      log.warn(
        `RepoLink could not be determined. Package: ${JSON.stringify(pkg)}`
      );
    }
  }
  // if RepoPath prop is blank of missing and language is Go, use the package name to create the RepoLink
  else if (
    pkg.Language &&
    pkg.Language === "Go" &&
    ((pkg.RepoPath && pkg.RepoPath === "") || pkg.RepoLink === undefined) &&
    pkg.Package &&
    typeof pkg.Package === "string" &&
    pkg.Package !== ""
  ) {
    return "https://github.com/Azure/azure-sdk-for-go/tree/main/" + pkg.Package;
  } else {
    // Logging for when a RepoLink can't be determined
    log.warn(
      `RepoLink could not be determine. Package: ${JSON.stringify(pkg)}`
    );
  }
  return "UNABLE TO DETERMINE REPO LINK";
}