Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Kate
Commits
4e6f7d9f
Commit
4e6f7d9f
authored
Feb 23, 2021
by
Kåre Särs
Browse files
Read the blame timestamp as iso8601
Display the date according to locale in "NarrowFormat"
parent
a889850c
Changes
2
Hide whitespace changes
Inline
Side-by-side
addons/git-blame/kategitblameplugin.cpp
View file @
4e6f7d9f
...
...
@@ -90,21 +90,18 @@ void GitBlameInlineNoteProvider::paintInlineNote(const KTextEditor::InlineNote &
int
lineNr
=
note
.
position
().
line
();
const
KateGitBlameInfo
&
info
=
m_plugin
->
blameInfo
(
lineNr
,
m_doc
->
line
(
lineNr
));
QString
text
=
QStringLiteral
(
" %1: %2"
).
arg
(
info
.
name
,
info
.
date
);
QString
text
=
QStringLiteral
(
" %1: %2"
).
arg
(
info
.
name
,
m_locale
.
toString
(
info
.
date
,
QLocale
::
NarrowFormat
)
);
QRect
rectangle
=
fm
.
boundingRect
(
text
);
rectangle
.
setWidth
(
rectangle
.
width
()
*
1.1
);
rectangle
.
setWidth
(
rectangle
.
width
()
*
1.
0
1
);
rectangle
.
moveTo
(
0
,
0
);
auto
editor
=
KTextEditor
::
Editor
::
instance
();
auto
color
=
QColor
::
fromRgba
(
editor
->
theme
().
textColor
(
KSyntaxHighlighting
::
Theme
::
Normal
));
color
.
setAlpha
(
0
);
painter
.
setPen
(
color
);
color
.
setAlpha
(
1
5
);
color
.
setAlpha
(
1
0
);
painter
.
setBrush
(
color
);
painter
.
drawRect
(
0
,
0
,
rectangle
.
width
(),
note
.
lineHeight
());
color
.
setAlpha
(
50
);
painter
.
setBrush
(
color
);
painter
.
drawRect
(
0
,
0
,
3
,
note
.
lineHeight
());
color
.
setAlpha
(
note
.
underMouse
()
?
130
:
90
);
painter
.
setPen
(
color
);
...
...
@@ -193,7 +190,7 @@ void KateGitBlamePlugin::startBlameProcess(const QUrl &url)
QDir
dir
{
url
.
toLocalFile
()};
dir
.
cdUp
();
QStringList
args
{
QStringLiteral
(
"blame"
),
QStringLiteral
(
"./%1"
).
arg
(
fileName
)};
QStringList
args
{
QStringLiteral
(
"blame"
),
QStringLiteral
(
"--date=iso-strict"
),
QStringLiteral
(
"./%1"
).
arg
(
fileName
)};
m_blameInfoProc
.
setWorkingDirectory
(
dir
.
absolutePath
());
m_blameInfoProc
.
start
(
QStringLiteral
(
"git"
),
args
);
...
...
@@ -228,14 +225,15 @@ void KateGitBlamePlugin::blameFinished(int /*exitCode*/, QProcess::ExitStatus /*
return
;
}
const
static
QRegularExpression
lineReg
(
QStringLiteral
(
"(
\\
S+)[^
\\
(]+
\\
((.*)
\\
s+(
\\
d
\\
d
\\
d
\\
d-
\\
d
\\
d-
\\
d
\\
d
\\
d
\\
d:
\\
d
\\
d:
\\
d
\\
d)[^
\\
)]+
\\
)
\\
s(.*)"
));
const
static
QRegularExpression
lineReg
(
QStringLiteral
(
"(
\\
S+)[^
\\
(]+
\\
((.*)
\\
s+(
\\
d
\\
d
\\
d
\\
d-
\\
d
\\
d-
\\
d
\\
d
T
\\
d
\\
d:
\\
d
\\
d:
\\
d
\\
d
\\
S+
)[^
\\
)]+
\\
)
\\
s(.*)"
));
m_blameInfo
.
clear
();
for
(
const
auto
&
line
:
stdOut
)
{
const
QRegularExpressionMatch
match
=
lineReg
.
match
(
line
);
if
(
match
.
hasMatch
())
{
m_blameInfo
.
append
({
match
.
captured
(
1
),
match
.
captured
(
2
).
trimmed
(),
match
.
captured
(
3
),
match
.
captured
(
4
)
});
m_blameInfo
.
append
({
match
.
captured
(
1
),
match
.
captured
(
2
).
trimmed
(),
QDateTime
::
fromString
(
match
.
captured
(
3
),
Qt
::
ISODate
),
match
.
captured
(
4
)
});
}
}
}
...
...
@@ -259,7 +257,7 @@ bool KateGitBlamePlugin::hasBlameInfo() const
const
KateGitBlameInfo
&
KateGitBlamePlugin
::
blameInfo
(
int
lineNr
,
const
QStringView
&
lineText
)
{
static
const
KateGitBlameInfo
dummy
{
QStringLiteral
(
"hash"
),
i18n
(
"Not Committed Yet"
),
Q
StringLiteral
(
""
),
QStringLiteral
(
""
)};
static
const
KateGitBlameInfo
dummy
{
QStringLiteral
(
"hash"
),
i18n
(
"Not Committed Yet"
),
Q
DateTime
::
currentDateTime
(
),
QStringLiteral
(
""
)};
if
(
m_blameInfo
.
isEmpty
())
{
return
dummy
;
...
...
addons/git-blame/kategitblameplugin.h
View file @
4e6f7d9f
...
...
@@ -22,11 +22,13 @@
#include <QRegularExpression>
#include <QVariant>
#include <QVector>
#include <QDateTime>
#include <QLocale>
struct
KateGitBlameInfo
{
QString
commitHash
;
QString
name
;
Q
String
date
;
Q
DateTime
date
;
QString
line
;
};
...
...
@@ -49,6 +51,7 @@ public:
private:
KTextEditor
::
Document
*
m_doc
;
KateGitBlamePlugin
*
m_plugin
;
QLocale
m_locale
;
};
class
KateGitBlamePlugin
:
public
KTextEditor
::
Plugin
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment