mirror of
https://github.com/spacedriveapp/spacedrive
synced 2024-07-04 13:23:28 +00:00
* Setup script revamp * Move toml to dev dep + CI runs the postinstall in debug mode * Fix windows CI * chmod +x scripts/setup.sh * Fix eslint and ts CI * Remove binstall + Fix trying to read input in CI * Doesn't need to check pnpm and rust in CI * Run postinstall script for Clippy CI * Attempt to fix windows CI not running postinstall - Ignore cache when running postinstall on CI * commited generated config.toml by mistake * Pass GITHUB_TOKEN to `pnpm i` * Update archive-wasm + Increase minimum node version to 18.17 * CI: Move rust setup after post-install script * Revert: CI: Move rust setup after post-install script * Fix CI, generate dummy cargo config.toml to fix prisma generation * Fix windows CI * CI: Fix wrong command --------- Co-authored-by: Utku <74243531+utkubakir@users.noreply.github.com>
25 lines
553 B
JavaScript
25 lines
553 B
JavaScript
import * as fs from 'node:fs/promises';
|
|
import * as path from 'node:path';
|
|
|
|
const REF_REGEX = /ref:\s+refs\/heads\/(?<branch>\s+)/;
|
|
|
|
/**
|
|
* @param {string} repoPath
|
|
* @returns {Promise<string[]>}
|
|
*/
|
|
export async function getGitBranches(repoPath) {
|
|
const branches = ['main', 'master'];
|
|
|
|
let head;
|
|
try {
|
|
head = await fs.readFile(path.join(repoPath, '.git', 'HEAD'), { encoding: 'utf8' });
|
|
} catch {
|
|
return branches;
|
|
}
|
|
|
|
const match = REF_REGEX.exec(head);
|
|
if (match?.groups?.branch) branches.unshift(match.groups.branch);
|
|
|
|
return branches;
|
|
}
|