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
698c3f92
Commit
698c3f92
authored
8 years ago
by
Georg Seibt
Browse files
Options
Downloads
Patches
Plain Diff
move copy method to Repository and return new Repository objects representing the copies
parent
7c73b56d
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
+27
-0
27 additions, 0 deletions
src/de/uni_passau/fim/seibt/gitwrapper/repo/Repository.java
with
27 additions
and
0 deletions
src/de/uni_passau/fim/seibt/gitwrapper/repo/Repository.java
+
27
−
0
View file @
698c3f92
...
...
@@ -15,6 +15,7 @@ import java.util.logging.Logger;
import
java.util.stream.Collectors
;
import
de.uni_passau.fim.seibt.gitwrapper.process.ProcessExecutor.ExecRes
;
import
org.apache.commons.io.FileUtils
;
/**
* A git {@link Repository}.
...
...
@@ -195,6 +196,32 @@ public class Repository {
return
revParse
.
map
(
toHash
);
}
/**
* Copies this {@link Repository} to the given <code>destination</code> directory.
*
* @param destination
* the destination directory
* @return a copy of this {@link Repository} at the new location
* @see FileUtils#copyDirectory(File, File)
*/
public
Optional
<
Repository
>
copy
(
File
destination
)
{
try
{
if
(
destination
.
exists
()
&&
destination
.
isDirectory
())
{
LOG
.
warning
(()
->
String
.
format
(
"%s already exists. Merging source and destination directories."
,
destination
));
}
FileUtils
.
copyDirectory
(
dir
,
destination
);
LOG
.
fine
(()
->
String
.
format
(
"Copied %s to %s."
,
this
,
destination
));
}
catch
(
IOException
e
)
{
LOG
.
log
(
Level
.
WARNING
,
e
,
()
->
String
.
format
(
"Failed to copy %s to %s."
,
dir
,
destination
));
return
Optional
.
empty
();
}
return
Optional
.
of
(
new
Repository
(
git
,
url
,
destination
));
}
/**
* Returns the {@link GitWrapper} used by this {@link 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