diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2018-09-29 19:53:49 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-10-01 14:31:01 +0200 |
commit | abb2c7927ca1640a755e0ec32c51bcc9c873b34c (patch) | |
tree | 4ded5e7559d48d450f861f5ec5c0a1a794cc2e15 | |
parent | 26b415176212b44ff6ce168cb00aeb93b10c0cb3 (diff) | |
download | PeerTube-abb2c7927ca1640a755e0ec32c51bcc9c873b34c.tar.gz PeerTube-abb2c7927ca1640a755e0ec32c51bcc9c873b34c.tar.zst PeerTube-abb2c7927ca1640a755e0ec32c51bcc9c873b34c.zip |
show last commit hash alongside server version in footer
-rw-r--r-- | client/src/app/app.component.html | 2 | ||||
-rw-r--r-- | client/src/app/app.component.ts | 5 | ||||
-rw-r--r-- | server/controllers/api/config.ts | 5 | ||||
-rw-r--r-- | server/helpers/utils.ts | 13 | ||||
-rw-r--r-- | server/tools/cli.ts | 13 | ||||
-rw-r--r-- | shared/models/server/server-config.model.ts | 1 |
6 files changed, 27 insertions, 12 deletions
diff --git a/client/src/app/app.component.html b/client/src/app/app.component.html index 958c131f7..03f7e88ed 100644 --- a/client/src/app/app.component.html +++ b/client/src/app/app.component.html | |||
@@ -29,7 +29,7 @@ | |||
29 | </div> | 29 | </div> |
30 | 30 | ||
31 | <footer class="row"> | 31 | <footer class="row"> |
32 | <a href="https://joinpeertube.org" title="PeerTube website" target="_blank" rel="noopener noreferrer">PeerTube v{{ serverVersion }}</a> - | 32 | <a href="https://joinpeertube.org" title="PeerTube website" target="_blank" rel="noopener noreferrer">PeerTube v{{ serverVersion }}{{ serverCommit }}</a> - |
33 | <a href="https://github.com/Chocobozzz/PeerTube/blob/develop/LICENSE" title="PeerTube license" target="_blank" rel="noopener noreferrer">CopyLeft 2015-2018</a> | 33 | <a href="https://github.com/Chocobozzz/PeerTube/blob/develop/LICENSE" title="PeerTube license" target="_blank" rel="noopener noreferrer">CopyLeft 2015-2018</a> |
34 | </footer> | 34 | </footer> |
35 | </div> | 35 | </div> |
diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts index 907bc583b..29b02032f 100644 --- a/client/src/app/app.component.ts +++ b/client/src/app/app.component.ts | |||
@@ -45,6 +45,11 @@ export class AppComponent implements OnInit { | |||
45 | return this.serverService.getConfig().serverVersion | 45 | return this.serverService.getConfig().serverVersion |
46 | } | 46 | } |
47 | 47 | ||
48 | get serverCommit () { | ||
49 | const commit = this.serverService.getConfig().serverCommit || '' | ||
50 | return (commit !== '') ? '...' + commit : commit | ||
51 | } | ||
52 | |||
48 | get instanceName () { | 53 | get instanceName () { |
49 | return this.serverService.getConfig().instance.name | 54 | return this.serverService.getConfig().instance.name |
50 | } | 55 | } |
diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts index 95549b724..633cf5e34 100644 --- a/server/controllers/api/config.ts +++ b/server/controllers/api/config.ts | |||
@@ -10,6 +10,7 @@ import { customConfigUpdateValidator } from '../../middlewares/validators/config | |||
10 | import { ClientHtml } from '../../lib/client-html' | 10 | import { ClientHtml } from '../../lib/client-html' |
11 | import { auditLoggerFactory, CustomConfigAuditView, getAuditIdFromRes } from '../../helpers/audit-logger' | 11 | import { auditLoggerFactory, CustomConfigAuditView, getAuditIdFromRes } from '../../helpers/audit-logger' |
12 | import { remove, writeJSON } from 'fs-extra' | 12 | import { remove, writeJSON } from 'fs-extra' |
13 | import { version } from '../../tools/cli' | ||
13 | 14 | ||
14 | const packageJSON = require('../../../../package.json') | 15 | const packageJSON = require('../../../../package.json') |
15 | const configRouter = express.Router() | 16 | const configRouter = express.Router() |
@@ -38,9 +39,12 @@ configRouter.delete('/custom', | |||
38 | asyncMiddleware(deleteCustomConfig) | 39 | asyncMiddleware(deleteCustomConfig) |
39 | ) | 40 | ) |
40 | 41 | ||
42 | let serverCommit: string | ||
41 | async function getConfig (req: express.Request, res: express.Response, next: express.NextFunction) { | 43 | async function getConfig (req: express.Request, res: express.Response, next: express.NextFunction) { |
42 | const allowed = await isSignupAllowed() | 44 | const allowed = await isSignupAllowed() |
43 | const allowedForCurrentIP = isSignupAllowedForCurrentIP(req.ip) | 45 | const allowedForCurrentIP = isSignupAllowedForCurrentIP(req.ip) |
46 | serverCommit = (serverCommit) ? serverCommit : version() | ||
47 | if (serverCommit === packageJSON.version) serverCommit = '' | ||
44 | 48 | ||
45 | const enabledResolutions = Object.keys(CONFIG.TRANSCODING.RESOLUTIONS) | 49 | const enabledResolutions = Object.keys(CONFIG.TRANSCODING.RESOLUTIONS) |
46 | .filter(key => CONFIG.TRANSCODING.ENABLED === CONFIG.TRANSCODING.RESOLUTIONS[key] === true) | 50 | .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 | |||
58 | } | 62 | } |
59 | }, | 63 | }, |
60 | serverVersion: packageJSON.version, | 64 | serverVersion: packageJSON.version, |
65 | serverCommit, | ||
61 | signup: { | 66 | signup: { |
62 | allowed, | 67 | allowed, |
63 | allowedForCurrentIP, | 68 | allowedForCurrentIP, |
diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts index a42474417..f5bf6de56 100644 --- a/server/helpers/utils.ts +++ b/server/helpers/utils.ts | |||
@@ -54,6 +54,18 @@ function getSecureTorrentName (originalName: string) { | |||
54 | return sha256(originalName) + '.torrent' | 54 | return sha256(originalName) + '.torrent' |
55 | } | 55 | } |
56 | 56 | ||
57 | function getVersion () { | ||
58 | const tag = require('child_process') | ||
59 | .execSync('[[ ! -d .git ]] || git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null || true', { stdio: [0,1,2] }) | ||
60 | if (tag) return tag.replace(/^v/, '') | ||
61 | |||
62 | const version = require('child_process') | ||
63 | .execSync('[[ ! -d .git ]] || git rev-parse --short HEAD').toString().trim() | ||
64 | if (version) return version | ||
65 | |||
66 | return require('../../../package.json').version | ||
67 | } | ||
68 | |||
57 | // --------------------------------------------------------------------------- | 69 | // --------------------------------------------------------------------------- |
58 | 70 | ||
59 | export { | 71 | export { |
@@ -62,5 +74,6 @@ export { | |||
62 | getFormattedObjects, | 74 | getFormattedObjects, |
63 | getSecureTorrentName, | 75 | getSecureTorrentName, |
64 | getServerActor, | 76 | getServerActor, |
77 | getVersion, | ||
65 | generateVideoTmpPath | 78 | generateVideoTmpPath |
66 | } | 79 | } |
diff --git a/server/tools/cli.ts b/server/tools/cli.ts index 9a170d4da..87d1512a3 100644 --- a/server/tools/cli.ts +++ b/server/tools/cli.ts | |||
@@ -1,17 +1,8 @@ | |||
1 | const config = require('application-config')('PeerTube/CLI') | 1 | const config = require('application-config')('PeerTube/CLI') |
2 | const netrc = require('netrc-parser').default | 2 | const netrc = require('netrc-parser').default |
3 | import { getVersion } from '../helpers/utils' | ||
3 | 4 | ||
4 | const version = () => { | 5 | const version = getVersion |
5 | const tag = require('child_process') | ||
6 | .execSync('[[ ! -d .git ]] || git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null || true', { stdio: [0,1,2] }) | ||
7 | if (tag) return tag | ||
8 | |||
9 | const version = require('child_process') | ||
10 | .execSync('[[ ! -d .git ]] || git rev-parse --short HEAD').toString().trim() | ||
11 | if (version) return version | ||
12 | |||
13 | return require('../../../package.json').version | ||
14 | } | ||
15 | 6 | ||
16 | let settings = { | 7 | let settings = { |
17 | remotes: [], | 8 | remotes: [], |
diff --git a/shared/models/server/server-config.model.ts b/shared/models/server/server-config.model.ts index e0ff8c07d..91196c1eb 100644 --- a/shared/models/server/server-config.model.ts +++ b/shared/models/server/server-config.model.ts | |||
@@ -2,6 +2,7 @@ import { NSFWPolicyType } from '../videos/nsfw-policy.type' | |||
2 | 2 | ||
3 | export interface ServerConfig { | 3 | export interface ServerConfig { |
4 | serverVersion: string | 4 | serverVersion: string |
5 | serverCommit?: string | ||
5 | 6 | ||
6 | instance: { | 7 | instance: { |
7 | name: string | 8 | name: string |