Skip to content

Commit

Permalink
Merge pull request #517 from kellyselden/use_git_helpers
Browse files Browse the repository at this point in the history
refactor: use git helpers
  • Loading branch information
kellyselden authored Jul 17, 2024
2 parents 20e4641 + 86d62ee commit e297296
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions test/helpers/git.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
'use strict';

const execa = require('execa');
const {
git,
getLinesFromOutput,
} = require('../../src/git');

async function getLastCommitMessage(cwd) {
return (await execa('git', ['log', '-1', '--pretty=%B'], { cwd })).stdout.trim();
return (await git(['log', '-1', '--pretty=%B'], { cwd })).trim();
}

async function getTagsOnLastCommit(cwd) {
return (await execa('git', ['tag', '-l', '--points-at', 'HEAD'], { cwd })).stdout.split(/\r?\n/).filter(Boolean);
return getLinesFromOutput(await git(['tag', '-l', '--points-at', 'HEAD'], { cwd }));
}

async function doesTagExist(ref, cwd) {
try {
await execa('git', ['rev-parse', ref], { cwd });
await git(['rev-parse', ref], { cwd });
} catch (err) {
if (err.stderr.includes('unknown revision or path not in the working tree')) {
return false;
Expand All @@ -25,7 +28,7 @@ async function doesTagExist(ref, cwd) {
}

async function isGitClean(cwd) {
let { stdout } = await execa('git', ['status', '--porcelain'], { cwd });
let stdout = await git(['status', '--porcelain'], { cwd });

return !stdout;
}
Expand Down

0 comments on commit e297296

Please sign in to comment.