show last commit hash alongside server version in footer
This commit is contained in:
parent
26b4151762
commit
abb2c7927c
|
@ -29,7 +29,7 @@
|
|||
</div>
|
||||
|
||||
<footer class="row">
|
||||
<a href="https://joinpeertube.org" title="PeerTube website" target="_blank" rel="noopener noreferrer">PeerTube v{{ serverVersion }}</a> -
|
||||
<a href="https://joinpeertube.org" title="PeerTube website" target="_blank" rel="noopener noreferrer">PeerTube v{{ serverVersion }}{{ serverCommit }}</a> -
|
||||
<a href="https://github.com/Chocobozzz/PeerTube/blob/develop/LICENSE" title="PeerTube license" target="_blank" rel="noopener noreferrer">CopyLeft 2015-2018</a>
|
||||
</footer>
|
||||
</div>
|
||||
|
|
|
@ -45,6 +45,11 @@ export class AppComponent implements OnInit {
|
|||
return this.serverService.getConfig().serverVersion
|
||||
}
|
||||
|
||||
get serverCommit () {
|
||||
const commit = this.serverService.getConfig().serverCommit || ''
|
||||
return (commit !== '') ? '...' + commit : commit
|
||||
}
|
||||
|
||||
get instanceName () {
|
||||
return this.serverService.getConfig().instance.name
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import { customConfigUpdateValidator } from '../../middlewares/validators/config
|
|||
import { ClientHtml } from '../../lib/client-html'
|
||||
import { auditLoggerFactory, CustomConfigAuditView, getAuditIdFromRes } from '../../helpers/audit-logger'
|
||||
import { remove, writeJSON } from 'fs-extra'
|
||||
import { version } from '../../tools/cli'
|
||||
|
||||
const packageJSON = require('../../../../package.json')
|
||||
const configRouter = express.Router()
|
||||
|
@ -38,9 +39,12 @@ configRouter.delete('/custom',
|
|||
asyncMiddleware(deleteCustomConfig)
|
||||
)
|
||||
|
||||
let serverCommit: string
|
||||
async function getConfig (req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||
const allowed = await isSignupAllowed()
|
||||
const allowedForCurrentIP = isSignupAllowedForCurrentIP(req.ip)
|
||||
serverCommit = (serverCommit) ? serverCommit : version()
|
||||
if (serverCommit === packageJSON.version) serverCommit = ''
|
||||
|
||||
const enabledResolutions = Object.keys(CONFIG.TRANSCODING.RESOLUTIONS)
|
||||
.filter(key => CONFIG.TRANSCODING.ENABLED === CONFIG.TRANSCODING.RESOLUTIONS[key] === true)
|
||||
|
@ -58,6 +62,7 @@ async function getConfig (req: express.Request, res: express.Response, next: exp
|
|||
}
|
||||
},
|
||||
serverVersion: packageJSON.version,
|
||||
serverCommit,
|
||||
signup: {
|
||||
allowed,
|
||||
allowedForCurrentIP,
|
||||
|
|
|
@ -54,6 +54,18 @@ function getSecureTorrentName (originalName: string) {
|
|||
return sha256(originalName) + '.torrent'
|
||||
}
|
||||
|
||||
function getVersion () {
|
||||
const tag = require('child_process')
|
||||
.execSync('[[ ! -d .git ]] || git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null || true', { stdio: [0,1,2] })
|
||||
if (tag) return tag.replace(/^v/, '')
|
||||
|
||||
const version = require('child_process')
|
||||
.execSync('[[ ! -d .git ]] || git rev-parse --short HEAD').toString().trim()
|
||||
if (version) return version
|
||||
|
||||
return require('../../../package.json').version
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export {
|
||||
|
@ -62,5 +74,6 @@ export {
|
|||
getFormattedObjects,
|
||||
getSecureTorrentName,
|
||||
getServerActor,
|
||||
getVersion,
|
||||
generateVideoTmpPath
|
||||
}
|
||||
|
|
|
@ -1,17 +1,8 @@
|
|||
const config = require('application-config')('PeerTube/CLI')
|
||||
const netrc = require('netrc-parser').default
|
||||
import { getVersion } from '../helpers/utils'
|
||||
|
||||
const version = () => {
|
||||
const tag = require('child_process')
|
||||
.execSync('[[ ! -d .git ]] || git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null || true', { stdio: [0,1,2] })
|
||||
if (tag) return tag
|
||||
|
||||
const version = require('child_process')
|
||||
.execSync('[[ ! -d .git ]] || git rev-parse --short HEAD').toString().trim()
|
||||
if (version) return version
|
||||
|
||||
return require('../../../package.json').version
|
||||
}
|
||||
const version = getVersion
|
||||
|
||||
let settings = {
|
||||
remotes: [],
|
||||
|
|
|
@ -2,6 +2,7 @@ import { NSFWPolicyType } from '../videos/nsfw-policy.type'
|
|||
|
||||
export interface ServerConfig {
|
||||
serverVersion: string
|
||||
serverCommit?: string
|
||||
|
||||
instance: {
|
||||
name: string
|
||||
|
|
Loading…
Reference in New Issue