The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/scripts/cli/analytics/codeowners.mts

21 lines
793 B

import path from 'path';
import { OwnershipEngine } from 'github-codeowners/dist/lib/ownership/index.js';
const CODEOWNERS_PATH = path.resolve('.github/CODEOWNERS');
let engine: { calcFileOwnership(filePath: string): string[] } | null = null;
const getEngine = (): { calcFileOwnership(filePath: string): string[] } => {
engine ??= OwnershipEngine.FromCodeownersFile(CODEOWNERS_PATH);
return engine;
};
/**
* Returns the owners for the given file path.
* Uses the same OwnershipEngine as the CI/CD codeowners tooling.
* Returns undefined when no rule matches.
*/
export const resolveOwner = (relativeFilePath: string): string | undefined => {
const owners: string[] = getEngine().calcFileOwnership(relativeFilePath);
return owners.length > 0 ? owners.join(', ') : undefined;
};