diff --git a/docs/reference.md b/docs/reference.md
index d8c524a56..747340f85 100755
--- a/docs/reference.md
+++ b/docs/reference.md
@@ -3672,7 +3672,7 @@ Implicit labels that can be used/exposed:
- GITHUB_PR_REVIEWER_OTHER: A repeated label with the login of users that have participated in the review but cannot approve the import. Only populated if `review_state` field is set.
-origin git.github_pr_origin(url, use_merge=False, required_labels=[], required_status_context_names=[], required_check_runs=[], retryable_labels=[], submodules='NO', excluded_submodules=[], baseline_from_branch=False, first_parent=True, partial_fetch=False, state='OPEN', review_state=None, review_approvers=["COLLABORATOR", "MEMBER", "OWNER"], api_checker=None, patch=None, branch=None, describe_version=None, credentials=None, github_host_name='github.com')
+origin git.github_pr_origin(url, use_merge=False, required_labels=[], required_status_context_names=[], required_check_runs=[], retryable_labels=[], submodules='NO', excluded_submodules=[], baseline_from_branch=False, first_parent=True, partial_fetch=False, state='OPEN', review_state=None, review_approvers=["COLLABORATOR", "MEMBER", "OWNER"], api_checker=None, patch=None, branch=None, describe_version=None, enable_lfs=False, credentials=None, github_host_name='github.com')
Parameters:
@@ -3697,6 +3697,7 @@ Parameter | Description
patch | transformation or NoneType
Patch the checkout dir. The difference with `patch.apply` transformation is that here we can apply it using three-way
branch | string or NoneType
If set, it will only migrate pull requests for this base branch
describe_version | bool or NoneType
Download tags and use 'git describe' to create four labels with a meaningful version identifier:
- `GIT_DESCRIBE_CHANGE_VERSION`: The version for the change or changes being migrated. The value changes per change in `ITERATIVE` mode and will be the latest migrated change in `SQUASH` (In other words, doesn't include excluded changes). this is normally what users want to use.
- `GIT_DESCRIBE_REQUESTED_VERSION`: `git describe` for the requested/head version. Constant in `ITERATIVE` mode and includes filtered changes.
-`GIT_DESCRIBE_FIRST_PARENT`: `git describe` for the first parent version.
-`GIT_SEQUENTIAL_REVISION_NUMBER`: The sequential number of the commit. Falls back to the SHA1 if not applicable.
+enable_lfs | bool
If true, Large File Storage support is enabled for the origin.
credentials | UsernamePasswordIssuer or NoneType
EXPERIMENTAL: Read credentials from config file to access the Git Repo. This expects a 'credentials.username_password' specifying the username to use for the remote git host and a password or token. This is gated by the '--use-credentials-from-config' flag
github_host_name | string
**EXPERIMENTAL feature.** The host name of the GitHub repository, used to construct the URL. Required for GitHub Enterprise.
diff --git a/java/com/google/copybara/git/GitHubPrOrigin.java b/java/com/google/copybara/git/GitHubPrOrigin.java
index a9d0c0c8c..4851d47b3 100644
--- a/java/com/google/copybara/git/GitHubPrOrigin.java
+++ b/java/com/google/copybara/git/GitHubPrOrigin.java
@@ -147,6 +147,7 @@ public class GitHubPrOrigin implements Origin {
private final GitHubHost ghHost;
private final GitHubPrOriginOptions gitHubPrOriginOptions;
private final ApprovalsProvider provider;
+ private final boolean enableLfs;
@Nullable private final CredentialFileHandler credentials;
@Nullable private final GitRepositoryHook gitRepositoryHook;
@@ -176,6 +177,7 @@ public class GitHubPrOrigin implements Origin {
boolean describeVersion,
GitHubHost ghHost,
ApprovalsProvider provider,
+ boolean enableLfs,
@Nullable CredentialFileHandler credentials,
@Nullable GitRepositoryHook gitRepositoryHook) {
this.url = checkNotNull(url);
@@ -204,6 +206,7 @@ public class GitHubPrOrigin implements Origin {
this.describeVersion = describeVersion;
this.ghHost = ghHost;
this.provider = checkNotNull(provider);
+ this.enableLfs = enableLfs;
this.credentials = credentials;
this.gitRepositoryHook = gitRepositoryHook;
}
@@ -711,6 +714,9 @@ private void checkReviewApprovers(
@VisibleForTesting
public GitRepository getRepository() throws RepoException {
GitRepository repo = gitOptions.cachedBareRepoForUrl(url);
+ if (enableLfs) {
+ repo.setRemoteOriginUrl(url);
+ }
if (credentials != null) {
try {
credentials.install(repo, gitOptions.getConfigCredsFile(generalOptions));
@@ -894,6 +900,9 @@ public ImmutableSetMultimap describe(Glob originFiles) {
if (!getRetryableLabels().isEmpty()) {
builder.putAll(GitHubUtil.RETRYABLE_LABELS, getRetryableLabels());
}
+ if (enableLfs) {
+ builder.put("enableLfs", Boolean.toString(enableLfs));
+ }
return builder.build();
}
diff --git a/java/com/google/copybara/git/GitModule.java b/java/com/google/copybara/git/GitModule.java
index 0459bd20d..3ab7d552c 100644
--- a/java/com/google/copybara/git/GitModule.java
+++ b/java/com/google/copybara/git/GitModule.java
@@ -1196,6 +1196,12 @@ public GitOrigin gerritOrigin(
named = true,
positional = false,
doc = DESCRIBE_VERSION_FIELD_DOC),
+ @Param(
+ name = "enable_lfs",
+ defaultValue = "False",
+ named = true,
+ positional = false,
+ doc = "If true, Large File Storage support is enabled for the origin."),
@Param(
name = "credentials",
allowedTypes = {
@@ -1237,6 +1243,7 @@ public Origin githubPrOrigin(
Object patch,
Object branch,
Object describeVersion,
+ Boolean enableLfs,
@Nullable Object credentials,
String gitHubHostName,
StarlarkThread thread)
@@ -1299,7 +1306,7 @@ public Origin githubPrOrigin(
workflowName,
false,
githubPostSubmitApprovalsProvider(fixedUrl, ref, credHandler),
- /* enableLfs= */ false,
+ enableLfs,
credHandler,
null);
}
@@ -1336,6 +1343,7 @@ public Origin githubPrOrigin(
convertDescribeVersion(describeVersion),
gitHubHost,
githubPreSubmitApprovalsProvider(fixedUrl, credHandler),
+ enableLfs,
credHandler,
/* gitRepositoryHook= */ null);
}
diff --git a/javatests/com/google/copybara/git/GitHubPrOriginTest.java b/javatests/com/google/copybara/git/GitHubPrOriginTest.java
index d83b61648..be7dec24e 100644
--- a/javatests/com/google/copybara/git/GitHubPrOriginTest.java
+++ b/javatests/com/google/copybara/git/GitHubPrOriginTest.java
@@ -49,6 +49,7 @@
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSetMultimap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
@@ -1276,6 +1277,28 @@ public void testDescribeBranch() throws Exception {
.contains("dev");
}
+ @Test
+ public void testEnableLfs() throws Exception {
+ GitHubPrOrigin origin =
+ githubPrOrigin(
+ "url = 'https://github.com/google/example'",
+ "enable_lfs = True");
+ ImmutableSetMultimap actual = origin.describe(Glob.ALL_FILES);
+ assertThat(actual.get("enableLfs")).containsExactly("true");
+
+ GitRepository repo = origin.getRepository();
+ assertThat(repo.simpleCommand("config", "remote.origin.url").getStdout().trim())
+ .isEqualTo("https://github.com/google/example");
+ }
+
+ @Test
+ public void testEnableLfs_defaultFalse() throws Exception {
+ GitHubPrOrigin origin =
+ githubPrOrigin("url = 'https://github.com/google/example'");
+ ImmutableSetMultimap actual = origin.describe(Glob.ALL_FILES);
+ assertThat(actual.containsKey("enableLfs")).isFalse();
+ }
+
private GitRevision checkReviewApprovers(String... configLines)
throws RepoException, IOException, ValidationException {
GitRepository remote = gitUtil.mockRemoteRepo("github.com/google/example");