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
2453ccbf
Commit
2453ccbf
authored
6 years ago
by
Georg Seibt
Browse files
Options
Downloads
Patches
Plain Diff
Sync submodules when checking out a Repository.
parent
3204a137
No related branches found
Branches containing commit
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/gitwrapper/Repository.java
+28
-2
28 additions, 2 deletions
src/de/uni_passau/fim/gitwrapper/Repository.java
with
28 additions
and
2 deletions
src/de/uni_passau/fim/gitwrapper/Repository.java
+
28
−
2
View file @
2453ccbf
...
...
@@ -128,7 +128,7 @@ public class Repository {
return
!
failed
;
};
return
checkout
.
map
(
toBoolean
).
orElse
(
false
);
return
checkout
.
map
(
toBoolean
).
map
(
co
->
co
&&
syncSubmodules
()).
orElse
(
false
);
}
/**
...
...
@@ -152,7 +152,33 @@ public class Repository {
return
true
;
};
return
checkout
.
map
(
toBoolean
).
orElse
(
false
);
return
checkout
.
map
(
toBoolean
).
map
(
co
->
co
&&
syncSubmodules
()).
orElse
(
false
);
}
/**
* Synchronizes and initializes the submodules of this repository.
*
* @return whether the synchronization was successful
*/
private
Boolean
syncSubmodules
()
{
Optional
<
ExecRes
>
init
=
git
.
exec
(
dir
,
"submodule"
,
"init"
);
Optional
<
ExecRes
>
sync
=
init
.
filter
(
ExecRes:
:
succeeded
)
.
flatMap
(
res
->
git
.
exec
(
dir
,
"submodule"
,
"sync"
));
Optional
<
ExecRes
>
update
=
sync
.
filter
(
ExecRes:
:
succeeded
)
.
flatMap
(
res
->
git
.
exec
(
dir
,
"submodule"
,
"update"
,
"--init"
,
"--recursive"
));
Function
<
ExecRes
,
Boolean
>
toBoolean
=
res
->
{
boolean
failed
=
git
.
failed
(
res
);
if
(
failed
)
{
LOG
.
warning
(()
->
"Failed to sync the submodules of "
+
Repository
.
this
);
return
false
;
}
return
true
;
};
return
update
.
map
(
toBoolean
).
orElse
(
false
);
}
/**
...
...
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