Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GitWrapper
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Georg Seibt
GitWrapper
Commits
131b2996
Commit
131b2996
authored
8 years ago
by
Georg Seibt
Browse files
Options
Downloads
Patches
Plain Diff
replace calls to Paths.get(...) with git.getPath(...)
parent
74cfa004
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/de/uni_passau/fim/seibt/gitwrapper/repo/Repository.java
+23
-4
23 additions, 4 deletions
src/de/uni_passau/fim/seibt/gitwrapper/repo/Repository.java
src/de/uni_passau/fim/seibt/gitwrapper/repo/Status.java
+20
-4
20 additions, 4 deletions
src/de/uni_passau/fim/seibt/gitwrapper/repo/Status.java
with
43 additions
and
8 deletions
src/de/uni_passau/fim/seibt/gitwrapper/repo/Repository.java
+
23
−
4
View file @
131b2996
...
...
@@ -3,7 +3,6 @@ package de.uni_passau.fim.seibt.gitwrapper.repo;
import
java.io.File
;
import
java.io.IOException
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.time.Instant
;
import
java.time.OffsetDateTime
;
import
java.time.ZoneId
;
...
...
@@ -415,6 +414,7 @@ public class Repository {
List
<
BlameLine
>
bLines
=
new
ArrayList
<>();
Map
<
Commit
,
BlameLine
>
firstOccurrences
=
new
HashMap
<>();
blameLineLoop:
while
(
lines
.
hasNextLine
())
{
String
line
;
Scanner
lineScanner
;
...
...
@@ -470,9 +470,18 @@ public class Repository {
case
COMMITTER_TZ:
committerTZ
=
ZoneId
.
of
(
lineScanner
.
next
());
break
;
case
FILENAME:
commitFile
=
Paths
.
get
(
lineScanner
.
nextLine
().
trim
());
break
;
case
FILENAME:
{
Optional
<
Path
>
oPath
=
git
.
getPath
(
lineScanner
.
nextLine
().
substring
(
1
));
if
(
oPath
.
isPresent
())
{
commitFile
=
oPath
.
get
();
}
else
{
// TODO return Optional.empty() from the blameFile() method?
LOG
.
warning
(()
->
"Failed to parse the file path for a line in the blame output. Skipping."
);
skipBlameLine
(
lines
);
continue
blameLineLoop
;
}
}
break
;
case
SUMMARY:
// We do not explicitly store the summary of the commit as it is just the first line of its message (for which there is a getter).
case
BOUNDARY:
...
...
@@ -507,6 +516,16 @@ public class Repository {
return
bLines
;
}
/**
* Skips all lines returned from the {@code lines} {@link Scanner} up to and including the first one starting
* with a TAB.
*
* @param lines the {@link Scanner} in which to skip lines
*/
private
void
skipBlameLine
(
Scanner
lines
)
{
while
(
lines
.
hasNextLine
()
&&
!
lines
.
nextLine
().
startsWith
(
"\t"
));
}
/**
* Parses the output of 'git blame' for an unmerged file and extracts the merge conflicts that occurred in the file.
* Every merge conflict is represented by a {@link MergeConflict} instance containing the {@link BlameLine BlameLines}
...
...
This diff is collapsed.
Click to expand it.
src/de/uni_passau/fim/seibt/gitwrapper/repo/Status.java
+
20
−
4
View file @
131b2996
...
...
@@ -236,6 +236,7 @@ public class Status {
List
<
Path
>
untracked
=
new
ArrayList
<>();
List
<
Path
>
ignored
=
new
ArrayList
<>();
GitWrapper
git
=
repo
.
getGit
();
Matcher
matcher
=
STATUS_ENTRY
.
matcher
(
gitOutput
);
while
(
matcher
.
find
())
{
...
...
@@ -247,11 +248,26 @@ public class Status {
Optional
<
Path
>
oldFile
;
if
((
code
=
matcher
.
group
(
G_CODE
))
!=
null
)
{
file
=
Paths
.
get
(
matcher
.
group
(
G_PATH
));
oldFile
=
Optional
.
empty
();
Optional
<
Path
>
oPath
=
git
.
getPath
(
matcher
.
group
(
G_PATH
));
if
(
oPath
.
isPresent
())
{
file
=
oPath
.
get
();
oldFile
=
Optional
.
empty
();
}
else
{
LOG
.
warning
(()
->
"Failed to parse the file path for status entry '"
+
matcher
.
group
()
+
"'."
);
continue
;
}
}
else
if
((
code
=
matcher
.
group
(
G_RCODE
))
!=
null
)
{
file
=
Paths
.
get
(
matcher
.
group
(
G_TO
));
oldFile
=
Optional
.
of
(
matcher
.
group
(
G_FROM
)).
map
(
Paths:
:
get
);
Optional
<
Path
>
oToPath
=
git
.
getPath
(
matcher
.
group
(
G_TO
));
Optional
<
Path
>
oFromPath
=
git
.
getPath
(
matcher
.
group
(
G_FROM
));
if
(
oToPath
.
isPresent
()
&&
oFromPath
.
isPresent
())
{
file
=
oToPath
.
get
();
oldFile
=
oFromPath
;
}
else
{
LOG
.
warning
(()
->
"Failed to parse a file path for status entry '"
+
matcher
.
group
()
+
"'."
);
continue
;
}
}
else
{
// This 'should' not be possible...
LOG
.
warning
(()
->
"Could not find the status codes for the status entry '"
+
matcher
.
group
()
+
"'."
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment