Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --glob-file option to load globs from a file #19

Merged
merged 1 commit into from
Oct 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ git clone --mirror git@github.com:bozaro/git-lfs-migrate.git
# -t, --write-threads
# IO thread count
# Default: 2
# --glob-file
# File containing glob patterns
java -jar git-lfs-migrate.jar \
-s git-lfs-migrate.git \
-d git-lfs-migrate-converted.git \
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/git/lfs/migrate/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.nio.file.attribute.BasicFileAttributes;
import java.security.GeneralSecurityException;
import java.util.*;
import java.util.stream.Stream;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -75,8 +76,14 @@ public static void main(@NotNull String[] args) throws Exception {
}
return;
}
String[] globs = cmd.globs.toArray(new String[cmd.globs.size()]);
if (cmd.globFile != null) {
globs = Stream.concat(
Arrays.stream(globs), Files.lines(cmd.globFile.toPath())
).toArray(String[]::new);
}
try {
processRepository(cmd.src, cmd.dst, cmd.cache, client, cmd.writeThreads, cmd.uploadThreads, cmd.globs.toArray(new String[cmd.globs.size()]));
processRepository(cmd.src, cmd.dst, cmd.cache, client, cmd.writeThreads, cmd.uploadThreads, globs);
} catch (ExecutionException e) {
if (e.getCause() instanceof RequestException) {
final RequestException cause = (RequestException) e.getCause();
Expand Down Expand Up @@ -447,6 +454,8 @@ public static class CmdArgs {
private boolean checkLfs = false;
@Parameter(names = {"--no-check-certificate"}, description = "Don't check the server certificate against the available certificate authorities")
private boolean noCheckCertificate = false;
@Parameter(names = {"--glob-file"}, description = "File containing glob patterns")
private File globFile = null;

@Parameter(description = "LFS file glob patterns")
@NotNull
Expand Down