ethers.js/lib.esm/_admin/utils/git.js

18 lines
533 B
JavaScript
Raw Normal View History

2022-09-27 10:45:27 +03:00
import { run } from "./run.js";
// Returns the most recent git commit hash for a given filename
export async function getGitTag(filename) {
const result = await run("git", ["log", "-n", "1", "--", filename]);
if (!result.ok) {
throw new Error(`git log error`);
}
let log = result.stdout.trim();
if (!log) {
return null;
}
const hashMatch = log.match(/^commit\s+([0-9a-f]{40})\n/i);
if (!hashMatch) {
return null;
}
return hashMatch[1];
}
//# sourceMappingURL=git.js.map