aboutsummaryrefslogtreecommitdiffstats
path: root/tests/benchmarker/benchmarker.cpp
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2017-01-02 16:28:24 +0100
committerJoerg Bornemann <joerg.bornemann@qt.io>2017-01-02 16:38:40 +0000
commit549a796fdc5d959be294b28b81d721a48fe4ae5d (patch)
treea11f97288d411d03ec5705d53bf5b89803024ace /tests/benchmarker/benchmarker.cpp
parent16a08516371356b5105413243f6fa0a5d7ea1ef1 (diff)
Fix restoration of symbolic commits
qbs-benchmarker tries to restore the original commit of the qbs repository. To determine that commit the command git describe HEAD is used. For the 1.7 branch this produces something like v1.7.0-26-g2bc9373 which then is passed to 'git checkout'. Afterwards the repo is in detached HEAD state. Use 'git symbolic-ref' to determine the correct original branch name. Fall back to the old method if that doesn't work. Change-Id: I21526db1efceebcf5102eed9da43478871880ab1 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'tests/benchmarker/benchmarker.cpp')
-rw-r--r--tests/benchmarker/benchmarker.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/tests/benchmarker/benchmarker.cpp b/tests/benchmarker/benchmarker.cpp
index 69faa780c..becf60dec 100644
--- a/tests/benchmarker/benchmarker.cpp
+++ b/tests/benchmarker/benchmarker.cpp
@@ -96,7 +96,18 @@ void Benchmarker::benchmark()
void Benchmarker::rememberCurrentRepoState()
{
QByteArray commit;
- runProcess(QStringList() << "git" << "describe" << "HEAD", m_qbsRepo, &commit);
+ int exitCode = 0;
+ try {
+ runProcess(QStringList() << "git" << "symbolic-ref" << "--short" << "HEAD", m_qbsRepo,
+ &commit, &exitCode);
+ } catch (const Exception &) {
+ if (exitCode == 0) {
+ // runProcess did not throw because of the exit code.
+ throw;
+ }
+ // Fallback, in case git cannot retrieve a nice symbolic name.
+ runProcess(QStringList() << "git" << "describe" << "HEAD", m_qbsRepo, &commit);
+ }
m_commitToRestore = QString::fromLatin1(commit);
}