-
Notifications
You must be signed in to change notification settings - Fork 389
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
[JENKINS-21248] Support shallow submodule update #303
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2187,6 +2187,7 @@ public org.jenkinsci.plugins.gitclient.SubmoduleUpdateCommand submoduleUpdate() | |
return new org.jenkinsci.plugins.gitclient.SubmoduleUpdateCommand() { | ||
boolean recursive = false; | ||
boolean remoteTracking = false; | ||
boolean shallow = false; | ||
String ref = null; | ||
|
||
@Override | ||
|
@@ -2219,6 +2220,17 @@ public org.jenkinsci.plugins.gitclient.SubmoduleUpdateCommand timeout(Integer ti | |
return this; | ||
} | ||
|
||
@Override | ||
public org.jenkinsci.plugins.gitclient.SubmoduleUpdateCommand shallow(boolean shallow) { | ||
this.shallow = shallow; | ||
return this; | ||
} | ||
|
||
@Override | ||
public org.jenkinsci.plugins.gitclient.SubmoduleUpdateCommand depth(Integer depth) { | ||
return this; | ||
} | ||
|
||
@Override | ||
public org.jenkinsci.plugins.gitclient.SubmoduleUpdateCommand useBranch(String submodule, String branchname) { | ||
return this; | ||
|
@@ -2234,6 +2246,10 @@ public void execute() throws GitException, InterruptedException { | |
listener.getLogger().println("[ERROR] JGit doesn't support submodule update --reference yet."); | ||
throw new UnsupportedOperationException("not implemented yet"); | ||
} | ||
if (shallow) { | ||
listener.getLogger().println("[ERROR] JGit doesn't support shallow submodules yet."); | ||
throw new UnsupportedOperationException("not implemented yet"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @MarkEWaite, should using As a reference There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right @darxriggs , it would be good enough to log the implementation gap rather than fail the checkout. Shallow clone is a performance optimization that isn't critical to the typical use of the repository. |
||
} | ||
|
||
try (Repository repo = getRepository()) { | ||
SubmoduleUpdateCommand update = git(repo).submoduleUpdate(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2575,6 +2575,18 @@ public void test_submodule_update() throws Exception { | |
assertFixSubmoduleUrlsThrows(); | ||
} | ||
|
||
@NotImplementedInJGit | ||
public void test_submodule_update_shallow() throws Exception { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Other test cases would also be useful:
|
||
w.init(); | ||
w.git.clone_().url(localMirror()).repositoryName("sub2_origin").execute(); | ||
w.git.checkout().branch("tests/getRelativeSubmodule").ref("sub2_origin/tests/getRelativeSubmodule").deleteBranchIfExist(true).execute(); | ||
w.git.submoduleInit(); | ||
w.git.submoduleUpdate().shallow(true).execute(); | ||
|
||
final String shallow = ".git" + File.separator + "modules" + File.separator + "sub" + File.separator + "shallow"; | ||
assertTrue("Shallow file does not exist: " + shallow, w.exists(shallow)); | ||
} | ||
|
||
@NotImplementedInJGit | ||
public void test_trackingSubmoduleBranches() throws Exception { | ||
if (! ((CliGitAPIImpl)w.git).isAtLeastVersion(1,8,2,0)) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If possible I would go for
int
instead ofInteger
for the method parameter and instance variable. (I also seeboolean
and noBoolean
).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I have seen now that this is done like this to be consisent with the methods for clone/fetch.