forked from qt-creator/qt-creator
Git: Show Precedes/Follows tags on Show editor
Known limitation: Commit that has a tag shows its own tag on Precedes field Change-Id: I533e48b4bb5d57809d8e9f12fa7db5d8706f7372 Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
7127b38a1a
commit
6a337561c5
@@ -1156,6 +1156,37 @@ QString GitClient::synchronousTopRevision(const QString &workingDirectory, QStri
|
||||
return revision;
|
||||
}
|
||||
|
||||
void GitClient::synchronousTagsForCommit(const QString &workingDirectory, const QString &revision,
|
||||
QByteArray &precedes, QByteArray &follows)
|
||||
{
|
||||
QStringList arguments;
|
||||
QByteArray parents;
|
||||
arguments << QLatin1String("describe") << QLatin1String("--contains") << revision;
|
||||
fullySynchronousGit(workingDirectory, arguments, &precedes);
|
||||
int tilde = precedes.indexOf('~');
|
||||
if (tilde != -1)
|
||||
precedes.truncate(tilde);
|
||||
else
|
||||
precedes = precedes.trimmed();
|
||||
|
||||
arguments.clear();
|
||||
arguments << QLatin1String("log") << QLatin1String("-n1") << QLatin1String("--pretty=format:%P") << revision;
|
||||
fullySynchronousGit(workingDirectory, arguments, &parents);
|
||||
foreach (const QByteArray &p, parents.split(' ')) {
|
||||
QByteArray pf;
|
||||
arguments.clear();
|
||||
arguments << QLatin1String("describe") << QLatin1String("--tags")
|
||||
<< QLatin1String("--abbrev=0") << QLatin1String(p);
|
||||
fullySynchronousGit(workingDirectory, arguments, &pf);
|
||||
pf.truncate(pf.lastIndexOf('\n'));
|
||||
if (!pf.isEmpty()) {
|
||||
if (!follows.isEmpty())
|
||||
follows += ", ";
|
||||
follows += pf;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Format an entry in a one-liner for selection list using git log.
|
||||
QString GitClient::synchronousShortDescription(const QString &workingDirectory, const QString &revision,
|
||||
const QString &format)
|
||||
|
||||
@@ -163,6 +163,8 @@ public:
|
||||
const QString &format);
|
||||
QString synchronousBranch(const QString &workingDirectory);
|
||||
QString synchronousTopRevision(const QString &workingDirectory, QString *errorMessage = 0);
|
||||
void synchronousTagsForCommit(const QString &workingDirectory, const QString &revision,
|
||||
QByteArray &precedes, QByteArray &follows);
|
||||
|
||||
bool cloneRepository(const QString &directory, const QByteArray &url);
|
||||
QString vcsGetRepositoryURL(const QString &directory);
|
||||
|
||||
@@ -207,11 +207,32 @@ static QByteArray removeAnnotationDate(const QByteArray &b)
|
||||
void GitEditor::setPlainTextDataFiltered(const QByteArray &a)
|
||||
{
|
||||
QByteArray array = a;
|
||||
GitPlugin *plugin = GitPlugin::instance();
|
||||
// If desired, filter out the date from annotation
|
||||
const bool omitAnnotationDate = contentType() == VcsBase::AnnotateOutput
|
||||
&& GitPlugin::instance()->settings().boolValue(GitSettings::omitAnnotationDateKey);
|
||||
if (omitAnnotationDate)
|
||||
array = removeAnnotationDate(a);
|
||||
switch (contentType())
|
||||
{
|
||||
case VcsBase::AnnotateOutput: {
|
||||
const bool omitAnnotationDate = plugin->settings().boolValue(GitSettings::omitAnnotationDateKey);
|
||||
if (omitAnnotationDate)
|
||||
array = removeAnnotationDate(a);
|
||||
break;
|
||||
}
|
||||
case VcsBase::DiffOutput: {
|
||||
const QFileInfo fi(source());
|
||||
const QString workingDirectory = fi.absolutePath();
|
||||
QByteArray precedes, follows;
|
||||
if (array.startsWith("commit ")) { // show
|
||||
int lastHeaderLine = array.indexOf("\n\n") + 1;
|
||||
plugin->gitClient()->synchronousTagsForCommit(workingDirectory, QLatin1String(array.mid(7, 8)), precedes, follows);
|
||||
if (!precedes.isEmpty())
|
||||
array.insert(lastHeaderLine, "Precedes: " + precedes + '\n');
|
||||
if (!follows.isEmpty())
|
||||
array.insert(lastHeaderLine, "Follows: " + follows + '\n');
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
setPlainTextData(array);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user