Files
FrenoCorp/node_modules/fast-stable-stringify/util/get-git-hash-sync.js
Michael Freno 7c684a42cc FRE-600: Fix code review blockers
- Consolidated duplicate UndoManagers to single instance
- Fixed connection promise to only resolve on 'connected' status
- Fixed WebSocketProvider import (WebsocketProvider)
- Added proper doc.destroy() cleanup
- Renamed isPresenceInitialized property to avoid conflict

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-25 00:08:01 -04:00

22 lines
817 B
JavaScript

var cp = require('child_process');
/**
* Returns the version string of the current working directory.
* It is the git short hash of the last commit that changed filePath
* If there are uncommitted changes to this filePath, this method will throw.
* @returns {string}
*/
module.exports = function getGitHashSync(filePath) {
var commandResult;
try {
cp.execSync('git diff-index --quiet HEAD -- ' + filePath, { encoding: 'utf-8' });
} catch (err) {
//throw new Error('Cannot resolve git hash of file ' + filePath + ': There are uncommitted changes to file ' + filePath);
}
commandResult = cp.execSync('git log -n1 --pretty=format:%h -- ' + filePath, { encoding: 'utf-8' });
if (!commandResult) {
throw new Error("Could not get hash: file " + filePath + " does not exist");
}
return commandResult;
};