MCPcopy Index your code
hub / github.com/ether/etherpad / getGitCommit

Function getGitCommit

src/node/utils/Settings.ts:136–158  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

134
135// Provide git version if available
136export const getGitCommit = () => {
137 let version = '';
138 try {
139 let rootPath = absolutePaths.findEtherpadRoot();
140 if (fs.lstatSync(`${rootPath}/.git`).isFile()) {
141 rootPath = fs.readFileSync(`${rootPath}/.git`, 'utf8');
142 rootPath = rootPath.split(' ').pop()?.trim() ?? '';
143 } else {
144 rootPath += '/.git';
145 }
146 const ref = fs.readFileSync(`${rootPath}/HEAD`, 'utf-8');
147 if (ref.startsWith('ref: ')) {
148 const refPath = `${rootPath}/${ref.substring(5, ref.indexOf('\n'))}`;
149 version = fs.readFileSync(refPath, 'utf-8');
150 } else {
151 version = ref;
152 }
153 version = version.substring(0, 7);
154 } catch (e: any) {
155 logger.warn(`Can't get git version for server header\n${e.message}`);
156 }
157 return version;
158};
159
160export type SettingsType = {
161 root: string,

Callers 3

express.tsFile · 0.90
adminsettings.tsFile · 0.90
Settings.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected