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
c227ee60
Commit
c227ee60
authored
8 years ago
by
Georg Seibt
Browse files
Options
Downloads
Patches
Plain Diff
add a method for retrieving the paths affected by a commit
parent
58bda64b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/de/uni_passau/fim/seibt/gitwrapper/repo/Commit.java
+39
-0
39 additions, 0 deletions
src/de/uni_passau/fim/seibt/gitwrapper/repo/Commit.java
with
39 additions
and
0 deletions
src/de/uni_passau/fim/seibt/gitwrapper/repo/Commit.java
+
39
−
0
View file @
c227ee60
package
de.uni_passau.fim.seibt.gitwrapper.repo
;
import
java.nio.file.Path
;
import
java.time.Instant
;
import
java.time.OffsetDateTime
;
import
java.time.ZoneId
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.function.Function
;
import
java.util.function.Supplier
;
import
java.util.logging.Logger
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
...
...
@@ -73,6 +77,41 @@ public class Commit extends Reference {
return
res
.
map
(
toBoolean
);
}
/**
* Returns the paths that were affected by this {@link Commit}.
*
* @return optionally the {@link List} of {@link Path Paths}
*/
public
Optional
<
List
<
Path
>>
getAffectedPaths
()
{
Optional
<
ExecRes
>
res
=
git
.
exec
(
repo
.
getDir
(),
"show"
,
"--name-only"
,
"--pretty=format:"
,
id
);
Function
<
ExecRes
,
List
<
Path
>>
toPaths
=
execRes
->
{
Supplier
<
String
>
errorMsg
=
()
->
"Failed to determine the paths affected by '"
+
this
+
"'."
;
if
(
git
.
failed
(
execRes
))
{
LOG
.
warning
(
errorMsg
);
return
null
;
}
String
[]
lines
=
execRes
.
getStdOutTrimmed
().
split
(
"\\R"
);
List
<
Path
>
paths
=
new
ArrayList
<>();
for
(
String
line
:
lines
)
{
Optional
<
Path
>
oPath
=
git
.
getPath
(
line
);
if
(
oPath
.
isPresent
())
{
paths
.
add
(
oPath
.
get
());
}
else
{
LOG
.
warning
(
errorMsg
);
return
null
;
}
}
return
paths
;
};
return
res
.
map
(
toPaths
);
}
/**
* Returns the author of this commit.
*
...
...
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