Commit 01cf51b6 authored by Rob Swindell's avatar Rob Swindell 💬
Browse files

Expose Git repo info (branch and commit hash) in @-codes and JS vars

New @-codes: GIT_HASH and GIT_BRANCH
New JS system properties: git_hash and git_branch
parent 47d48ec1
/* Synchronet "@code" functions */
// vi: tabstop=4
/* $Id: atcodes.cpp,v 1.142 2020/05/10 20:12:35 rswindell Exp $ */
/****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) *
......@@ -16,21 +13,9 @@
* See the GNU General Public License for more details: gpl.txt or *
* http://www.fsf.org/copyleft/gpl.html *
* *
* Anonymous FTP access to the most recent released source is available at *
* ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
* *
* Anonymous CVS access to the development source and modification history *
* is available at cvs.synchro.net:/cvsroot/sbbs, example: *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login *
* (just hit return, no password is necessary) *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src *
* *
* For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html *
* *
* You are encouraged to submit any modifications (preferably in Unix diff *
* format) via e-mail to mods@synchro.net *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/
......@@ -39,6 +24,7 @@
#include "utf8.h"
#include "unicode.h"
#include "cp437defs.h"
#include "ver.h"
#if defined(_WINSOCKAPI_)
extern WSADATA WSAData;
......@@ -411,6 +397,12 @@ const char* sbbs_t::atcode(char* sp, char* str, size_t maxlen, long* pmode, bool
return(str);
}
if(strcmp(sp, "GIT_HASH") == 0)
return git_hash;
if(strcmp(sp, "GIT_BRANCH") == 0)
return git_branch;
if(!strcmp(sp,"UPTIME")) {
extern volatile time_t uptime;
time_t up=0;
......
......@@ -21,6 +21,7 @@
#include "sbbs.h"
#include "js_request.h"
#include "ver.h"
#ifdef JAVASCRIPT
......@@ -529,6 +530,8 @@ static char* sys_prop_desc[] = {
,"Synchronet version notice (includes version and platform)"
,"Synchronet version number in decimal (e.g. 31301 for v3.13b)"
,"Synchronet version number in hexadecimal (e.g. 0x31301 for v3.13b)"
,"Synchronet Git repository branch name"
,"Synchronet Git repository commit hash"
,"platform description (e.g. 'Win32', 'Linux', 'FreeBSD')"
,"architecture description (e.g. 'i386', 'i686', 'x86_64')"
,"message base library version information"
......@@ -2475,6 +2478,10 @@ static JSBool js_system_resolve(JSContext *cx, JSObject *obj, jsid id)
LAZY_INTEGER("version_num", VERSION_NUM);
LAZY_INTEGER("version_hex", VERSION_HEX);
/* Git repo details */
LAZY_STRING("git_branch", git_branch);
LAZY_STRING("git_hash", git_hash);
LAZY_STRING("platform", PLATFORM_DESC);
LAZY_STRING("architecture", ARCHITECTURE_DESC);
LAZY_STRFUNC("msgbase_lib", sprintf(str,"SMBLIB %s",smb_lib_ver()), str);
......
......@@ -1439,12 +1439,6 @@ extern char lastuseron[LEN_ALIAS+1]; /* Name of user last online */
}
#endif
extern
#ifdef __cplusplus
"C"
#endif
const char* beta_version;
/* Global data */
/* ToDo: These should be hunted down and killed */
......
/* ver.cpp */
// vi: tabstop=4
/* Synchronet version display */
/* $Id: ver.cpp,v 1.31 2019/10/08 02:07:26 rswindell Exp $ */
/* Synchronet version info */
/****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) *
......@@ -18,21 +13,9 @@
* See the GNU General Public License for more details: gpl.txt or *
* http://www.fsf.org/copyleft/gpl.html *
* *
* Anonymous FTP access to the most recent released source is available at *
* ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
* *
* Anonymous CVS access to the development source and modification history *
* is available at cvs.synchro.net:/cvsroot/sbbs, example: *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login *
* (just hit return, no password is necessary) *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src *
* *
* For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html *
* *
* You are encouraged to submit any modifications (preferably in Unix diff *
* format) via e-mail to mods@synchro.net *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/
......@@ -40,8 +23,11 @@
#include "ssl.h"
#include "git_hash.h"
#include "git_branch.h"
#include "ver.h"
const char* beta_version = " "; /* Space if non-beta, " beta" otherwise */
extern "C" const char* git_hash = GIT_HASH;
extern "C" const char* git_branch = GIT_BRANCH;
extern "C" const char* beta_version = " "; /* Space if non-beta, " beta" otherwise */
#if defined(_WINSOCKAPI_)
extern WSADATA WSAData;
......
/* Synchronet version info */
/****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* See the GNU General Public License for more details: gpl.txt or *
* http://www.fsf.org/copyleft/gpl.html *
* *
* For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/
#ifndef _VER_H_
#define _VER_H_
#ifdef __cplusplus
extern "C" {
#endif
extern const char* git_hash;
extern const char* git_branch;
extern const char* beta_version;
#ifdef __cplusplus
}
#endif
#endif /* Don't add anything after this line */
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment