Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Thomas Schöps
kdevelop
Commits
0b4d926c
Commit
0b4d926c
authored
Jun 21, 2009
by
Hugo Parente Lima
Browse files
Added History command to the git plugin.
parent
e2474c13
Changes
2
Hide whitespace changes
Inline
Side-by-side
gitplugin.cpp
View file @
0b4d926c
...
...
@@ -35,6 +35,7 @@
#include
<vcs/vcsjob.h>
#include
<vcs/vcsrevision.h>
#include
<vcs/vcsevent.h>
#include
<vcs/dvcs/dvcsjob.h>
#include
<shell/core.h>
#include
<vcs/vcsannotation.h>
...
...
@@ -248,22 +249,16 @@ VcsJob* GitPlugin::log(const KUrl& localLocation,
if
(
prepareJob
(
job
,
localLocation
.
toLocalFile
())
)
{
*
job
<<
"git"
;
*
job
<<
"log"
;
*
job
<<
"--date=raw"
;
*
job
<<
"--"
;
addFileList
(
job
,
localLocation
);
connect
(
job
,
SIGNAL
(
readyForParsing
(
DVcsJob
*
)),
this
,
SLOT
(
parseGitLogOutput
(
DVcsJob
*
)));
return
job
;
}
if
(
job
)
delete
job
;
return
NULL
;
}
VcsJob
*
GitPlugin
::
log
(
const
KUrl
&
localLocation
,
const
KDevelop
::
VcsRevision
&
rev
,
const
KDevelop
::
VcsRevision
&
limit
)
{
Q_UNUSED
(
limit
)
return
log
(
localLocation
,
rev
,
0
);
}
KDevelop
::
VcsJob
*
GitPlugin
::
annotate
(
const
KUrl
&
localLocation
,
const
KDevelop
::
VcsRevision
&
)
{
DVcsJob
*
job
=
new
DVcsJob
(
this
);
if
(
prepareJob
(
job
,
localLocation
.
toLocalFile
())
)
{
...
...
@@ -271,6 +266,7 @@ KDevelop::VcsJob* GitPlugin::annotate(const KUrl &localLocation, const KDevelop:
*
job
<<
"blame"
;
*
job
<<
"--root"
;
*
job
<<
"-t"
;
*
job
<<
"--"
;
addFileList
(
job
,
localLocation
);
connect
(
job
,
SIGNAL
(
readyForParsing
(
DVcsJob
*
)),
this
,
SLOT
(
parseGitBlameOutput
(
DVcsJob
*
)));
}
else
{
...
...
@@ -793,6 +789,48 @@ void GitPlugin::parseLogOutput(const DVcsJob * job, QList<DVcsEvent>& commits) c
}
}
void
GitPlugin
::
parseGitLogOutput
(
DVcsJob
*
job
)
{
QList
<
QVariant
>
commits
;
static
QRegExp
commitRegex
(
"^commit (
\\
w{8})
\\
w{32}"
);
static
QRegExp
infoRegex
(
"^(
\\
w+):(.*)"
);
QString
contents
=
job
->
output
();
QTextStream
s
(
&
contents
);
VcsEvent
item
;
QString
message
;
bool
pushCommit
=
false
;
while
(
!
s
.
atEnd
())
{
QString
line
=
s
.
readLine
();
if
(
commitRegex
.
exactMatch
(
line
))
{
if
(
pushCommit
)
{
item
.
setMessage
(
message
.
trimmed
());
commits
.
append
(
QVariant
::
fromValue
(
item
));
}
else
{
pushCommit
=
true
;
}
VcsRevision
rev
;
rev
.
setRevisionValue
(
commitRegex
.
cap
(
1
),
KDevelop
::
VcsRevision
::
GlobalNumber
);
item
.
setRevision
(
rev
);
message
.
clear
();
}
else
if
(
infoRegex
.
exactMatch
(
line
))
{
QString
cap1
=
infoRegex
.
cap
(
1
);
if
(
cap1
==
"Author"
)
{
item
.
setAuthor
(
infoRegex
.
cap
(
2
).
trimmed
());
}
else
if
(
cap1
==
"Date"
)
{
item
.
setDate
(
QDateTime
::
fromTime_t
(
infoRegex
.
cap
(
2
).
trimmed
().
split
(
' '
)[
0
].
toUInt
()));
}
}
else
if
(
line
.
startsWith
(
" "
))
{
message
+=
line
.
remove
(
0
,
4
);
message
+=
'\n'
;
}
}
item
.
setMessage
(
message
.
trimmed
());
commits
.
append
(
QVariant
::
fromValue
(
item
));
job
->
setResults
(
commits
);
}
QStringList
GitPlugin
::
getLsFiles
(
const
QString
&
directory
,
const
QStringList
&
args
)
{
DVcsJob
*
job
=
lsFiles
(
directory
,
args
);
...
...
gitplugin.h
View file @
0b4d926c
...
...
@@ -64,12 +64,12 @@ public:
KDevelop
::
VcsJob
*
commit
(
const
QString
&
message
,
const
KUrl
::
List
&
localLocations
,
KDevelop
::
IBasicVersionControl
::
RecursionMode
recursion
=
KDevelop
::
IBasicVersionControl
::
Recursive
);
using
KDevelop
::
DistributedVersionControlPlugin
::
log
;
KDevelop
::
VcsJob
*
log
(
const
KUrl
&
localLocation
,
const
KDevelop
::
VcsRevision
&
rev
,
unsigned
long
limit
);
KDevelop
::
VcsJob
*
log
(
const
KUrl
&
localLocation
,
const
KDevelop
::
VcsRevision
&
rev
,
const
KDevelop
::
VcsRevision
&
limit
);
KDevelop
::
VcsJob
*
annotate
(
const
KUrl
&
localLocation
,
const
KDevelop
::
VcsRevision
&
rev
);
// Begin: KDevelop::IDistributedVersionControl
...
...
@@ -117,6 +117,8 @@ protected:
protected
slots
:
void
parseGitBlameOutput
(
DVcsJob
*
job
);
void
parseGitLogOutput
(
DVcsJob
*
job
);
private:
//commit dialog "main" helper
QStringList
getLsFiles
(
const
QString
&
directory
,
const
QStringList
&
args
=
QStringList
());
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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