Show hash and branch name of Git repo in About dialog
This commit is contained in:
parent
a4f2a44dd2
commit
4889495184
|
@ -1028,12 +1028,18 @@ void Application::initConfig(int argc, char ** argv)
|
||||||
// only for 'BuildVersionMajor'.
|
// only for 'BuildVersionMajor'.
|
||||||
if (App::Application::Config().find("BuildVersionMajor") == App::Application::Config().end()) {
|
if (App::Application::Config().find("BuildVersionMajor") == App::Application::Config().end()) {
|
||||||
std::stringstream str; str << FCVersionMajor << "." << FCVersionMinor;
|
std::stringstream str; str << FCVersionMajor << "." << FCVersionMinor;
|
||||||
App::Application::Config()["ExeVersion"] = str.str();
|
App::Application::Config()["ExeVersion" ] = str.str();
|
||||||
App::Application::Config()["BuildVersionMajor"] = FCVersionMajor;
|
App::Application::Config()["BuildVersionMajor" ] = FCVersionMajor;
|
||||||
App::Application::Config()["BuildVersionMinor"] = FCVersionMinor;
|
App::Application::Config()["BuildVersionMinor" ] = FCVersionMinor;
|
||||||
App::Application::Config()["BuildRevision"] = FCRevision;
|
App::Application::Config()["BuildRevision" ] = FCRevision;
|
||||||
App::Application::Config()["BuildRepositoryURL"] = FCRepositoryURL;
|
App::Application::Config()["BuildRepositoryURL" ] = FCRepositoryURL;
|
||||||
App::Application::Config()["BuildRevisionDate"] = FCCurrentDateT;
|
App::Application::Config()["BuildRevisionDate" ] = FCRevisionDate;
|
||||||
|
#if defined(FCRepositoryHash)
|
||||||
|
App::Application::Config()["BuildRevisionHash" ] = FCRepositoryHash;
|
||||||
|
#endif
|
||||||
|
#if defined(FCRepositoryBranch)
|
||||||
|
App::Application::Config()["BuildRevisionBranch"] = FCRepositoryBranch;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
_argc = argc;
|
_argc = argc;
|
||||||
|
|
|
@ -1,18 +1,10 @@
|
||||||
|
|
||||||
/// Version Number
|
// Version Number
|
||||||
#define FCVersionMajor "0"
|
#define FCVersionMajor "0"
|
||||||
#define FCVersionMinor "13"
|
#define FCVersionMinor "13"
|
||||||
#define FCVersionName "Vulcan"
|
#define FCVersionName "Vulcan"
|
||||||
|
|
||||||
#define FCRevision "$WCREV$" //Highest committed revision number
|
#define FCRevision "$WCREV$" //Highest committed revision number
|
||||||
#define FCRevisionDate "$WCDATE$" //Date of highest committed revision
|
#define FCRevisionDate "$WCDATE$" //Date of highest committed revision
|
||||||
#define FCRevisionRange "$WCRANGE$" //Update revision range
|
|
||||||
#define FCRepositoryURL "$WCURL$" //Repository URL of the working copy
|
#define FCRepositoryURL "$WCURL$" //Repository URL of the working copy
|
||||||
#define FCCurrentDateT "$WCNOW$" //Current system date & time
|
|
||||||
|
|
||||||
//Placeholders of the form "$WCxxx?TrueText:FalseText$" are replaced with
|
|
||||||
//TrueText if the tested condition is true, and FalseText if false.
|
|
||||||
|
|
||||||
#define FCScrClean "$WCMODS?Src modified:Src not modified$" //True if local modifications found
|
|
||||||
#define FCScrMixed "$WCMIXED?Src mixed:Src not mixed$" //True if mixed update revisions found
|
|
||||||
|
|
||||||
|
|
|
@ -16,13 +16,17 @@
|
||||||
<property name="modal">
|
<property name="modal">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<property name="margin">
|
<item row="0" column="0" colspan="3">
|
||||||
<number>9</number>
|
<widget class="QLabel" name="labelSplashPicture">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="spacing">
|
<property name="alignment">
|
||||||
<number>6</number>
|
<set>Qt::AlignCenter</set>
|
||||||
</property>
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<spacer>
|
<spacer>
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -36,15 +40,18 @@
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0" colspan="3">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="labelSplashPicture">
|
<spacer>
|
||||||
<property name="text">
|
<property name="orientation">
|
||||||
<string/>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="sizeHint" stdset="0">
|
||||||
<set>Qt::AlignCenter</set>
|
<size>
|
||||||
|
<width>31</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<layout class="QVBoxLayout">
|
<layout class="QVBoxLayout">
|
||||||
|
@ -161,6 +168,34 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="5" column="0">
|
||||||
|
<widget class="QLabel" name="labelBranch">
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">Branch</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="1">
|
||||||
|
<widget class="QLabel" name="labelBuildBranch">
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true"><html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg 2; font-size:7.8pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><span style=" font-weight:600;">Unknown</span></p></body></html></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="1">
|
||||||
|
<widget class="QLabel" name="labelBuildHash">
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true"><html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg 2; font-size:7.8pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><span style=" font-weight:600;">Unknown</span></p></body></html></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="0">
|
||||||
|
<widget class="QLabel" name="labelHash">
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">Hash</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -178,19 +213,6 @@
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
|
||||||
<spacer>
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>31</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="1">
|
<item row="3" column="1">
|
||||||
<spacer>
|
<spacer>
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -219,6 +241,13 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="copyButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Copy to clipboard</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer>
|
<spacer>
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -239,19 +268,6 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<spacer>
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>181</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -264,7 +280,7 @@
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="Icons/resource.qrc"/>
|
<include location="../../../FreeCAD/src/Gui/Icons/resource.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
|
|
|
@ -248,18 +248,18 @@ static QString getPlatform()
|
||||||
|
|
||||||
void AboutDialog::setupLabels()
|
void AboutDialog::setupLabels()
|
||||||
{
|
{
|
||||||
QString exeName = QString::fromAscii(App::Application::Config()["ExeName"].c_str());
|
std::map<std::string, std::string>& config = App::Application::Config();
|
||||||
std::map<std::string,std::string>& cfg = App::Application::Config();
|
QString exeName = QString::fromAscii(config["ExeName"].c_str());
|
||||||
std::map<std::string,std::string>::iterator it = cfg.find("WindowTitle");
|
std::map<std::string,std::string>::iterator it = config.find("WindowTitle");
|
||||||
if (it != cfg.end())
|
if (it != config.end())
|
||||||
exeName = QString::fromUtf8(it->second.c_str());
|
exeName = QString::fromUtf8(it->second.c_str());
|
||||||
QString banner = QString::fromUtf8(App::Application::Config()["ConsoleBanner"].c_str());
|
QString banner = QString::fromUtf8(config["ConsoleBanner"].c_str());
|
||||||
banner = banner.left( banner.indexOf(QLatin1Char('\n')) );
|
banner = banner.left( banner.indexOf(QLatin1Char('\n')) );
|
||||||
QString major = QString::fromAscii(App::Application::Config()["BuildVersionMajor"].c_str());
|
QString major = QString::fromAscii(config["BuildVersionMajor"].c_str());
|
||||||
QString minor = QString::fromAscii(App::Application::Config()["BuildVersionMinor"].c_str());
|
QString minor = QString::fromAscii(config["BuildVersionMinor"].c_str());
|
||||||
QString build = QString::fromAscii(App::Application::Config()["BuildRevision"].c_str());
|
QString build = QString::fromAscii(config["BuildRevision"].c_str());
|
||||||
QString disda = QString::fromAscii(App::Application::Config()["BuildRevisionDate"].c_str());
|
QString disda = QString::fromAscii(config["BuildRevisionDate"].c_str());
|
||||||
QString mturl = QString::fromAscii(App::Application::Config()["MaintainerUrl"].c_str());
|
QString mturl = QString::fromAscii(config["MaintainerUrl"].c_str());
|
||||||
|
|
||||||
QString author = ui->labelAuthor->text();
|
QString author = ui->labelAuthor->text();
|
||||||
author.replace(QString::fromAscii("Unknown Application"), exeName);
|
author.replace(QString::fromAscii("Unknown Application"), exeName);
|
||||||
|
@ -283,10 +283,38 @@ void AboutDialog::setupLabels()
|
||||||
platform.replace(QString::fromAscii("Unknown"),
|
platform.replace(QString::fromAscii("Unknown"),
|
||||||
QString::fromAscii("%1 (%2-bit)").arg(getPlatform()).arg(QSysInfo::WordSize));
|
QString::fromAscii("%1 (%2-bit)").arg(getPlatform()).arg(QSysInfo::WordSize));
|
||||||
ui->labelBuildPlatform->setText(platform);
|
ui->labelBuildPlatform->setText(platform);
|
||||||
|
|
||||||
|
// branch name
|
||||||
|
it = config.find("BuildRevisionBranch");
|
||||||
|
if (it != config.end()) {
|
||||||
|
QString branch = ui->labelBuildBranch->text();
|
||||||
|
branch.replace(QString::fromAscii("Unknown"), QString::fromAscii(it->second.c_str()));
|
||||||
|
ui->labelBuildBranch->setText(branch);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ui->labelBranch->hide();
|
||||||
|
ui->labelBuildBranch->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
// hash id
|
||||||
|
it = config.find("BuildRevisionHash");
|
||||||
|
if (it != config.end()) {
|
||||||
|
QString hash = ui->labelBuildHash->text();
|
||||||
|
hash.replace(QString::fromAscii("Unknown"), QString::fromAscii(it->second.c_str()));
|
||||||
|
ui->labelBuildHash->setText(hash);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ui->labelHash->hide();
|
||||||
|
ui->labelBuildHash->hide();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AboutDialog::on_licenseButton_clicked()
|
void AboutDialog::on_licenseButton_clicked()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AboutDialog::on_copyButton_clicked()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
#include "moc_Splashscreen.cpp"
|
#include "moc_Splashscreen.cpp"
|
||||||
|
|
|
@ -85,6 +85,7 @@ protected:
|
||||||
|
|
||||||
protected Q_SLOTS:
|
protected Q_SLOTS:
|
||||||
virtual void on_licenseButton_clicked();
|
virtual void on_licenseButton_clicked();
|
||||||
|
virtual void on_copyButton_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui_AboutApplication* ui;
|
Ui_AboutApplication* ui;
|
||||||
|
|
|
@ -50,11 +50,7 @@ class VersionControl:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.rev = ""
|
self.rev = ""
|
||||||
self.date = ""
|
self.date = ""
|
||||||
self.range = ""
|
|
||||||
self.url = ""
|
self.url = ""
|
||||||
self.time = ""
|
|
||||||
self.mods = "Src not modified"
|
|
||||||
self.mixed = "Src not mixed"
|
|
||||||
|
|
||||||
def extractInfo(self, srcdir):
|
def extractInfo(self, srcdir):
|
||||||
return False
|
return False
|
||||||
|
@ -67,11 +63,7 @@ class VersionControl:
|
||||||
for line in lines:
|
for line in lines:
|
||||||
line = string.replace(line,'$WCREV$',self.rev)
|
line = string.replace(line,'$WCREV$',self.rev)
|
||||||
line = string.replace(line,'$WCDATE$',self.date)
|
line = string.replace(line,'$WCDATE$',self.date)
|
||||||
line = string.replace(line,'$WCRANGE$',self.range)
|
|
||||||
line = string.replace(line,'$WCURL$',self.url)
|
line = string.replace(line,'$WCURL$',self.url)
|
||||||
line = string.replace(line,'$WCNOW$',self.time)
|
|
||||||
line = string.replace(line,'$WCMODS?Src modified:Src not modified$',self.mods)
|
|
||||||
line = string.replace(line,'$WCMIXED?Src mixed:Src not mixed$',self.mixed)
|
|
||||||
content.append(line)
|
content.append(line)
|
||||||
return content
|
return content
|
||||||
|
|
||||||
|
@ -82,9 +74,7 @@ class UnknownControl(VersionControl):
|
||||||
return False
|
return False
|
||||||
self.rev = "Unknown"
|
self.rev = "Unknown"
|
||||||
self.date = "Unknown"
|
self.date = "Unknown"
|
||||||
self.range = "Unknown"
|
|
||||||
self.url = "Unknown"
|
self.url = "Unknown"
|
||||||
self.time = "Unknown"
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def printInfo(self):
|
def printInfo(self):
|
||||||
|
@ -104,13 +94,10 @@ class DebianChangelog(VersionControl):
|
||||||
r=re.search("bzr(\\d+)",c)
|
r=re.search("bzr(\\d+)",c)
|
||||||
if r != None:
|
if r != None:
|
||||||
self.rev = r.groups()[0] + " (Launchpad)"
|
self.rev = r.groups()[0] + " (Launchpad)"
|
||||||
self.range = self.rev
|
|
||||||
|
|
||||||
t = time.localtime()
|
t = time.localtime()
|
||||||
self.url = "https://code.launchpad.net/~vcs-imports/freecad/trunk"
|
|
||||||
#self.time = time.asctime()
|
|
||||||
self.date = ("%d/%02d/%02d %02d:%02d:%02d") % (t.tm_year, t.tm_mon, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec)
|
self.date = ("%d/%02d/%02d %02d:%02d:%02d") % (t.tm_year, t.tm_mon, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec)
|
||||||
self.time = ("%d/%02d/%02d %02d:%02d:%02d") % (t.tm_year, t.tm_mon, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec)
|
self.url = "https://code.launchpad.net/~vcs-imports/freecad/trunk"
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def printInfo(self):
|
def printInfo(self):
|
||||||
|
@ -121,8 +108,6 @@ class BazaarControl(VersionControl):
|
||||||
info=os.popen("bzr log -l 1 %s" % (srcdir)).read()
|
info=os.popen("bzr log -l 1 %s" % (srcdir)).read()
|
||||||
if len(info) == 0:
|
if len(info) == 0:
|
||||||
return False
|
return False
|
||||||
#Get the current local date
|
|
||||||
self.time = time.strftime("%Y/%m/%d %H:%M:%S")
|
|
||||||
lines=info.split("\n")
|
lines=info.split("\n")
|
||||||
for i in lines:
|
for i in lines:
|
||||||
r = re.match("^revno: (\\d+)$", i)
|
r = re.match("^revno: (\\d+)$", i)
|
||||||
|
@ -151,7 +136,6 @@ class GitControl(VersionControl):
|
||||||
if len(info) == 0:
|
if len(info) == 0:
|
||||||
return False
|
return False
|
||||||
self.rev='%04d (Git)' % (info.count('\n'))
|
self.rev='%04d (Git)' % (info.count('\n'))
|
||||||
self.range='%04d' % (info.count('\n'))
|
|
||||||
# date/time
|
# date/time
|
||||||
info=os.popen("git log -1 --date=iso").read()
|
info=os.popen("git log -1 --date=iso").read()
|
||||||
info=info.split("\n")
|
info=info.split("\n")
|
||||||
|
@ -159,9 +143,7 @@ class GitControl(VersionControl):
|
||||||
r = re.match("^Date:\\W+(\\d+-\\d+-\\d+\\W+\\d+:\\d+:\\d+)", i)
|
r = re.match("^Date:\\W+(\\d+-\\d+-\\d+\\W+\\d+:\\d+:\\d+)", i)
|
||||||
if r != None:
|
if r != None:
|
||||||
self.date = r.groups()[0].replace('-','/')
|
self.date = r.groups()[0].replace('-','/')
|
||||||
self.time = self.date
|
|
||||||
break
|
break
|
||||||
#self.time = time.strftime("%Y/%m/%d %H:%M:%S")
|
|
||||||
self.url = "Unknown"
|
self.url = "Unknown"
|
||||||
info=os.popen("git remote -v").read()
|
info=os.popen("git remote -v").read()
|
||||||
info=info.split("\n")
|
info=info.split("\n")
|
||||||
|
@ -170,11 +152,20 @@ class GitControl(VersionControl):
|
||||||
if r != None:
|
if r != None:
|
||||||
self.url = r.groups()[0]
|
self.url = r.groups()[0]
|
||||||
break
|
break
|
||||||
|
self.hash=os.popen("git log -1 --pretty=format:%H").read()
|
||||||
|
self.branch=os.popen("git branch").read().split('\n')[0][2:]
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def printInfo(self):
|
def printInfo(self):
|
||||||
print "git"
|
print "git"
|
||||||
|
|
||||||
|
def writeVersion(self, lines):
|
||||||
|
content = VersionControl.writeVersion(self, lines)
|
||||||
|
content.append('// Git relevant stuff\n')
|
||||||
|
content.append('#define FCRepositoryHash "%s"\n' % (self.hash))
|
||||||
|
content.append('#define FCRepositoryBranch "%s"\n' % (self.branch))
|
||||||
|
return content
|
||||||
|
|
||||||
class MercurialControl(VersionControl):
|
class MercurialControl(VersionControl):
|
||||||
def extractInfo(self, srcdir):
|
def extractInfo(self, srcdir):
|
||||||
return False
|
return False
|
||||||
|
|
Loading…
Reference in New Issue
Block a user