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
7c73b56d
Commit
7c73b56d
authored
8 years ago
by
Georg Seibt
Browse files
Options
Downloads
Patches
Plain Diff
checkout and doc formatting
parent
df74e6ed
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/Repository.java
+33
-2
33 additions, 2 deletions
src/de/uni_passau/fim/seibt/gitwrapper/repo/Repository.java
with
33 additions
and
2 deletions
src/de/uni_passau/fim/seibt/gitwrapper/repo/Repository.java
+
33
−
2
View file @
7c73b56d
...
...
@@ -56,6 +56,35 @@ public class Repository {
this
.
commits
=
new
HashMap
<>();
}
/**
* Performs a checkout of the given {@link Commit}.
*
* @param c
* the {@link Commit} to checkout
* @return whether the checkout was successful
* @see <a href=https://git-scm.com/docs/git-checkout>git-checkout</a>
*/
public
boolean
checkout
(
Commit
c
)
{
if
(!
commits
.
containsValue
(
c
))
{
LOG
.
warning
(()
->
String
.
format
(
"Checkout failed. %s is not part of %s."
,
c
,
this
));
return
false
;
}
Optional
<
ExecRes
>
checkout
=
git
.
exec
(
dir
,
"checkout"
,
c
.
getId
());
Function
<
ExecRes
,
Boolean
>
toBoolean
=
res
->
{
boolean
failed
=
git
.
failed
(
res
);
if
(
failed
)
{
LOG
.
warning
(()
->
String
.
format
(
"Checkout of %s failed."
,
c
));
}
return
failed
;
};
return
checkout
.
map
(
toBoolean
).
orElse
(
false
);
}
/**
* Returns the merge commits in this repository.
*
...
...
@@ -85,7 +114,8 @@ public class Repository {
* 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.
*
* @param id the ID for the {@link Commit}
* @param id
* the ID for the {@link Commit}
* @return the {@link Commit}
*/
Commit
getCommitUnchecked
(
String
id
)
{
...
...
@@ -96,7 +126,8 @@ public class Repository {
* Returns a {@link Commit} for the given ID. If the given ID does not designate a commit that exists in this
* {@link Repository} an empty {@link Optional} will be returned. The ID will be resolved to a full SHA1 hash.
*
* @param id the ID of the commit
* @param id
* the ID of the commit
* @return the {@link Commit} or an empty {@link Optional} if the ID is invalid or an exception occurs
*/
public
Optional
<
Commit
>
getCommit
(
String
id
)
{
...
...
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