Implement refactor merge comments

This commit is contained in:
Nora 2022-12-20 11:03:12 +00:00
Родитель f332e6145a
Коммит 467d43c68c
4 изменённых файлов: 15 добавлений и 15 удалений

Просмотреть файл

@ -5,7 +5,7 @@ import { OWNER_REGEX, REPO_REGEX } from "../pure/helpers-pure";
* @param identifier The GitHub NWO
* @returns
*/
export function validGitHubNwo(identifier: string): boolean {
export function isValidGitHubNwo(identifier: string): boolean {
return validGitHubNwoOrOwner(identifier, "nwo");
}
@ -14,7 +14,7 @@ export function validGitHubNwo(identifier: string): boolean {
* @param identifier The GitHub owner
* @returns
*/
export function validGitHubOwner(identifier: string): boolean {
export function isValidGitHubOwner(identifier: string): boolean {
return validGitHubNwoOrOwner(identifier, "owner");
}
@ -28,7 +28,7 @@ function validGitHubNwoOrOwner(
}
/**
* Extracts an NOW from a GitHub URL.
* Extracts an NWO from a GitHub URL.
* @param githubUrl The GitHub repository URL
* @return The corresponding NWO, or undefined if the URL is not valid
*/

Просмотреть файл

@ -24,7 +24,7 @@ import { Credentials } from "./authentication";
import { getErrorMessage } from "./pure/helpers-pure";
import {
getNwoFromGitHubUrl,
validGitHubNwo,
isValidGitHubNwo,
} from "./common/github-url-identifier-helper";
/**
@ -101,7 +101,7 @@ export async function promptImportGithubDatabase(
}
const nwo = getNwoFromGitHubUrl(githubRepo) || githubRepo;
if (!validGitHubNwo(nwo)) {
if (!isValidGitHubNwo(nwo)) {
throw new Error(`Invalid GitHub repository: ${githubRepo}`);
}

Просмотреть файл

@ -7,9 +7,9 @@ import {
import { commandRunner, UserCancellationException } from "../../commandRunner";
import {
getNwoFromGitHubUrl,
validGitHubNwo,
isValidGitHubNwo,
getOwnerFromGitHubUrl,
validGitHubOwner,
isValidGitHubOwner,
} from "../../common/github-url-identifier-helper";
import { showAndLogErrorMessage } from "../../helpers";
import { DisposableObject } from "../../pure/disposable-object";
@ -123,7 +123,7 @@ export class DbPanel extends DisposableObject {
}
const nwo = getNwoFromGitHubUrl(repoName) || repoName;
if (!validGitHubNwo(nwo)) {
if (!isValidGitHubNwo(nwo)) {
throw new Error(`Invalid GitHub repository: ${repoName}`);
}
@ -142,7 +142,7 @@ export class DbPanel extends DisposableObject {
}
const owner = getOwnerFromGitHubUrl(ownerName) || ownerName;
if (!validGitHubOwner(owner)) {
if (!isValidGitHubOwner(owner)) {
throw new Error(`Invalid user or organization: ${owner}`);
}

Просмотреть файл

@ -1,23 +1,23 @@
import {
getNwoFromGitHubUrl,
getOwnerFromGitHubUrl,
validGitHubNwo,
validGitHubOwner,
isValidGitHubNwo,
isValidGitHubOwner,
} from "../../../src/common/github-url-identifier-helper";
describe("github url identifier helper", () => {
describe("valid GitHub Nwo Or Owner method", () => {
it("should return true for valid owner", () => {
expect(validGitHubOwner("github")).toBe(true);
expect(isValidGitHubOwner("github")).toBe(true);
});
it("should return true for valid NWO", () => {
expect(validGitHubNwo("github/codeql")).toBe(true);
expect(isValidGitHubNwo("github/codeql")).toBe(true);
});
it("should return false for invalid owner", () => {
expect(validGitHubOwner("github/codeql")).toBe(false);
expect(isValidGitHubOwner("github/codeql")).toBe(false);
});
it("should return false for invalid NWO", () => {
expect(validGitHubNwo("githubl")).toBe(false);
expect(isValidGitHubNwo("githubl")).toBe(false);
});
});