HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/shop.komma.nl/node_modules/env-ci/lib/git.js
const execa = require('execa');

function head(options) {
	try {
		return execa.sync('git', ['rev-parse', 'HEAD'], options).stdout;
	} catch (error) {
		return undefined;
	}
}

function branch(options) {
	try {
		const headRef = execa.sync('git', ['rev-parse', '--abbrev-ref', 'HEAD'], options).stdout;

		if (headRef === 'HEAD') {
			const branch = execa
				.sync('git', ['show', '-s', '--pretty=%d', 'HEAD'], options)
				.stdout.replace(/^\(|\)$/g, '')
				.split(', ')
				.find(branch => branch.startsWith('origin/'));
			return branch ? branch.match(/^origin\/(.+)/)[1] : undefined;
		}

		return headRef;
	} catch (error) {
		return undefined;
	}
}

module.exports = {head, branch};