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
ea197eb9
Commit
ea197eb9
authored
8 years ago
by
Georg Seibt
Browse files
Options
Downloads
Patches
Plain Diff
add a warning in case of failure to the checkAncestry(...) method
parent
d387515a
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
+21
-2
21 additions, 2 deletions
src/de/uni_passau/fim/seibt/gitwrapper/repo/Commit.java
with
21 additions
and
2 deletions
src/de/uni_passau/fim/seibt/gitwrapper/repo/Commit.java
+
21
−
2
View file @
ea197eb9
...
...
@@ -4,10 +4,15 @@ import java.time.Instant;
import
java.time.OffsetDateTime
;
import
java.time.ZoneId
;
import
java.util.Optional
;
import
java.util.function.Function
;
import
java.util.logging.Logger
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
de.uni_passau.fim.seibt.gitwrapper.process.ProcessExecutor
;
import
de.uni_passau.fim.seibt.gitwrapper.process.ProcessExecutor.ExecRes
;
import
de.uni_passau.fim.seibt.gitwrapper.process.ToolWrapper
;
/**
* A {@link Commit} made in a {@link Repository}.
*/
...
...
@@ -52,8 +57,22 @@ public class Commit extends Reference {
* <code>false</code>, if not and an {@link Optional#EMPTY empty optional}, if an error occurred.
*/
public
Optional
<
Boolean
>
checkAncestry
(
Commit
ancestor
)
{
return
git
.
exec
(
repo
.
getDir
(),
" merge-base"
,
"--is-ancestor"
,
ancestor
.
getId
(),
id
).
map
(
execRes
->
execRes
.
exitCode
==
0
?
Boolean
.
TRUE
:
execRes
.
exitCode
==
1
?
Boolean
.
FALSE
:
null
);
Optional
<
ExecRes
>
res
=
git
.
exec
(
repo
.
getDir
(),
"merge-base"
,
"--is-ancestor"
,
ancestor
.
getId
(),
id
);
Function
<
ExecRes
,
Boolean
>
toBoolean
=
execRes
->
{
if
(
execRes
.
exitCode
==
0
)
{
return
Boolean
.
TRUE
;
}
if
(
execRes
.
exitCode
==
1
)
{
return
Boolean
.
FALSE
;
}
LOG
.
warning
(()
->
"Failed to determine whether '"
+
ancestor
+
"' is an ancestor of '"
+
this
+
"'."
);
return
null
;
};
return
res
.
map
(
toBoolean
);
}
/**
...
...
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