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

[JENKINS-21248] Support shallow submodule update #303

Closed
wants to merge 2 commits into from

Conversation

fujii
Copy link
Contributor

@fujii fujii commented Mar 9, 2018

@fujii
Copy link
Contributor Author

fujii commented Mar 9, 2018

This patch is the git-plugin part of this fix.
fujii/git-plugin@035090e

Copy link
Contributor

@MarkEWaite MarkEWaite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide tests for the shallow setting on submodule clone. The existing submodule tests should be a good starting point to add further tests.

@fujii
Copy link
Contributor Author

fujii commented Mar 12, 2018

Thank you for your feedback, @MarkEWaite.
I created a test, and it passes on my env. But it fails in CI env.
What makes the difference? CI server can access github.com during tests?

@MarkEWaite
Copy link
Contributor

I see the same failure when I execute:

mkdir tmp
cd tmp
git clone https://github.com/jenkinsci/git-client-plugin
cd git-client-plugin
git checkout -b fujii-shallow-submodule-update master
git pull https://github.com/fujii/git-client-plugin.git shallow-submodule-update
mvn clean -Dtest=CliGitAPIImplTest test

I assumed it was the missing submoduleInit() call in the new test compared to the test which precedes it in the file. Unfortunately, that was not enough to fix the test. I think you'll need to investigate further.

@fujii
Copy link
Contributor Author

fujii commented Mar 13, 2018

Thank you for testing my patch, @MarkEWaite.
Unfortunately, I can't reproduce the error with your procedure.
I guess it might depend on the region.
So, I created a new test fetching a submodule from the local mirror target/clone.git.
This patch will fail in the CI auto test because https://github.com/jenkinsci/git-client-plugin.git doesn't have tests/getRelativeSubmodule branch yet.
It is in https://github.com/fujii/git-client-plugin/tree/tests/getRelativeSubmodule
How do you think this idea?

@darxriggs
Copy link
Contributor

Hi @fujii, could you rebase this pull request on the current master branch?

return this;
}

public SubmoduleUpdateCommand depth(Integer depth) {
Copy link
Contributor

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 of Integer for the method parameter and instance variable. (I also see boolean and no Boolean).

Copy link
Contributor

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.

@@ -2570,6 +2570,18 @@ public void test_submodule_update() throws Exception {
assertFixSubmoduleUrlsThrows();
}

@NotImplementedInJGit
public void test_submodule_update_shallow() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other test cases would also be useful:

  • no shallow(...) call
  • shallow(false)
  • depth(...)

@fujii
Copy link
Contributor Author

fujii commented Jul 5, 2018

@darxriggs: Thank you. I will do it. But, I'm pretty busy now. Feel free to take over.

@darxriggs
Copy link
Contributor

Hi @fujii, the error you mentioned, is it about referencing shas on github when cloning? Github does not support this (see isaacs/github#436). The respective git option would be uploadpack.allowReachableSHA1InWant. The error output I get is as follows:

hudson.plugins.git.GitException: Command "git submodule update --depth=1 modules/sshkeys" returned status code 1:
stdout: 
stderr: Cloning into '/tmp/jenkinsTests.tmp/jenkins3443046290638298345test/modules/sshkeys'...
error: Server does not allow request for unadvertised object 689c45ed57f0829735f9a2b16760c14236fe21d9
Fetched in submodule path 'modules/sshkeys', but it did not contain 689c45ed57f0829735f9a2b16760c14236fe21d9. Direct fetching of that commit failed.

Your proposed solution with an extra branch that contains a submodule referencing a local git repository is a clever trick. But I find it a bit confusing and an extra branch has to be maintained.

Another idea is to put a repository with submodules into src/test/resources (there are already others) that contains all relevant properties to test submodules. This would also reduce the need to clone submodules from github which implies some risk and constraints.

What are your thoughts @MarkEWaite?

@MarkEWaite
Copy link
Contributor

Adding a binary copy of a specific repository into src/test/resources would be fine. I have no problem with extra branches in the git-client-plugin repository for specific tests. I hesitate to have those branches depend on something outside the repository, unless the tests which use those branches are entirely optional.

@@ -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");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @MarkEWaite, should using shallow for JGit throw this UnsupportedOperationException here or just log a WARNING when calling shallow(true) at lines 2224-2227?

As a reference FetchCommand and CloneCommand just perform logging. That's not consistent in this class.

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

@darxriggs
Copy link
Contributor

As I cannot update this one, I prepared a new pull request #344 with improvements.

@fujii
Copy link
Contributor Author

fujii commented Jul 30, 2018

Thanks. Closed this ticket.

@fujii fujii closed this Jul 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants