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