From 99a7e562dac658b5e8bf05bd7cd385b125350f9f Mon Sep 17 00:00:00 2001 From: Alexander Koskovich Date: Sat, 16 Dec 2023 13:20:24 -0500 Subject: [PATCH] Support syncing repositories that utilize Git LFS The primary usecase of repo is AOSP development, however objects in AOSP can often get quite large, a lot of firmware and proprietary blobs can be well above 100 MiB which is the GitHub limit. --- .../java/hudson/plugins/repo/RepoScm.java | 24 +++++++++++++++++++ .../hudson/plugins/repo/RepoScm/config.jelly | 4 ++++ .../plugins/repo/RepoScm/help-gitLfs.html | 6 +++++ 3 files changed, 34 insertions(+) create mode 100644 src/main/resources/hudson/plugins/repo/RepoScm/help-gitLfs.html diff --git a/src/main/java/hudson/plugins/repo/RepoScm.java b/src/main/java/hudson/plugins/repo/RepoScm.java index dd63a38..8b2b1a2 100644 --- a/src/main/java/hudson/plugins/repo/RepoScm.java +++ b/src/main/java/hudson/plugins/repo/RepoScm.java @@ -132,6 +132,7 @@ public class RepoScm extends SCM implements Serializable { @CheckForNull private EnvVars extraEnvVars; @CheckForNull private boolean noCloneBundle; @CheckForNull private boolean worktree; + @CheckForNull private boolean gitLfs; /** * Returns the manifest repository URL. @@ -379,6 +380,13 @@ public boolean isFetchSubmodules() { return fetchSubmodules; } + /** + * Returns the value of gitLfs. + */ + public boolean isGitLfs() { + return gitLfs; + } + /** * Returns the value of extraEnvVars. */ @@ -491,6 +499,7 @@ public RepoScm(final String manifestRepositoryUrl) { ignoreProjects = Collections.emptySet(); noCloneBundle = false; worktree = false; + gitLfs = false; } /** @@ -774,6 +783,18 @@ public void setFetchSubmodules(final boolean fetchSubmodules) { this.fetchSubmodules = fetchSubmodules; } + /** + * Set gitLfs. + * + * @param gitLfs + * If this value is true, add the "--git-lfs" option when + * executing "repo init". + */ + @DataBoundSetter + public void setGitLfs(final boolean gitLfs) { + this.gitLfs = gitLfs; + } + /** * Sets list of projects which changes will be ignored when * calculating whether job needs to be rebuild. This field corresponds @@ -1106,6 +1127,9 @@ private boolean checkoutCode(final Launcher launcher, if (manifestSubmodules) { commands.add("--submodules"); } + if (gitLfs) { + commands.add("--git-lfs"); + } int returnCode = launcher.launch().stdout(logger).pwd(workspace) .cmds(commands).envs(env).join(); diff --git a/src/main/resources/hudson/plugins/repo/RepoScm/config.jelly b/src/main/resources/hudson/plugins/repo/RepoScm/config.jelly index da2af27..d4d82c3 100644 --- a/src/main/resources/hudson/plugins/repo/RepoScm/config.jelly +++ b/src/main/resources/hudson/plugins/repo/RepoScm/config.jelly @@ -109,5 +109,9 @@ + + + + diff --git a/src/main/resources/hudson/plugins/repo/RepoScm/help-gitLfs.html b/src/main/resources/hudson/plugins/repo/RepoScm/help-gitLfs.html new file mode 100644 index 0000000..f3e6aaa --- /dev/null +++ b/src/main/resources/hudson/plugins/repo/RepoScm/help-gitLfs.html @@ -0,0 +1,6 @@ +
+

+ Allow repositories utilizing LFS to sync LFS objects. + This is passed to repo as repo init --git-lfs. +

+