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-49757] Remove redundant fetch #904

Merged
merged 36 commits into from
Jul 2, 2020
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
8d58567
Add flag to avoid redundant fetch in GitSCM checkout
rishabhBudhouliya Feb 24, 2020
23158ea
Automated test to check redundance fetch call: testRedundantFetchCall…
rishabhBudhouliya Feb 25, 2020
9b25935
Added tests that confirm no data loss with avoiding second fetch
rishabhBudhouliya Mar 2, 2020
2cf858e
Merge pull request #1 from jenkinsci/master
rishabhBudhouliya Mar 6, 2020
11a87d4
Merge branch 'master' of https://github.com/jenkinsci/git-plugin
rishabhBudhouliya Mar 18, 2020
5d94f2e
Merge branch 'master' into JENKINS-49757
MarkEWaite May 14, 2020
1cfb539
Use equals rather than ==
MarkEWaite Jun 6, 2020
e6ac2ed
Use assertThat and is for better msgs
MarkEWaite Jun 6, 2020
eaded93
Clarify assertion
MarkEWaite Jun 6, 2020
21ead1e
Simpler assertThat
MarkEWaite Jun 6, 2020
67ced0e
Merge branch 'master' into JENKINS-49757
MarkEWaite Jun 6, 2020
995d803
Fix compilation error
MarkEWaite Jun 6, 2020
ae036cc
Fix redundant fetch test failure
rishabhBudhouliya Jun 7, 2020
82ffbbf
Enable CleanBeforeCheckout to be decorated in the CloneCommand
rishabhBudhouliya Jun 10, 2020
3bc0059
Fix assertRedundantFetchIsTrue by reducing the scope of fetch argumen…
rishabhBudhouliya Jun 10, 2020
57ab0d0
Merge branch 'master' into CleanBeforeCheckout
rishabhBudhouliya Jun 12, 2020
05daa5e
Update assertion of git fetch arg from build logs with pattern matching
rishabhBudhouliya Jun 12, 2020
d3a1e22
Merge remote-tracking branch 'upstream/master'
rishabhBudhouliya Jun 17, 2020
36e3e7d
Merge branch 'master' into CleanBeforeCheckout
rishabhBudhouliya Jun 17, 2020
deb1b78
Do not decorate clone command with a clean
rishabhBudhouliya Jun 17, 2020
c4c47cb
Fix testCleanBeforeCheckout assertions
rishabhBudhouliya Jun 17, 2020
e8d1bca
Determine if second fetch call is redundant
rishabhBudhouliya Jun 24, 2020
b54faeb
Do not aggregate GitSCMExtension imports
rishabhBudhouliya Jun 24, 2020
79cf010
Merge branch 'master' of https://github.com/jenkinsci/git-plugin
rishabhBudhouliya Jun 24, 2020
a38f1e2
Merge branch 'master' into CleanBeforeCheckout
rishabhBudhouliya Jun 24, 2020
1be3697
Correct spacing in foreach loop
rishabhBudhouliya Jun 24, 2020
15e2f52
Remove unused imports
rishabhBudhouliya Jun 24, 2020
7957017
Merge branch 'master' into CleanBeforeCheckout
MarkEWaite Jun 28, 2020
f2fecc8
Add missing import
MarkEWaite Jun 28, 2020
a7685db
Fix imports
MarkEWaite Jun 28, 2020
1623253
Run the git command to configure test repo
MarkEWaite Jun 28, 2020
09726f1
Use shallow clone randomly to improve coverage
MarkEWaite Jun 28, 2020
c7b7ec6
Place CloneOption import in its sorted location
MarkEWaite Jun 28, 2020
f7b77e6
Add test to check second fetch is used when needed
MarkEWaite Jun 28, 2020
534818a
Mark the rc arg as NonNull, caller checks for null
MarkEWaite Jun 28, 2020
c2e097d
Non breaking change: simplification of if-else clause
rishabhBudhouliya Jun 28, 2020
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
12 changes: 12 additions & 0 deletions src/test/java/hudson/plugins/git/GitSCMTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,12 @@ public void testAvoidRedundantFetch() throws Exception {

/* Without honor refspec on initial clone */
FreeStyleProject projectWithMaster = setupProject(repos, Collections.singletonList(new BranchSpec("master")), null, false, null);
if (random.nextBoolean()) {
/* Randomly enable shallow clone, should not alter test assertions */
CloneOption cloneOptionMaster = new CloneOption(false, null, null);
cloneOptionMaster.setDepth(1);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I fail to understand, why would need a shallow clone to improve coverage when we already have a full normal clone?

Copy link
Contributor

Choose a reason for hiding this comment

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

Good question. One branch was not being reached when a cloneOption extension is detected but does not have honor refspec enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay. I didn't consider other CloneOptions. If honor refspec is false, with avoiding the second fetch, we will also avoid other clone options like Shallow Clone, Disable tags, Reference a repo and timeout.

The good news is that the first fetch is capable to execute all of these options if we miss the second fetch. It should not make any difference to the user's expectation on git repository information after the checkout.

((GitSCM) projectWithMaster.getScm()).getExtensions().add(cloneOptionMaster);
}

// create initial commit
final String commitFile1 = "commitFile1";
Expand All @@ -375,6 +381,12 @@ public void testAvoidRedundantFetchWithoutHonorRefSpec() throws Exception {

/* Without honor refspec on initial clone */
FreeStyleProject projectWithMaster = setupProject(repos, Collections.singletonList(new BranchSpec("master")), null, false, null);
if (random.nextBoolean()) {
/* Randomly enable shallow clone, should not alter test assertions */
CloneOption cloneOptionMaster = new CloneOption(false, null, null);
cloneOptionMaster.setDepth(1);
((GitSCM) projectWithMaster.getScm()).getExtensions().add(cloneOptionMaster);
}

// create initial commit
final String commitFile1 = "commitFile1";
Expand Down