forked from qt-creator/qt-creator
Git: InstantBlame: Adjust to common terminology
We use "subject", "hash", and "date" in other places, like the colors. Change-Id: Ia34b1b7762931b31126554c7568e1e67301462fb Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
committed by
André Hartmann
parent
740483cd8b
commit
8a119f7f09
@@ -45,9 +45,9 @@ BlameMark::BlameMark(const FilePath &fileName, int lineNumber, const CommitInfo
|
|||||||
{Tr::tr("Git Blame"), Constants::TEXT_MARK_CATEGORY_BLAME})
|
{Tr::tr("Git Blame"), Constants::TEXT_MARK_CATEGORY_BLAME})
|
||||||
, m_info(info)
|
, m_info(info)
|
||||||
{
|
{
|
||||||
QString text = info.shortAuthor + " " + info.authorTime.toString("yyyy-MM-dd");
|
QString text = info.shortAuthor + " " + info.authorDate.toString("yyyy-MM-dd");
|
||||||
if (settings().instantBlameShowSubject())
|
if (settings().instantBlameShowSubject())
|
||||||
text += " • " + info.summary;
|
text += " • " + info.subject;
|
||||||
|
|
||||||
setPriority(TextEditor::TextMark::LowPriority);
|
setPriority(TextEditor::TextMark::LowPriority);
|
||||||
setToolTip(toolTipText(info));
|
setToolTip(toolTipText(info));
|
||||||
@@ -58,7 +58,7 @@ BlameMark::BlameMark(const FilePath &fileName, int lineNumber, const CommitInfo
|
|||||||
copyToClipboardAction->setIcon(QIcon::fromTheme("edit-copy", Utils::Icons::COPY.icon()));
|
copyToClipboardAction->setIcon(QIcon::fromTheme("edit-copy", Utils::Icons::COPY.icon()));
|
||||||
copyToClipboardAction->setToolTip(TextEditor::Tr::tr("Copy SHA1 to Clipboard"));
|
copyToClipboardAction->setToolTip(TextEditor::Tr::tr("Copy SHA1 to Clipboard"));
|
||||||
QObject::connect(copyToClipboardAction, &QAction::triggered, [info] {
|
QObject::connect(copyToClipboardAction, &QAction::triggered, [info] {
|
||||||
Utils::setClipboardAndSelection(info.sha1);
|
Utils::setClipboardAndSelection(info.hash);
|
||||||
});
|
});
|
||||||
return QList<QAction *>{copyToClipboardAction};
|
return QList<QAction *>{copyToClipboardAction};
|
||||||
});
|
});
|
||||||
@@ -71,7 +71,7 @@ bool BlameMark::addToolTipContent(QLayout *target) const
|
|||||||
target->addWidget(textLabel);
|
target->addWidget(textLabel);
|
||||||
QObject::connect(textLabel, &QLabel::linkActivated, textLabel, [this](const QString &link) {
|
QObject::connect(textLabel, &QLabel::linkActivated, textLabel, [this](const QString &link) {
|
||||||
qCInfo(log) << "Link activated with target:" << link;
|
qCInfo(log) << "Link activated with target:" << link;
|
||||||
const QString sha1 = (link == "blameParent") ? m_info.sha1 + "^" : m_info.sha1;
|
const QString hash = (link == "blameParent") ? m_info.hash + "^" : m_info.hash;
|
||||||
|
|
||||||
if (link.startsWith("blame") || link == "showFile") {
|
if (link.startsWith("blame") || link == "showFile") {
|
||||||
const VcsBasePluginState state = currentState();
|
const VcsBasePluginState state = currentState();
|
||||||
@@ -81,14 +81,14 @@ bool BlameMark::addToolTipContent(QLayout *target) const
|
|||||||
const QString originalFileName = m_info.originalFileName;
|
const QString originalFileName = m_info.originalFileName;
|
||||||
if (link.startsWith("blame")) {
|
if (link.startsWith("blame")) {
|
||||||
qCInfo(log).nospace().noquote() << "Blaming: \"" << path << "/" << originalFileName
|
qCInfo(log).nospace().noquote() << "Blaming: \"" << path << "/" << originalFileName
|
||||||
<< "\":" << m_info.originalLine << " @ " << sha1;
|
<< "\":" << m_info.originalLine << " @ " << hash;
|
||||||
gitClient().annotate(path, originalFileName, m_info.originalLine, sha1);
|
gitClient().annotate(path, originalFileName, m_info.originalLine, hash);
|
||||||
} else {
|
} else {
|
||||||
qCInfo(log).nospace().noquote() << "Showing file: \"" << path << "/"
|
qCInfo(log).nospace().noquote() << "Showing file: \"" << path << "/"
|
||||||
<< originalFileName << "\" @ " << sha1;
|
<< originalFileName << "\" @ " << hash;
|
||||||
|
|
||||||
const auto fileName = Utils::FilePath::fromString(originalFileName);
|
const auto fileName = Utils::FilePath::fromString(originalFileName);
|
||||||
gitClient().openShowEditor(path, sha1, fileName);
|
gitClient().openShowEditor(path, hash, fileName);
|
||||||
}
|
}
|
||||||
} else if (link == "logLine") {
|
} else if (link == "logLine") {
|
||||||
const VcsBasePluginState state = currentState();
|
const VcsBasePluginState state = currentState();
|
||||||
@@ -101,8 +101,8 @@ bool BlameMark::addToolTipContent(QLayout *target) const
|
|||||||
.arg(m_info.line).arg(state.relativeCurrentFile());
|
.arg(m_info.line).arg(state.relativeCurrentFile());
|
||||||
gitClient().log(state.currentFileTopLevel(), {}, true, {lineArg, "--no-patch"});
|
gitClient().log(state.currentFileTopLevel(), {}, true, {lineArg, "--no-patch"});
|
||||||
} else {
|
} else {
|
||||||
qCInfo(log).nospace().noquote() << "Showing commit: " << sha1 << " for " << m_info.filePath;
|
qCInfo(log).nospace().noquote() << "Showing commit: " << hash << " for " << m_info.filePath;
|
||||||
gitClient().show(m_info.filePath, sha1);
|
gitClient().show(m_info.filePath, hash);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -127,10 +127,10 @@ QString BlameMark::toolTipText(const CommitInfo &info) const
|
|||||||
" <tr><td>Date:</td><td style=\"color: %8;\">%9</td></tr>"
|
" <tr><td>Date:</td><td style=\"color: %8;\">%9</td></tr>"
|
||||||
"</table>"
|
"</table>"
|
||||||
"<p style=\"color: %10;\">%11</p>")
|
"<p style=\"color: %10;\">%11</p>")
|
||||||
.arg(colors.hash, info.sha1.left(8), info.sha1, QString::number(info.line),
|
.arg(colors.hash, info.hash.left(8), info.hash, QString::number(info.line),
|
||||||
colors.author, info.author, info.authorMail,
|
colors.author, info.author, info.authorMail,
|
||||||
colors.date, info.authorTime.toString("yyyy-MM-dd hh:mm:ss"),
|
colors.date, info.authorDate.toString("yyyy-MM-dd hh:mm:ss"),
|
||||||
colors.subject, info.summary);
|
colors.subject, info.subject);
|
||||||
|
|
||||||
if (settings().instantBlameIgnoreSpaceChanges()
|
if (settings().instantBlameIgnoreSpaceChanges()
|
||||||
|| settings().instantBlameIgnoreLineMoves()) {
|
|| settings().instantBlameIgnoreLineMoves()) {
|
||||||
@@ -248,7 +248,7 @@ static CommitInfo parseBlameOutput(const QStringList &blame, const Utils::FilePa
|
|||||||
return result;
|
return result;
|
||||||
|
|
||||||
const QStringList firstLineParts = blame.at(0).split(" ");
|
const QStringList firstLineParts = blame.at(0).split(" ");
|
||||||
result.sha1 = firstLineParts.first();
|
result.hash = firstLineParts.first();
|
||||||
result.author = blame.at(1).mid(7);
|
result.author = blame.at(1).mid(7);
|
||||||
result.authorMail = blame.at(2).mid(13).chopped(1);
|
result.authorMail = blame.at(2).mid(13).chopped(1);
|
||||||
if (result.author == author.name || result.authorMail == author.email)
|
if (result.author == author.name || result.authorMail == author.email)
|
||||||
@@ -256,8 +256,8 @@ static CommitInfo parseBlameOutput(const QStringList &blame, const Utils::FilePa
|
|||||||
else
|
else
|
||||||
result.shortAuthor = result.author;
|
result.shortAuthor = result.author;
|
||||||
const uint timeStamp = blame.at(3).mid(12).toUInt();
|
const uint timeStamp = blame.at(3).mid(12).toUInt();
|
||||||
result.authorTime = QDateTime::fromSecsSinceEpoch(timeStamp);
|
result.authorDate = QDateTime::fromSecsSinceEpoch(timeStamp);
|
||||||
result.summary = blame.at(9).mid(8);
|
result.subject = blame.at(9).mid(8);
|
||||||
result.filePath = filePath;
|
result.filePath = filePath;
|
||||||
// blame.at(10) can be "boundary", "previous" or "filename"
|
// blame.at(10) can be "boundary", "previous" or "filename"
|
||||||
if (blame.at(10).startsWith("filename"))
|
if (blame.at(10).startsWith("filename"))
|
||||||
|
@@ -19,12 +19,12 @@ namespace Git::Internal {
|
|||||||
|
|
||||||
class CommitInfo {
|
class CommitInfo {
|
||||||
public:
|
public:
|
||||||
QString sha1;
|
QString hash;
|
||||||
QString shortAuthor;
|
QString shortAuthor;
|
||||||
QString author;
|
QString author;
|
||||||
QString authorMail;
|
QString authorMail;
|
||||||
QDateTime authorTime;
|
QDateTime authorDate;
|
||||||
QString summary;
|
QString subject;
|
||||||
Utils::FilePath filePath; ///< absolute file path for current file
|
Utils::FilePath filePath; ///< absolute file path for current file
|
||||||
QString originalFileName; ///< relative file path from project root for the original file
|
QString originalFileName; ///< relative file path from project root for the original file
|
||||||
int line = -1; ///< current line number in current file
|
int line = -1; ///< current line number in current file
|
||||||
|
Reference in New Issue
Block a user