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
79ed570a
Commit
79ed570a
authored
8 years ago
by
Georg Seibt
Browse files
Options
Downloads
Patches
Plain Diff
method for determining the HEAD commit
parent
57b6e52d
No related branches found
No related tags found
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/Repository.java
+20
-0
20 additions, 0 deletions
src/de/uni_passau/fim/seibt/gitwrapper/repo/Repository.java
with
20 additions
and
0 deletions
src/de/uni_passau/fim/seibt/gitwrapper/repo/Repository.java
+
20
−
0
View file @
79ed570a
...
...
@@ -126,6 +126,26 @@ public class Repository {
return
revList
.
map
(
toCommitList
).
orElse
(
Collections
.
emptyList
());
}
/**
* Returns the {@link Commit} currently pointed at by <code>HEAD</code>.
*
* @return the <code>HEAD</code> commit
*/
public
Optional
<
Commit
>
getCurrentHEAD
()
{
Optional
<
ExecRes
>
revParse
=
git
.
exec
(
dir
,
"rev-parse"
,
"HEAD"
);
Function
<
ExecRes
,
Commit
>
toHEAD
=
res
->
{
if
(
git
.
failed
(
res
))
{
LOG
.
warning
(()
->
"Failed to obtain the current HEAD commit."
);
return
null
;
}
return
getCommitUnchecked
(
res
.
stdOut
);
};
return
revParse
.
map
(
toHEAD
);
}
/**
* Returns a {@link Commit} for the given ID. The caller must ensure that the ID is a full SHA1 hash of a
* commit that exists in this repository.
...
...
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