8000 getFileDiffsWithBasehead(): use CODE_SCANNING_REPOSITORY if present by cklin · Pull Request #2830 · github/codeql-action · GitHub
[go: up one dir, main page]

Skip to content

getFileDiffsWithBasehead(): use CODE_SCANNING_REPOSITORY if present #2830

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 27, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
8000
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add getRepositoryNwo() helper functions
  • Loading branch information
cklin committed Mar 26, 2025
commit b22f3341fe006de1c0cd6d58cb816e3f00628ec6
32 changes: 31 additions & 1 deletion src/repository.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,41 @@
import { ConfigurationError } from "./util";
import { ConfigurationError, getRequiredEnvParam } from "./util";

// A repository name with owner, parsed into its two parts
export interface RepositoryNwo {
owner: string;
repo: string;
}

/**
* Get the repository name with owner from the environment variable
* `GITHUB_REPOSITORY`.
*
* @returns The repository name with owner.
*/
export function getRepositoryNwo(): RepositoryNwo {
return getRepositoryNwoFromEnv("GITHUB_REPOSITORY");
}

/**
* Get the repository name with owner from the first environment variable that
* is set and non-empty.
*
* @param envVarNames The names of the environment variables to check.
* @returns The repository name with owner.
* @throws ConfigurationError if none of the environment variables are set.
*/
export function getRepositoryNwoFromEnv(
...envVarNames: string[]
): RepositoryNwo {
const envVarName = envVarNames.find((name) => process.env[name]);
if (!envVarName) {
throw new ConfigurationError(
`None of the env vars ${envVarNames.join(", ")} are set`,
);
}
return parseRepositoryNwo(getRequiredEnvParam(envVarName));
}

export function parseRepositoryNwo(input: string): RepositoryNwo {
const parts = input.split("/");
if (parts.length !== 2) {
Expand Down
0