Commit 7c5a1394 authored by Waqar Ahmed's avatar Waqar Ahmed
Browse files

Display tag if we are in a tag and master when new repo

parent 49b1dc1a
......@@ -25,10 +25,37 @@ QString GitUtils::getCurrentBranchName(const QString &repo)
{
QProcess git;
git.setWorkingDirectory(repo);
QStringList args{QStringLiteral("rev-parse"), QStringLiteral("--abbrev-ref"), QStringLiteral("HEAD")};
// try: symbolic-ref --short HEAD
QStringList args{QStringLiteral("symbolic-ref"), QStringLiteral("--short"), QStringLiteral("HEAD")};
git.start(QStringLiteral("git"), args);
if (git.waitForStarted() && git.waitForFinished(-1)) {
return QString::fromUtf8(git.readAllStandardOutput().trimmed());
if (git.exitStatus() == QProcess::NormalExit && git.exitCode() == 0) {
return QString::fromUtf8(git.readAllStandardOutput().trimmed());
}
// failed
// maybe we are in a tag?
// try: git describe --exact-match HEAD
args = QStringList{QStringLiteral("describe"), QStringLiteral("--exact-match"), QStringLiteral("HEAD")};
git.start(QStringLiteral("git"), args);
if (git.waitForStarted() && git.waitForFinished(-1)) {
if (git.exitStatus() == QProcess::NormalExit && git.exitCode() == 0) {
return QString::fromUtf8(git.readAllStandardOutput().trimmed());
}
}
// failed, just return short commit
// git rev-parse --short HEAD
args = QStringList{QStringLiteral("rev-parse"), QStringLiteral("--short"), QStringLiteral("HEAD")};
git.start(QStringLiteral("git"), args);
if (git.waitForStarted() && git.waitForFinished(-1)) {
if (git.exitStatus() == QProcess::NormalExit && git.exitCode() == 0) {
return QString::fromUtf8(git.readAllStandardOutput().trimmed());
}
}
// give up
}
return QString();
}
......
......@@ -42,7 +42,6 @@ KateProjectView::KateProjectView(KateProjectPluginView *pluginView, KateProject
layout->setSpacing(0);
layout->setContentsMargins(0, 0, 0, 0);
layout->addLayout(btnLayout);
layout->addWidget(m_gitBtn);
layout->addWidget(m_stackWidget);
// layout->addWidget(m_treeView);
layout->addWidget(m_filter);
......
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