/***************************************************************************
- * Copyright (C) 2005-08 by the Quassel Project *
+ * Copyright (C) 2005-09 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
// try to execute git-describe to get a version string
QProcess git;
git.setWorkingDirectory(gitroot);
+ #ifdef Q_OS_WIN
+ git.start("cmd.exe", QStringList() << "/C" << "git" << "describe" << "--long");
+ #else
git.start("git", QStringList() << "describe" << "--long");
+ #endif
if(git.waitForFinished(10000)) {
QString descr = git.readAllStandardOutput().trimmed();
if(!descr.isEmpty() && !descr.contains("fatal")) {
// seems we have a valid git describe string
descrver = descr;
// check if the workdir is dirty
+ #ifdef Q_OS_WIN
+ git.start("cmd.exe", QStringList() << "/C" << "git" << "diff-index" << "--name-only" << "HEAD");
+ #else
git.start("git", QStringList() << "diff-index" << "--name-only" << "HEAD");
+ #endif
if(git.waitForFinished(10000)) {
if(!git.readAllStandardOutput().isEmpty()) dirty = "*";
}
// get a full committish
+ #ifdef Q_OS_WIN
+ git.start("cmd.exe", QStringList() << "/C" << "git" << "rev-parse" << "HEAD");
+ #else
git.start("git", QStringList() << "rev-parse" << "HEAD");
+ #endif
if(git.waitForFinished(10000)) {
committish = git.readAllStandardOutput().trimmed();
}
verfile.close();
}
- // ok, create our version.gen now
+ // generate the contents for version.gen
+ QByteArray contents = QString("QString buildinfo = \"%1,%2,%3,%4,%5,%6,%7,%8\";\n")
+ .arg(basever, descrver, dirty, committish, commitdate, protover, clientneeds, coreneeds)
+ .toAscii();
+
QFile gen(target);
- if(!gen.open(QIODevice::WriteOnly | QIODevice::Text)) {
+ if(!gen.open(QIODevice::ReadWrite | QIODevice::Text)) {
qFatal("%s", qPrintable(QString("Could not write %1!").arg(target)));
return EXIT_FAILURE;
}
- gen.write(QString("QString buildinfo = \"%1,%2,%3,%4,%5,%6,%7,%8\";\n")
- .arg(basever, descrver, dirty, committish, commitdate, protover, clientneeds, coreneeds).toAscii());
+ QByteArray oldContents = gen.readAll();
+ if(oldContents != contents) { // only touch the file if something changed
+ gen.seek(0);
+ gen.write(contents);
+ gen.waitForBytesWritten(10000);
+ }
gen.close();
+
return EXIT_SUCCESS;
}