Skip to content
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

git: Extract getRootPath() function #475

Merged
merged 1 commit into from
Aug 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const execa = require("execa");
const hostedGitInfo = require("hosted-git-info");

import ConfigurationError from "./configuration-error";
import { getRootPath } from "./git";

export interface Configuration {
repo: string;
Expand All @@ -20,9 +21,7 @@ export interface ConfigLoaderOptions {
}

export function load(options: ConfigLoaderOptions = {}): Configuration {
let cwd = process.cwd();
let rootPath = execa.sync("git", ["rev-parse", "--show-toplevel"], { cwd }).stdout;

let rootPath = getRootPath();
return fromPath(rootPath, options);
}

Expand Down
5 changes: 5 additions & 0 deletions src/git.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
const execa = require("execa");

export function getRootPath() {
const cwd = process.cwd();
return execa.sync("git", ["rev-parse", "--show-toplevel"], { cwd }).stdout;
}

export async function changedPaths(sha: string): Promise<string[]> {
const result = await execa("git", ["show", "-m", "--name-only", "--pretty=format:", "--first-parent", sha]);
return result.stdout.split("\n");
Expand Down