()
| 134 | |
| 135 | // Provide git version if available |
| 136 | export 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 | |
| 160 | export type SettingsType = { |
| 161 | root: string, |
no outgoing calls
no test coverage detected